cdk_scroll(3)
๐ NAME ๐
Okay bestie, sit down, hydrate, because we're doing cdk_scroll(3) โ the Cdk scrolling list widget. That's the one from the Library calls section of the manual. It gives you a lil list of items that scrolls, and it's honestly a whole vibe. ๐
๐ฆ SYNOPSIS ๐ฆ
So how do you even get this widget into your program? You link against Cdk like this:
cc [ flag ... ] file ... -lcdk [ library ... ]
and you pull in the header:
#include <cdk.h>
Then you've got this whole roster of functions to work with. Every single one, no skipping, I don't make the rules. ๐
the "do the thing" era
int activateCDKScroll (
CDKSCROLL *scroll,
chtype * actions);
void addCDKScrollItem (
CDKSCROLL *scroll,
const char *item);
void deleteCDKScrollItem (
CDKSCROLL *scroll,
int position);
void destroyCDKScroll (
CDKSCROLL *scroll);
void drawCDKScroll (
CDKSCROLL *scroll,
boolean box);
void eraseCDKScroll (
CDKSCROLL *scroll);
activateCDKScroll is the one that actually gets the widget up and running and lets it take in actions. addCDKScrollItem and deleteCDKScrollItem do exactly what they say โ adding an item and removing whatever's at position. destroyCDKScroll is the goodbye kiss ๐, drawCDKScroll paints it (with or without a box, your call), and eraseCDKScroll wipes it off the screen. โจ
the getters (she's nosy and we love her)
boolean getCDKScrollBox (
CDKSCROLL *scroll);
int getCDKScrollCurrent(
CDKSCROLL *scroll);
int getCDKScrollCurrentItem (
CDKSCROLL *widget);
chtype getCDKScrollHighlight (
CDKSCROLL *scroll,
chtype highlight);
int getCDKScrollCurrentTop (
CDKSCROLL *widget);
int getCDKScrollItems (
CDKSCROLL *scroll,
char **list);
getCDKScrollBox tells you whether there's a box situation going on. getCDKScrollCurrent grabs the current position. getCDKScrollCurrentItem grabs the current item. getCDKScrollHighlight hands you back the highlight attribute. getCDKScrollCurrentTop gives you the current top. And getCDKScrollItems fills your list with the items. Fr fr, a whole information buffet. ๐
the builders and movers
int injectCDKScroll (
CDKSCROLL *scroll,
chtype input);
void insertCDKScrollItem (
CDKSCROLL *scroll,
const char *item);
void moveCDKScroll (
CDKSCROLL *scroll,
int xpos,
int ypos,
boolean relative,
boolean refresh);
CDKSCROLL *newCDKScroll (
CDKSCREEN *cdkscreen,
int xpos,
int ypos,
int spos,
int height,
int width,
const char *title,
CDK_CONST char **itemList,
int items,
boolean numbers,
chtype highlight,
boolean box,
boolean shadow);
void positionCDKScroll (
CDKSCROLL *scroll);
injectCDKScroll shoves an input straight into the widget. insertCDKScrollItem slides an item in. moveCDKScroll repositions the whole thing at xpos, ypos, optionally relative, optionally with a refresh. And then there's newCDKScroll โ the main character constructor ๐ โ which builds you a whole CDKSCROLL * out of a cdkscreen, an xpos, a ypos, a spos, a height, a width, a title, an itemList, a count of items, a numbers flag, a highlight attribute, a box flag and a shadow flag. That's a lot of arguments and she deserves them all. positionCDKScroll just makes it sit pretty in its spot. ๐
the setters, aka the glow-up crew
void setCDKScroll (
CDKSCROLL *scroll,
CDK_CONST char **itemList,
int items,
boolean numbers,
chtype highlight,
boolean box);
void setCDKScrollBackgroundAttrib (
CDKSCROLL *scroll,
chtype attribute);
void setCDKScrollBackgroundColor (
CDKSCROLL *scroll,
const char * color);
void setCDKScrollBox (
CDKSCROLL *scroll,
boolean box);
void setCDKScrollBoxAttribute (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollCurrent(
CDKSCROLL *scroll,
intitem);
void setCDKScrollCurrentItem (
CDKSCROLL *widget,
intitem);
void setCDKScrollHighlight (
CDKSCROLL *scroll,
chtype highlight);
void setCDKScrollHorizontalChar (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollItems (
CDKSCROLL *scroll,
CDK_CONST char **itemList,
int listSize,
boolean numbers);
void setCDKScrollLLChar (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollLRChar (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollPosition (
CDKSCROLL *scroll,
intitem);
void setCDKScrollPostProcess (
CDKSCROLL *scroll,
PROCESSFN callback,
void * data);
void setCDKScrollPreProcess (
CDKSCROLL *scroll,
PROCESSFN callback,
void * data);
void setCDKScrollULChar (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollURChar (
CDKSCROLL *scroll,
chtype character);
void setCDKScrollVerticalChar (
CDKSCROLL *scroll,
chtype character);
Okay so setCDKScroll is the big one โ it sets the itemList, the number of items, the numbers flag, the highlight attribute and the box flag all in one go. setCDKScrollBackgroundAttrib takes a chtype attribute, and setCDKScrollBackgroundColor takes a color string. setCDKScrollBox flips the box flag, setCDKScrollBoxAttribute sets the box character. setCDKScrollCurrent and setCDKScrollCurrentItem take intitem โ yes, exactly like that, copy it character for character, don't @ me ๐. setCDKScrollHighlight sets the highlight, setCDKScrollHorizontalChar sets the horizontal character, and setCDKScrollItems sets the itemList with a listSize and a numbers flag.
Then the corner crew: setCDKScrollLLChar, setCDKScrollLRChar, setCDKScrollULChar and setCDKScrollURChar each set a corner character, and setCDKScrollVerticalChar sets the vertical one. ๐ฆ
setCDKScrollPosition takes an intitem too, and then there's the callback duo: setCDKScrollPostProcess and setCDKScrollPreProcess, which both take a PROCESSFN callback plus a void * data. Pre and post, before and after, a matched set, obsessed. ๐
โจ DESCRIPTION โจ
Here's the tea, bestie: the Cdk scroll widget creates a scrolling list. That's the whole assignment, and she ate. ๐
And every single function listed above? They're the ones that create or manipulate the Cdk scrolling list widget. Creation, manipulation, the full lifecycle, the whole glow-up arc. ๐
That's the setup done โ the next chunk of this page picks up right where we left off, so stay seated. ๐ธ
โจ AVAILABLE FUNCTIONS โจ
okay bestie, this is the whole menu of what you can do with your scroll widget ๐ every single one, no skips, no shortcuts, we're doing all of them. grab a snack ๐
๐ activateCDKScroll
activates the scroll widget and lets the user actually, like, interact with it.
- The parameter
scrollpoints to a non-NULL scroll 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 or TAB then this function will return a value from 0 to the number of items-1, representing the item selected. 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.
๐ฆ addCDKScrollItem
lets the user add an item into an existing scrolling list. new bestie joins the list โจ
- The
scrollparameter points to the scrolling list to add the item to. - The parameter
itemis achar *representing the new item to add. The item is always added to the end of the list.
๐
deleteCDKScrollItem
lets the user add an item into an existing scrolling list.
okay so the original docs literally say "add" here ๐ we are simply the messenger, we do not make the rules. it's a delete function, the name says delete, but the words in the page say add. anyway.
- The
scrollparameter points to the scrolling list to add the item to. - The parameter
f2positionis anintwhich specifies which element to remove.
๐ destroyCDKScroll
removes the widget from the screen and frees memory the object used. it's gone, it's deleted, it's living its truth elsewhere ๐
๐ drawCDKScroll
draws the scroll widget on the screen. If the box option is true, the widget is drawn with a box. boxed = fancy, unboxed = minimalist, both iconic.
๐ง eraseCDKScroll
removes the widget from the screen. This does NOT destroy the widget.
fr fr, erase โ destroy. it's just hiding, not deleting. don't come for me.
โญ getCDKScrollBox
returns true if the widget will be drawn with a box around it.
๐ getCDKScrollCurrent
returns the current item's index.
This is deprecated because the name is inconsistent with other widgets: use getCDKScrollCurrentItem.
deprecated bestie, use the other one, we've moved on ๐
๐ธ getCDKScrollCurrentItem
returns the current item's index in the scroller.
๐ getCDKScrollHighlight
returns the attribute of the highlight bar.
๐ฅ getCDKScrollCurrentTop
returns the top line of the scroller, counting from zero.
๐ซถ getCDKScrollItems
optionally copies the scrolling-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.
heads up: YOU size the list, the function will not do it for you. it's giving "bring your own buffer" ๐ญ
๐ซ injectCDKScroll
injects a single character into the widget.
- The parameter
scrollpoints to a non-NULL scroll widget. - The parameter
characteris the character to inject into the widget.
The return value and side-effect (setting the widget data exitType) depend upon the injected character:
RETURNorTABโ the function returns a value ranging from zero to one less than the number of items, representing the item selected. The widget dataexitTypeis set tovNORMAL.ESCAPEโ the function returns-1. The widget dataexitTypeis set tovESCAPE_HIT.- Otherwise โ unless modified by preprocessing, postprocessing or key bindings, the function returns
-1. The widget dataexitTypeis set tovEARLY_EXIT.
๐ insertCDKScrollItem
lets the user add an item into an existing scrolling list.
- The
scrollparameter points to the scrolling list to add the item to. - The parameter
itemis achar *representing the new item to add.
The item is always added before the current item in the list.
๐ moveCDKScroll
moves the given widget to the given position.
- 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 values TOP, BOTTOM, LEFT, RIGHT, or CENTER when relative = TRUE. (weird things may happen).
- The final parameter
refreshis a boolean value which states whether the widget will get refreshed after the move.
"weird things may happen" is literally what the page says and honestly that is the most honest sentence in this entire document ๐ do not do it.
๐ฆ newCDKScroll
creates a scroll widget and returns a pointer to it. Parameters:
- The
screenparameter is the screen you wish this widget to be placed in. - The parameter
xposcontrols the placement of the object along the horizontal axis. This parameter may be an integer or one of the pre-defined valuesLEFT,RIGHT, andCENTER. yposcontrols the placement of the object along the vertical axis. This parameter may be an integer value or one of the pre-defined valuesTOP,BOTTOM, andCENTER.sposis where the scroll bar is to be placed. This may be one of three values:LEFT, which puts the scroll bar on the left of the scrolling list.RIGHTwhich puts the scroll bar on the right side of the list, andNONEwhich does not add a scroll bar.
heightandwidthcontrol 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.
titleis 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.itemListis the list of items to be displayed in the scrolling list.itemsis the number of elements in the given list.numbersis true if you want the items in the list to have a number attached to the front of the list items.highlightspecifies the display attribute of the currently selected item.boxis true if the widget should be drawn with a box around it.shadowis true to turn the shadow on around this widget.
If the widget could not be created then a NULL pointer is returned.
if you get NULL back, bestie, it did not work. check it. always check it ๐
๐ positionCDKScroll
allows the user to move the widget around the screen via the cursor/keypad keys. See cdk_position (3) for key bindings.
๐บ setCDKScroll
lets the programmer modify certain elements of an existing scroll widget.
The parameter names correspond to the same parameter names listed in the newCDKScroll function.
๐จ setCDKScrollBackgroundAttrib
sets the background attribute of the widget.
The parameter attribute is a curses attribute, e.g., A_BOLD.
๐ setCDKScrollBackgroundColor
sets the background color of the widget.
The parameter color is in the format of the Cdk format strings.
See cdk_display (3).
๐ฆ setCDKScrollBox
sets whether the widget will be drawn with a box around it.
๐ setCDKScrollBoxAttribute
sets the attribute of the box.
๐ฎ setCDKScrollCurrent
sets the index for the current item.
โญ setCDKScrollCurrentItem
set the current item number in the scroller.
๐งต setCDKScrollCurrentTop
set the top line number of the scroller.
๐ setCDKScrollHighlight
sets the attribute of the highlight bar.
๐ setCDKScrollHorizontalChar
sets the horizontal drawing character for the box to the given character.
๐ธ setCDKScrollItems
sets the contents of the scrolling list. The previous contents of the scrolling list stored in the widget are freed.
the old stuff gets freed, so don't go holding onto pointers into it after this, iykyk โ
๐ฆ setCDKScrollLLChar
sets the lower left hand corner of the widget's box to the given character.
๐ setCDKScrollLRChar
sets the lower right hand corner of the widget's box to the given character.
๐ setCDKScrollPosition
sets the current item in the widget to the given position.
๐ setCDKScrollPostProcess
allows the user to have the widget call a function after the key has been applied to the widget.
- The parameter
functionis the callback function. - The parameter
datapoints to data passed to the callback function.
To learn more about post-processing see cdk_process(3).
๐ setCDKScrollPreProcess
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
functionis the callback function. - The parameter
datapoints to data passed to the callback function.
To learn more about pre-processing see cdk_process(3).
๐ setCDKScrollULChar
sets the upper left hand corner of the widget's box to the given character.
๐ setCDKScrollURChar
sets the upper right hand corner of the widget's box to the given character.
๐ช setCDKScrollVerticalChar
sets the vertical drawing character for the box to the given character.
๐ KEY BINDINGS ๐
okay bestie so when the widget is activated there's a whole lil squad of default key bindings that show up to help you punch in or wrangle the info quickly. here's the rundown of every key and what it does for this widget, no cap ๐ซถ
โจ Moving Around โจ
Left Arrowโ shifts the list left by one column. tiny nudge energy.Right Arrowโ shifts the list right by one column. equally tiny, equally valid ๐Up Arrowโ selects the previous item in the list. going back up, we love to see it.Down Arrowโ selects the next item in the list. keep scrolling, main character.
๐ Paging Through ๐
Prev Page,Ctrl-Bโ scrolls one page backward. rewinding the vibe.Next Page,Ctrl-Fโ scrolls one page forward. onward, always onward โจ
๐ฅ Jumping To The Top ๐ฅ
these four are all the same move, pick whichever one lives in your muscle memory:
1<gHome
...all of them move to the first element in the list. iconic shortcut redundancy, honestly. periodt.
๐ Jumping To The Bottom ๐
again, three ways to do the exact same thing, because choice is a gift:
>GEnd
...and they all move to the last element in the list. slay.
โ๏ธ Shifting All The Way โ๏ธ
$โ shifts the list to the far right. no half measures.|โ shifts the list to the far left. all the way over there.
๐ช Getting Out Of There ๐ช
Returnโ exits the widget and returns the index of the selected item. also sets the widget dataexitTypetovNORMAL. clean exit, we love her ๐ซถTabโ same deal bestie: exits the widget, returns the index of the selected item, and sets the widget dataexitTypetovNORMAL.Escapeโ exits the widget and returns-1. also sets the widget dataexitTypetovESCAPE_HIT. the dramatic exit, iykyk ๐ญ
๐ One More Thing ๐
Ctrl-Lโ refreshes the screen. a lil glow-up for your terminal, go off โจ
๐ SEE ALSO ๐
go read these next, bestie, they're all in the family:
and that's the whole page!! ๐ this was cdk_scroll(3), dated 2025-01-14, and you've officially made it to the end of the manual. so proud of you. go forth and scroll responsibly, queen ๐๐ธ
๐ฆ where this page comes from
- debian trixie: libcdk5-dev 5.0.20250116-1 ยท BSD-4-Clause
- 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