cdk_radio(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_radio ๐Ÿ’– โ€” the Cdk radio list widget (manual page cdk_radio(3), library calls section, bestie)

okay so. you found the cdk_radio(3) page and you're like "what is this" โ€” it's the Cdk radio list widget, and yes it's exactly as cute as it sounds. a radio list, like the little round buttons where you pick one and only one. that's the vibe. let's get into it. โœจ


๐ŸŒธ NAME ๐ŸŒธ

cdk_radio โ€” Cdk radio list widget


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

compile situation first, bestie:

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

and the header, obviously:

#include <cdk.h>

now the whole function lineup, every single one, no skips, no cap:

int activateCDKRadio (
               CDKRADIO *radio,
               chtype *actions);

void destroyCDKRadio (
               CDKRADIO *radio);

void drawCDKRadio (
               CDKRADIO *radio,
               boolean box);

void eraseCDKRadio (
               CDKRADIO *radio);

boolean getCDKRadioBox (
               CDKRADIO *radio);

chtype getCDKRadioChoiceCharacter (
               CDKRADIO *radio);

int getCDKRadioCurrentItem (
               CDKRADIO *radio);

chtype getCDKRadioHighlight (
               CDKRADIO *radio);

int getCDKRadioItems (
               CDKRADIO *radio,
               char **list);

chtype getCDKRadioLeftBrace (
               CDKRADIO *radio);

chtype getCDKRadioRightBrace (
               CDKRADIO *radio);

int getCDKRadioSelectedItem (
               CDKRADIO *radio);

int injectCDKRadio (
               CDKRADIO *radio,
               chtype input);

void moveCDKRadio (
               CDKRADIO *radio,
               int xpos,
               int ypos,
               boolean relative,
               boolean refresh);

CDKRADIO *newCDKRadio (
               CDKSCREEN *cdkscreen,
               int xpos,
               int ypos,
               int spos,
               int height,
               int width,
               const char *title,
               CDK_CONST char **radioList,
               int radioListLength,
               chtype choiceCharacter,
               int defaultItem,
               chtype highlight,
               boolean box,
               boolean shadow);

void positionCDKRadio (
               CDKRADIO *radio);

void setCDKRadio (
               CDKRADIO *radio,
               chtype highlight,
               chtype choiceCharacter,
               boolean box);

void setCDKRadioBackgroundAttrib (
               CDKRADIO *radio,
               chtype attribute);

void setCDKRadioBackgroundColor (
               CDKRADIO *radio,
               const char * color);

void setCDKRadioBox (
               CDKRADIO *radio,
               boolean box);

void setCDKRadioBoxAttribute (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioChoiceCharacter (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioCurrentItem (
               CDKRADIO *radio,
               intindex);

void setCDKRadioHighlight (
               CDKRADIO *radio,
               chtype highlight);

void setCDKRadioHorizontalChar (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioItems (
               CDKRADIO *radio,
               CDK_CONST char **list,
               int listSize);

void setCDKRadioLLChar (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioLRChar (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioLeftBrace (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioPostProcess (
               CDKRADIO *radio,
               PROCESSFN callback,
               void * data);

void setCDKRadioPreProcess (
               CDKRADIO *radio,
               PROCESSFN callback,
               void * data);

void setCDKRadioRightBrace (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioSelectedItem (
               CDKRADIO *radio,
               int item);

void setCDKRadioULChar (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioURChar (
               CDKRADIO *radio,
               chtype character);

void setCDKRadioVerticalChar (
               CDKRADIO *radio,
               chtype character);
lowkey that's a lot of functions and yes you're gonna meet all of them. pace yourself, hydrate, it's giving marathon not sprint. ๐Ÿ’…

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea: the Cdk radio widget creates a radio list. that's the whole main character energy of this page. ๐Ÿ“ปโœจ

and then โ€” the part that actually matters for your code โ€” there's a whole lil family of functions that either create the Cdk radio box widget or manipulate it. new one gets born, existing one gets poked and prodded and restyled. that's the deal. ๐Ÿซถ


(part 1 done, bestie โ€” the rest is coming, don't go anywhere) ๐ŸŒˆ

โœจ AVAILABLE FUNCTIONS โœจ

๐Ÿ’– activateCDKRadio

okay so this one activates the radio widget and lets the user actually interact with it. main character moment fr.

  • the parameter radio is a pointer to a non-NULL radio widget. no cap.
  • 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. (iykyk โ€” that's the hands-off mode ๐Ÿ’…)

if the character entered into this widget is RETURN or TAB then this function will return a value from 0 to the number of items minus 1, representing the item selected. it will also set the widget data exitType to vNORMAL. slay.

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. ๐Ÿ˜ญ the escape hatch got hit, bestie.


๐Ÿฆ‹ destroyCDKRadio

removes the widget from the screen and frees memory the object used. it's giving closure. bye babe ๐Ÿซถ


๐ŸŒธ drawCDKRadio

draws the radio widget on the screen. putting it on display, as it should be.

if the box parameter is true, the widget is drawn with a box. ๐ŸŽ€


โœจ eraseCDKRadio

removes the widget from the screen. this does NOT destroy the widget. so it's a little disappearing act, not a breakup โ€” the widget is still very much alive, just not visible. ๐Ÿ’€


๐Ÿ’œ getCDKRadioBox

returns true if the widget will be drawn with a box around it. vibe check: boxed or unboxed? ๐ŸŽ


๐Ÿ“ getCDKRadioChoiceCharacter

returns the character being used to draw the selected element in the list.


โญ getCDKRadioCurrentItem

returns the index of the current item.


๐Ÿ”ฅ getCDKRadioHighlight

returns the attribute of the highlight bar.


๐Ÿงš getCDKRadioItems

optionally copies the radio-box items into the caller's list, which must be large enough since this function does not allocate it. like, you bring the container, okay?? if the list parameter is null, no copying is done. it returns the list size whether or not the list parameter is null. so either way you get the number, periodt.


๐Ÿ’… getCDKRadioLeftBrace

returns the character being used to draw the left brace of the selection box.


๐ŸŒˆ getCDKRadioRightBrace

returns the character being used to draw the right brace of the selection box.


๐Ÿ‘‘ getCDKRadioSelectedItem

returns the selected item of the widget.


๐ŸŽ€ injectCDKRadio

this function injects a single character into the widget. one (1) character. very precise of it.

  • the parameter radio is a pointer to a non-NULL radio 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, so let's break it down:

  • RETURN or TAB โ€” the function returns a value ranging from zero to one less than the number of items, representing the items selected. the widget data exitType is set to vNORMAL. โœจ
  • ESCAPE โ€” the function returns -1. 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. she left early, no explanation ๐Ÿ’€

๐Ÿซถ moveCDKRadio

moves the given widget to the given position. relocation era.

  • 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). and by "weird things" they mean chaos, bestie, do not test it ๐Ÿ™ˆ
  • the final parameter refresh is a boolean value which states whether the widget will get refreshed after the move.

๐ŸŒŸ newCDKRadio

creates a radio widget and returns a pointer to it. the birth of an icon ๐Ÿ’– parameters go a little something like this:

  • 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 โ€” tells where the scroll bar is to be placed. this 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. math girlies rise ๐Ÿงฎ
  • title โ€” is the string which will be displayed at the top of the widget. the title can be more than one line; just provide a carriage return character at the line break. multiline title? we love range. ๐ŸŒˆ
  • radioList โ€” is the list of items to display in the radio list.
  • radioListLength โ€” is the number of elements in the given list.
  • choiceCharacter โ€” is the character to use to highlight the current selection.
  • highlight โ€” specifies the display attribute of the currently selected item.
  • defaultItem โ€” is the index in the list of the default selection.
  • box โ€” is true if 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. sad girl hours ๐Ÿ˜ญ


๐Ÿ’ซ positionCDKRadio

allows the user to move the widget around the screen via the cursor/keypad keys. see cdk_position (3) for key bindings. it's giving drag and drop but make it terminal.


๐ŸŽ€ setCDKRadio

lets the programmer modify certain elements of an existing radio widget.

the parameter names correspond to the same parameter names listed in the newCDKRadio function. so like, same list, same vibes, you already know them. โœจ


๐ŸŒธ setCDKRadioBackgroundAttrib

sets the background attribute of the widget.

the parameter attribute is a curses attribute, e.g., A_BOLD.


๐ŸŒˆ setCDKRadioBackgroundColor

sets the background color of the widget.

the parameter color is in the format of the Cdk format strings.

see cdk_display (3).


๐Ÿ’œ setCDKRadioBox

sets whether the widget will be drawn with a box around it. ๐ŸŽ


โญ setCDKRadioBoxAttribute

this function sets the attribute of the box.


๐Ÿ“ setCDKRadioChoiceCharacter

sets the character to use to draw the selected element in the list.


๐Ÿ”ฅ setCDKRadioCurrentItem

sets the current item by its index in the list.


๐Ÿ‘‘ setCDKRadioHighlight

sets the attribute of the highlight bar.


๐Ÿงš setCDKRadioHorizontalChar

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


๐Ÿ’… setCDKRadioItems

set the radio list items and display the result. the current item is set to the beginning of the list. the previous radio list items stored in the widget are freed. out with the old, in with the new, no takebacks ๐Ÿ’€


๐Ÿซถ setCDKRadioLLChar

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


๐Ÿฆ‹ setCDKRadioLRChar

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


โœจ setCDKRadioLeftBrace

sets the character to use to draw the left brace of the selection box.


๐ŸŒŸ setCDKRadioPostProcess

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).


๐Ÿ’ซ setCDKRadioPreProcess

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 points to data passed to the callback function.

to learn more about pre-processing see cdk_process (3).


๐ŸŒธ setCDKRadioRightBrace

sets the character to use to draw the right brace of the selection box.


๐ŸŽ€ setCDKRadioSelectedItem

sets the selected item.


โญ setCDKRadioULChar

this function sets the upper left hand corner of the widget's box to the given character.


๐Ÿ’œ setCDKRadioURChar

this function sets the upper right hand corner of the widget's box to the given character.


๐Ÿ”ฅ setCDKRadioVerticalChar

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

โŒจ๏ธ KEY BINDINGS โŒจ๏ธ

Okay bestie, so when the widget is activated, there are a bunch of default key bindings that will help the user enter or manipulate the information quickly. The table below lays out the keys and their actions for this widget, so let's get into it ๐Ÿ’…

  • Left Arrow โ€” Shifts the whole list left one character.
  • Right Arrow โ€” Shifts the whole list right one character.
  • Up Arrow โ€” Selects the next item up in the list.
  • Down Arrow โ€” Selects the next item down 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. ๐ŸŽ€

  • $ โ€” Shifts the whole list to the far right.
  • | โ€” Shifts the whole list to the far left.

  • Space โ€” Selects or deselects the current choice.
  • Return โ€” Exits the widget and returns the index of the selected item. This also sets the widget data exitType to vNORMAL.
  • Tab โ€” Exit the widget and return the index of the selected item. 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 ๐Ÿ‘€

cdk(3), cdk_binding(3), cdk_display(3), cdk_position(3), cdk_screen(3)


And that's a wrap on cdk_radio(3), bestie!! This page is from the 2025-01-14 version, so you know it's fresh. Now go forth and radio-button your little heart out ๐Ÿ’–๐ŸŒธ๐Ÿ‘‘