cdk_selection(3)

πŸ“¦
version 5.0.20260119 Β· 4 versions
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– cdk_selection β€” the Cdk selection list widget, bestie πŸ’–

okay so welcome to cdk_selection(3), from the Library calls girlies ✨ this is the Cdk selection list widget and she is literally iconic, no cap.


🌸 NAME 🌸

cdk_selection β€” Cdk selection list widget πŸ’…


✨ SYNOPSIS ✨

first things first, you gotta link her up:

cc [ flag ... ] file ...  -lcdk [ library ... ]

and then, obviously, you gotta invite her in:

#include <cdk.h>

now here's the whole friend group, every single function, exactly as she comes 🫢

int activateCDKSelection (
               CDKSELECTION *selection,
               chtype * actions);

void destroyCDKSelection (
               CDKSELECTION *selection);

void drawCDKSelection (
               CDKSELECTION *selection,
               boolean box);

void eraseCDKSelection (
               CDKSELECTION *selection);

boolean getCDKSelectionBox (
               CDKSELECTION *selection);

int getCDKSelectionChoice (
               CDKSELECTION *selection,
               int index);

int *getCDKSelectionChoices (
               CDKSELECTION *selection);

int getCDKSelectionCurrent (
               CDKSELECTION *selection);

chtype getCDKSelectionHighlight (
               CDKSELECTION *selection);

int getCDKSelectionItems (
               CDKSELECTION *selection,
               char **list);

int getCDKSelectionMode (
               CDKSELECTION *selection,
               int index);

int *getCDKSelectionModes (
               CDKSELECTION *selection);

char *getCDKSelectionTitle (
               CDKSELECTION *selection);

int injectCDKSelection (
               CDKSELECTION *selection,
               chtype input);

void moveCDKSelection (
               CDKSELECTION *selection,
               int xpos,
               int ypos,
               boolean relative,
               boolean refresh);

CDKSELECTION *newCDKSelection (
               CDKSCREEN *cdkscreen,
               int xpos,
               int ypos,
               int spos,
               int height,
               int width,
               const char *title,
               CDK_CONST char **selectionList,
               int selectionListLength,
               CDK_CONST char **choiceList,
               int choiceListLength,
               chtype highlight,
               boolean box,
               boolean shadow);

void positionCDKSelection (
               CDKSELECTION *selection);

void setCDKSelection (
               CDKSELECTION *selection,
               chtype highlight,
               int *defChoices,
               boolean box);

void setCDKSelectionBackgroundAttrib (
               CDKSELECTION *selection,
               chtype attribute);

void setCDKSelectionBackgroundColor (
               CDKSELECTION *selection,
               const char * color);

void setCDKSelectionBox (
               CDKSELECTION *selection,
               boolean boxWidget);

