cdk_scroll(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

๐Ÿ’– 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 scroll points to a non-NULL scroll 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 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 scroll parameter points to the scrolling list to add the item to.
  • The parameter item is a char * 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 scroll parameter points to the scrolling list to add the item to.
  • The parameter f2position is an int which 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 scroll points to a non-NULL scroll 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 a value ranging from zero to one less than the number of items, representing the item 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.

๐Ÿ“ insertCDKScrollItem

lets the user add an item into an existing scrolling list.

  • The scroll parameter points to the scrolling list to add the item to.
  • The parameter item is a char * 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 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.
"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 screen parameter is the screen you wish this widget to be placed in.
  • The parameter xpos controls the placement of the object along the horizontal axis. This parameter 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. This parameter may be an integer value or one of the pre-defined values TOP, BOTTOM, and CENTER.
  • spos is 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.
    • RIGHT which puts the scroll bar on the right side of the list, and
    • NONE which 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 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.
  • itemList is the list of items to be displayed in the scrolling list.
  • items is the number of elements in the given list.
  • numbers is true if you want the items in the list to have a number attached to the front of the list items.
  • 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 is 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 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).


๐Ÿ’Œ 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 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).


๐ŸŽ 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
  • <
  • g
  • Home

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

  • >
  • G
  • End

...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 data exitType to vNORMAL. clean exit, we love her ๐Ÿซถ
  • Tab โ€” same deal bestie: exits the widget, returns the index of the selected item, and sets the widget data exitType to vNORMAL.
  • Escape โ€” exits the widget and returns -1. also sets the widget data exitType to vESCAPE_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 ๐Ÿ‘‘๐ŸŒธ