cdk_viewer(3)

๐Ÿ“ฆ
version 5.0.20260119 ยท 3 versions
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– 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 viewer is a pointer to a non-NULL viewer widget.
  • if the actions parameter 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 xpos and ypos are 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 relative states whether the xpos/ypos pair 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 values TOP, BOTTOM, LEFT, RIGHT, or CENTER when relative = TRUE. (weird things may happen). like, we're warning you fr fr. ๐Ÿ’€
  • the final parameter refresh is 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 values LEFT, RIGHT, and CENTER.
  • ypos โ€” controls the placement of the object along the vertical axis. it may be an integer or one of the pre-defined values TOP, BOTTOM, and CENTER.
  • height and width โ€” 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 in buttons.
  • buttonHighlight โ€” is the highlight attribute of the currently selected button.
  • box โ€” is true if 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 ๐Ÿ’…

  • title is the title to be displayed on the top of the viewer.
  • list is the information to display,
  • listSize states how many rows there are in the list array. if listSize is negative, list is scanned to find its length, including files which will be included via embedded links.
  • buttonAttribute states the attribute of the current highlighted button.
  • the boolean parameter interpret tells the viewer to interpret the contents of list for Cdk display command.
  • the showLineInfo boolean flag tells the viewer to show to show the line number and percentage in the top left corner of the viewer window.
  • the parameters box and shadow are the same as in the function description of newCDKViewer.

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 data exitType to vNORMAL. โœ…
  • Escape โ€” exit the widget and return -1. Set the widget data exitType to vESCAPE_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. ๐Ÿ’–โœจ