void setCDKSelectionBoxAttribute (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionChoice (
               CDKSELECTION *selection,
               int index,
               int choice);

void setCDKSelectionChoices (
               CDKSELECTION *selection,
               int *choices);

void setCDKSelectionCurrent (
               CDKSELECTION *selection,
               intindex);

void setCDKSelectionHighlight (
               CDKSELECTION *selection,
               chtype highlight);

void setCDKSelectionHorizontalChar (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionItems (
               CDKSELECTION *selection,
               CDK_CONST char **list,
               int listSize);

void setCDKSelectionLLChar (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionLRChar (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionMode (
               CDKSELECTION *selection,
               int index,
               int mode);

void setCDKSelectionModes (
               CDKSELECTION *selection,
               int *modes);

void setCDKSelectionPostProcess (
               CDKSELECTION *selection,
               PROCESSFN callback,
               void * data);

void setCDKSelectionPreProcess (
               CDKSELECTION *selection,
               PROCESSFN callback,
               void * data);

void setCDKSelectionTitle (
               CDKSELECTION *selection,
               const char *title);

void setCDKSelectionULChar (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionURChar (
               CDKSELECTION *selection,
               chtype character);

void setCDKSelectionVerticalChar (
               CDKSELECTION *selection,
               chtype character);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the Cdk selection widget? she literally creates a selection list. that's the whole vibe, that's the moment, main character energy fr fr 🌈

and all the functions listed up there in the synopsis? yeah, those are the ones that either create her or manipulate her. the Cdk selection list widget. periodt πŸ’…

ngl there is so much more to come β€” the descriptions of every single function, the modes, the options, all of it. this is just the lil intro, bestie. stay tuned πŸŽ€

✨ AVAILABLE FUNCTIONS ✨

okay bestie, here’s the whole lineup of functions for the selection widget. every single one is present, no skips, no cap. πŸ’…


activateCDKSelection 🌸

activates the selection widget and lets the user interact with the widget. it’s giving β€œmain character takes the wheel.”

  • The parameter selection is a pointer to a non-NULL selection 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 or TAB then this function will return 1. It will also set the widget data exitType to vNORMAL. If the character entered into this widget was ESCAPE then the widget will return a value of -1 and the widget data exitType will be set to vESCAPE_HIT.

destroyCDKSelection πŸ’€

removes the widget from the screen and frees memory the object used.

drawCDKSelection πŸŽ€

draws the selection widget on the screen. If the box parameter is true, the widget is drawn with a box.

eraseCDKSelection 🧚

removes the widget from the screen. This does NOT destroy the widget.

getCDKSelectionBox πŸ¦‹

returns true if the widget will be drawn with a box around it.

getCDKSelectionChoice ⭐

returns the selection choice at the given index.

getCDKSelectionChoices πŸ“

returns an array of the current selection choices for the widget.

getCDKSelectionCurrent πŸ’–

returns the current selection index.

getCDKSelectionHighlight 🌈

returns the attribute of the highlight bar.

getCDKSelectionItems πŸ‘‘

optionally copies the selection-list items into the caller’s list, which must be large enough since this function does not allocate it. If the list parameter is null, no copying is done. It returns the list size whether or not the list parameter is null.

getCDKSelectionMode πŸ”₯

returns the selection mode at the given index.

getCDKSelectionModes ✨

returns an array of the current modes for the widget.

getCDKSelectionTitle πŸŽ€

returns the first line of the title of the selection widget. The caller must free the returned value.

injectCDKSelection πŸ’‰

injects a single character into the widget.

  • The parameter selection is a pointer to a non-NULL selection widget.
  • The parameter character is the character to inject into the widget.

The return value and side-effect (setting the widget data exitType) depend upon the injected character:

  • RETURN or TAB β€” the function returns 1. The widget data exitType is set to vNORMAL.
  • ESCAPE β€” the function returns -1. vESCAPE_HIT. The widget data exitType is set to vESCAPE_HIT.
  • Otherwise β€” unless modified by preprocessing, postprocessing or key bindings, the function returns -1. The widget data exitType is set to vEARLY_EXIT.

moveCDKSelection πŸ•Ί

moves the given widget to the given position.

  • 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).
  • The final parameter refresh is a boolean value which states whether the widget will get refreshed after the move.

newCDKSelection 🌟

creates a selection widget and returns a pointer to it. 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.
  • spos β€” is where the scroll bar is to be placed. It may be one of three values:
    • LEFT puts the scroll bar on the left of the scrolling list.
    • RIGHT puts the scroll bar on the right side of the list, and
    • NONE does not add a scroll bar.
  • height and width β€” control the height and width of the widget. If you provide a value of zero for either of the height or the width, the widget will be created with the full width and height of the screen. If you provide a negative value, the widget will be created the full height or width minus the value provided.
  • title β€” is the string which to display at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break.
  • selectionList β€” is the list of items to display in the selection list.
  • selectionListLength β€” is the number of elements in the given list.
  • choiceList β€” is the list of choices that will be selected when the user presses the space bar.
  • choiceListLength β€” is the length of this list.
  • highlight β€” specifies the display attribute of the currently selected item.
  • 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.

positionCDKSelection 🧭

allows the user to move the widget around the screen via the cursor/keypad keys. See cdk_position (3) for key bindings.

setCDKSelection πŸ› οΈ

lets the programmer modify certain elements of an existing selection widget. The parameter names correspond to the same parameter names listed in the newCDKSelection function.

setCDKSelectionBackgroundAttrib 🎨

sets the background attribute of the widget. The parameter attribute is a curses attribute, e.g., A_BOLD.

setCDKSelectionBackgroundColor 🌈

sets the background color of the widget. The parameter color is in the format of the Cdk format strings. See cdk_display (3).

setCDKSelectionBox πŸ“¦

sets whether the widget will be drawn with a box around it.

setCDKSelectionBoxAttribute πŸ”₯

sets the attribute of the box.

setCDKSelectionChoice πŸ’«

sets the selection choice value at the given index.

setCDKSelectionChoices 🫢

sets the selection choice values of the widget.

setCDKSelectionCurrent πŸ‘‘

sets the current selection index.

setCDKSelectionHighlight ✨

sets the attribute of the highlight bar.

setCDKSelectionHorizontalChar βž–

sets the horizontal drawing character for the box to the given character.

setCDKSelectionItems πŸ“

sets the selection list items. The previous selection list items stored in the widget are freed.

setCDKSelectionLLChar πŸ“

sets the lower left hand corner of the widget’s box to the given character.

setCDKSelectionLRChar πŸ“

sets the lower right hand corner of the widget’s box to the given character.

setCDKSelectionMode πŸŽ›οΈ

sets the selection mode at the given index.

setCDKSelectionModes 🧚

sets the selection mode of the elements of the widget. There are two acceptable values for the modes:

  • 0 which allows the user to change the selection value at the given index; and
  • 1 which sets the element to a read-only state.

setCDKSelectionPostProcess πŸ’€

allows the user to have the widget call a function after the key has been applied to the widget. The parameter function is the callback function. The parameter data points to data passed to the callback function. To learn more about post-processing see cdk_process(3).

setCDKSelectionPreProcess πŸ¦‹

allows the user to have the widget call a function after a key is hit and before the key is applied to the widget. The parameter function is the callback function. The parameter data is a pointer to void. To learn more about pre-processing see cdk_process(3).

setCDKSelectionTitle πŸŽ€

set the selection list’s title.

setCDKSelectionULChar πŸ“

sets the upper left hand corner of the widget’s box to the given character.

setCDKSelectionURChar πŸ“

sets the upper right hand corner of the widget’s box to the given character.

setCDKSelectionVerticalChar βž•

sets the vertical drawing character for the box to the given character.

⌨️ KEY BINDINGS ⌨️

Okay bestie so when the widget gets activated (yes, the moment it wakes up and becomes the main character πŸ’…) there are a bunch of default key bindings that help the user enter or manipulate the info fast. Here's the whole tea, every single one, no skips:

  • Left Arrow β€” Shift the whole list left one column.
  • Right Arrow β€” Shift the whole list right one column.
  • Up Arrow β€” Select the previous item in the list.
  • Down Arrow β€” Select the next item in the list.

  • Prev Page, Ctrl-B β€” Scroll one page backward.

  • Next Page, Ctrl-F β€” Scroll one page forward.

  • 1, <, g, Home β€” Move to the first element in the list.

  • >, G, End β€” Move to the last element in the list.

  • $ β€” Shift the whole list to the far right.
  • | β€” Shift the whole list to the far left.

  • Space β€” Cycles to the next choice on the current item. πŸŒ€
  • Return β€” Exit the widget and return 1. Also set the widget data exitType to vNORMAL.
  • Tab β€” Exit the widget and return 1. Also set the widget data exitType to vNORMAL.
  • Escape β€” Exit the widget and return -1. Also set the widget data exitType to vESCAPE_HIT.
  • Ctrl-L β€” Refreshes the screen. ✨
Not me pointing out that Return and Tab do the exact same thing and both set exitType to vNORMAL, while Escape is the dramatic one that bails with -1 and sets exitType to vESCAPE_HIT. Two icons, two vibes, zero overlap. 🫢

πŸ‘€ SEE ALSO πŸ‘€


And that's the whole page, bestie, we ate and left no crumbs πŸ“πŸ’– This little love letter to the selection widget is cdk_selection(3), dated 2025-01-14, and it's signed off the way manpages always are β€” with the page name and that date chillin' in the footer. Go forth and select things, you absolute icon. πŸ’…πŸŒˆπŸ‘‘