cdk_viewer(3)
๐ cdk_viewer โ the Cdk viewer list widget ๐
okay bestie, gather round, because we're about to talk about cdk_viewer from the Cdk library and honestly? it's giving main character energy for anyone who's ever wanted a file viewer in their terminal. ๐ฆ
โจ SYNOPSIS โจ
like, here's how you actually pull it into your life:
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
and then the whole squad of functions you get to play with:
int activateCDKViewer (
CDKVIEWER *viewer);
void cleanCDKViewer (
CDKVIEWER *viewer);
void destroyCDKViewer (
CDKVIEWER *viewer);
void drawCDKViewer (
CDKVIEWER *viewer,
boolean box);
void eraseCDKViewer (
CDKVIEWER *viewer);
boolean getCDKViewerBox (
CDKVIEWER *viewer);
chtype getCDKViewerHighlight (
CDKVIEWER *viewer);
chtype **getCDKViewerInfo (
CDKVIEWER *viewer,
char **itemList);
boolean getCDKViewerInfoLine (
CDKVIEWER *viewer);
chtype **getCDKViewerTitle (
CDKVIEWER *viewer);
void moveCDKViewer (
CDKVIEWEE *viewer,
int box,
int box,
boolean relative,
boolean refresh);
CDKVIEWER *newCDKViewer (
CDKSCREEN *cdkscreen,
int xpos,
int ypos,
int height,
int width,
CDK_CONST char **buttonList,
int buttonCount,
chtype buttonHighlight,
boolean box,
boolean shadow);
void positionCDKViewer (
CDKVIEWER *viewer);
void setCDKViewer (
CDKVIEWER *viewer,
const char *title,
CDK_CONST char **list,
int listSize,
chtype buttonAttribute,
boolean interpret,
boolean showLineInfo,
boolean box);
void setCDKViewerBackgroundAttrib (
CDKVIEWER *viewer,
chtype attribute);
void setCDKViewerBackgroundColor (
CDKVIEWER *viewer,
const char * color);
void setCDKViewerBox (
CDKVIEWER *viewer,
boolean Box);
void setCDKViewerBoxAttribute (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerHighlight (
CDKVIEWER *viewer,
chtype highlight);
void setCDKViewerHorizontalChar (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerInfo (
CDKVIEWER *viewer,
CDK_CONST char **list,
int listSize,
boolean interpret);
void setCDKViewerInfoLine (
CDKVIEWER *viewer,
boolean showInfoLine);
void setCDKViewerLLChar (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerLRChar (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerTitle (
CDKVIEWER *viewer,
const char *title);
void setCDKViewerULChar (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerURChar (
CDKVIEWER *viewer,
chtype character);
void setCDKViewerVerticalChar (
CDKVIEWER *viewer,
chtype character);
๐ธ DESCRIPTION ๐ธ
so the Cdk viewer widget is literally a whole file viewer, but make it a widget. it lets a user interact with a file. ๐ซถ
and before you ask โ it does NOT allow editing. it is view only, bestie. look, don't touch. no cap. ๐
the rest of this page is the full roster of functions that create or manipulate the Cdk viewer list widget, so let's get into it. ๐
๐ฅ AVAILABLE FUNCTIONS ๐ฅ
activateCDKViewer
activates the viewer widget and lets the user actually, y'know, interact with it. ๐
- the parameter
vieweris a pointer to a non-NULL viewer widget. - if the
actionsparameter is passed with a non-NULL value, the characters in the array will be injected into the widget.
to activate the widget interactively, pass in a NULL pointer for actions.
if the character entered into this widget is RETURN, then this function returns a value from 0 to the number of buttons -1, representing the button selected. it will also set the widget data exitType to vNORMAL. โจ
if the character entered into this widget was ESCAPE, then the widget returns a value of -1 and the widget data exitType gets set to vESCAPE_HIT. ๐ญ
cleanCDKViewer
clears the information from the window. bye bye clutter ๐งน
destroyCDKViewer
removes the widget from the screen and frees the memory the object used. it's giving closure. ๐ฆ
drawCDKViewer
draws the viewer widget on the screen. if the box option is true, the widget is drawn with a box. ๐ฆ
eraseCDKViewer
removes the widget from the screen. and no, bestie, this does NOT destroy the widget. it's just... gone from view. hiding. main character exit. ๐
getCDKViewerBox
returns true if the widget will be drawn with a box around it. โญ
getCDKViewerHighlight
returns the attribute of the buttons.
getCDKViewerInfo
returns the contents of the viewer widget. ๐
getCDKViewerInfoLine
returns true if the information line is on.
getCDKViewerTitle
returns the title of the widget. โจ
moveCDKViewer
function moves the given widget to the given position. slay, mobility.
- the parameters
xposandyposare the new position of the widget.
the parameter xpos may be an integer or one of the pre-defined values TOP, BOTTOM, and CENTER.
the parameter ypos may be an integer or one of the pre-defined values LEFT, RIGHT, and CENTER.
- the parameter
relativestates whether thexpos/ypospair is a relative move or an absolute move.
for example, if xpos = 1 and ypos = 2 and relative = TRUE, then the widget would move one row down and two columns right. if the value of relative was FALSE, then the widget would move to the position (1,2).
do NOT use the valuesTOP,BOTTOM,LEFT,RIGHT, orCENTERwhenrelative = TRUE. (weird things may happen). like, we're warning you fr fr. ๐
- the final parameter
refreshis a boolean value which states whether the widget will get refreshed after the move.
*newCDKViewer
function creates a viewer widget and returns a pointer to it. it's the birth of an icon, honestly. ๐
parameters:
screenโ is the screen you wish this widget to be placed in.xposโ controls the placement of the object along the horizontal axis. it may be an integer or one of the pre-defined valuesLEFT,RIGHT, andCENTER.yposโ controls the placement of the object along the vertical axis. it may be an integer or one of the pre-defined valuesTOP,BOTTOM, andCENTER.heightandwidthโ are the height and width of the viewer window.buttonsโ is an array of the button labels which are to be attached to the viewer on the bottom.buttonCountโ is the number of buttons inbuttons.buttonHighlightโ is the highlight attribute of the currently selected button.boxโ istrueif the widget should be drawn with a box around it.shadowโ turns the shadow on or off around this widget.
if the widget could not be created then a NULL pointer is returned. ๐ญ not the flop era.
positionCDKViewer
allows the user to move the widget around the screen via the cursor/keypad keys. see cdk_position (3) for key bindings. ๐ฎ
setCDKViewer
lets the programmer modify several elements of an existing viewer widget. glow-up time ๐
titleis the title to be displayed on the top of the viewer.listis the information to display,listSizestates how many rows there are in thelistarray. iflistSizeis negative,listis scanned to find its length, including files which will be included via embedded links.buttonAttributestates the attribute of the current highlighted button.- the boolean parameter
interprettells the viewer to interpret the contents oflistfor Cdk display command. - the
showLineInfoboolean flag tells the viewer to show to show the line number and percentage in the top left corner of the viewer window. - the parameters
boxandshadoware the same as in the function description ofnewCDKViewer.
setCDKViewerBackgroundAttrib
sets the background attribute of the widget.
the parameter attribute is a curses attribute, e.g., A_BOLD.
setCDKViewerBackgroundColor
sets the background color of the widget.
the parameter color is in the format of the Cdk format strings.
see cdk_display (3).
setCDKViewerBox
sets whether the widget will be drawn with a box around it. ๐ฆโจ
setCDKViewerBoxAttribute
sets the attribute of the box.
setCDKViewerHighlight
sets the highlight attribute of the buttons on the widget. โจ
setCDKViewerHorizontalChar
sets the horizontal drawing character for the box to the given character.
setCDKViewerInfo
sets the contents of the viewer widget.
see setCDKViewer for parameter descriptions.
setCDKViewerInfoLine
turns on/off the information line in the top left hand corner of the widget. if the value of showInfoLine is TRUE, the information line will be displayed. if it is FALSE it won't. periodt. ๐
setCDKViewerLLChar
sets the lower left hand corner of the widget's box to the given character.
setCDKViewerLRChar
sets the lower right hand corner of the widget's box to the given character.
setCDKViewerTitle
sets the title of the widget. ๐
setCDKViewerULChar
sets the upper left hand corner of the widget's box to the given character.
setCDKViewerURChar
sets the upper right hand corner of the widget's box to the given character.
setCDKViewerVerticalChar
sets the vertical drawing character for the box to the given character.
๐ KEY BINDINGS ๐
okay bestie, so when the widget is activated, there are several default key bindings that help the user enter or manipulate the information quickly. The following table outlines the keys and their actions for this widget. I turned it into a bullet list because tables are not the vibe here, but every single key and action is still present, no cap.
Left Arrowโ shifts the viewport one column left. ๐Right Arrowโ shifts the viewport one column left. (Yes, literally left. Thatโs the manpageโs story, and Iโm sticking to it. ๐)Up Arrowโ scrolls the viewport one line up. โฌ๏ธDown Arrowโ scrolls the viewport one line down. โฌ๏ธPrev Page,Ctrl-B,B,bโ scroll one page backward. ๐Next Page,Ctrl-F,Space,F,fโ scroll one page forward. ๐Home,|โ shift the whole list to the far left. โฌ ๏ธEnd,$โ shift the whole list to the far right. โก๏ธ1,<,gโ moves to the first line in the viewer. ๐ฅ>,Gโ moves to the last line in the viewer. ๐Lโ moves half the distance to the end of the viewer. ๐lโ moves half the distance to the top of the viewer. ๐?โ searches up for a pattern. ๐/โ searches down for a pattern. ๐nโ repeats last search. ๐Nโ repeats last search, reversed direction. โฉ๏ธ:โ jumps to a given line. ๐ฏiโ displays file statistics. ๐sโ displays file statistics. ๐Tabโ switches buttons. ๐Returnโ exit the widget and return the index of the selected button. Set the widget dataexitTypetovNORMAL. โEscapeโ exit the widget and return-1. Set the widget dataexitTypetovESCAPE_HIT. โCtrl-Lโ refreshes the screen. ๐
๐ฆ SEE ALSO ๐ฆ
This page was cdk_viewer(3), dated 2024-03-28. Thatโs the source/version and date energy, bestie. Bye, go scroll something iconic. ๐โจ
๐ฆ where this page comes from
- debian trixie: libcdk5-dev 5.0.20250116-1 ยท BSD-4-Clause
- fedora 43: cdk 5.0.20240619-4.fc43 ยท LicenseRef-Callaway-BSD-with-advertising
- fedora 43: cdk 5.0.20240619-4.fc43 ยท LicenseRef-Callaway-BSD-with-advertising
- fedora 43: cdk 5.0.20251014-1.fc43 ยท X11-distribute-modifications-variant
- fedora 43: cdk 5.0.20251014-1.fc43 ยท X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 ยท X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 ยท X11-distribute-modifications-variant
- nixos 26.05: cdk 5.0-20260119
- nixpkgs unstable: cdk 5.0-20260119
- ubuntu questing: libcdk5-dev 5.0.20250116-1
- ubuntu resolute: libcdk5-dev 5.0.20251014-1 ยท BSD-4-Clause
- ubuntu stonking: libcdk5-dev 5.0.20260119-1 ยท BSD-4-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms