cdk_alphalist(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_alphalist(3) β€” library calls, but make it cute πŸ¦‹

okay bestie, gather round, because we're about to talk about cdk_alphalist from the cdk library calls corner of the manual (section 3, iykyk). it's a whole sorted-list widget and honestly? it ate. let's get into it πŸ’…


πŸ’– NAME πŸ’–

cdk_alphalist β€” Cdk sorted list widget.


✨ SYNOPSIS ✨

first things first, you link against it like this, no notes:

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

and you pull in the header, obviously:

#include <cdk.h>

then here's the whole roster of functions this widget brings to the function party, fr fr:

char *activateCDKAlphalist (
               CDKALPHALIST *alphalist,
               chtype *actions);

void destroyCDKAlphalist (
               CDKALPHALIST *alphalist);

void drawCDKAlphalist (
               CDKALPHALIST *alphalist,
               boolean box);

void eraseCDKAlphalist (
               CDKALPHALIST *alphalist);

boolean getCDKAlphalistBox (
               CDKALPHALIST *alphalist);

char **getCDKAlphalistContents (
               CDKALPHALIST *alphalist,
               int *size);

int getCDKAlphalistCurrentItem (
               CDKALPHALIST *widget);

chtype getCDKAlphalistFillerChar (
               CDKALPHALIST *alphalist);

chtype getCDKAlphalistHighlight (
               CDKALPHALIST *alphalist);

char *injectCDKAlphalist (
               CDKALPHALIST *alphalist,
               chtype input);

void moveCDKAlphalist (
               CDKALPHALIST *alphalist,
               int xpos,
               int ypos,
               boolean relative,
               boolean refresh);

CDKALPHALIST *newCDKAlphalist (
               CDKSCREEN *cdkscreen,
               int xpos,
               int ypos,
               int height,
               int width,
               const char * title,
               const char * label,
               CDK_CONST char ** list,
               int listSize,
               chtype fillerCharacter,
               chtype highlight,
               boolean box,
               boolean shadow);

void positionCDKAlphalist (
               CDKALPHALIST *alphalist);

void setCDKAlphalist (
               CDKALPHALIST *alphalist,
               CDK_CONST char ** list,
               int listSize,
               chtype fillerCharacter,
               chtype highlight,
               boolean box);

void setCDKAlphalistBackgroundAttrib (
               CDKALPHALIST *alphalist,
               chtype attribute);

void setCDKAlphalistBackgroundColor (
               CDKALPHALIST *alphalist,
               const char * color);

void setCDKAlphalistBox (
               CDKALPHALIST *alphalist,
               boolean box);

void setCDKAlphalistBoxAttribute (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistContents (
               CDKALPHALIST *alphalist,
               CDK_CONST char ** list,
               int listSize);

void setCDKAlphalistCurrentItem (
               CDKALPHALIST *widget,
               int item);

void setCDKAlphalistFillerChar (
               CDKALPHALIST *alphalist,
               chtype fillerCharacter);

void setCDKAlphalistHighlight (
               CDKALPHALIST *alphalist,
               chtype highlight);

void setCDKAlphalistHorizontalChar (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistLLChar (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistLRChar (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistPostProcess (
               CDKALPHALIST *alphalist,
               PROCESSFN callback,
               void * data);

void setCDKAlphalistPreProcess (
               CDKALPHALIST *alphalist,
               PROCESSFN callback,
               void * data);

void setCDKAlphalistULChar (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistURChar (
               CDKALPHALIST *alphalist,
               chtype character);

void setCDKAlphalistVerticalChar (
               CDKALPHALIST *alphalist,
               chtype character);

like, that's the whole squad 🫢 getters, setters, the constructor, the destructor, the whole glow-up. we'll get into what each one does in the parts that follow, don't even worry.


🌈 DESCRIPTION 🌈

so here's the tea πŸ“ the Cdk alphalist lets a user select from a list of alphabetically sorted words. yes, alphabetically sorted, that's literally its whole thing, it's the main character of sorted lists.

the user can use the arrow keys to traverse through the list, slay, classic. or β€” and this is the fun part β€” they can type in the beginning of the word and the list will automatically adjust itself in the correct place in the scrolling list. not me typing two letters and the widget just knowing where I meant to be 😭✨ it's giving mind-reading, it's giving bestie intuition.

and here's the structural lore you need: this widget, like the file selector widget, is a compound widget of both the entry field widget and the scrolling list widget. so it's not doing some brand-new solo thing β€” it's the two of them holding hands and becoming one iconic duo πŸ’–πŸ‘‘ that's why it can take typed input and scroll, periodt.

bestie note: keep that "compound widget" fact in your pocket, because it explains basically everything about how this thing behaves later. no cap.

and that's the setup, the whole vibe check passed with flying colors 🌸 more sections are coming your way, so stay tuned, don't touch that dial πŸ’œ

✨ AVAILABLE FUNCTIONS ✨

okay bestie, here's the whole roster of functions this widget ships with πŸ’– no skipping, we're doing all of them.


activateCDKAlphalist

activates the alphalist widget and lets the user actually interact with it. it's giving main character energy, it's giving "the widget is now live" πŸ‘‘

  • the parameter alphalist is a pointer to a non-NULL alphalist 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. that's the vibe 🌸

if the character entered into this widget is RETURN then this function will return a char * of the information which was typed in the field. iconic.

if the TAB character is hit then the widget will try to complete the word in the entry field. autocomplete queen fr fr ✨

if the widget is exited with the RETURN character then the widget data exitType will be set to vNORMAL.

if the widget was exited with the ESCAPE key then the widget data exitType will be set to vESCAPE_HIT and the widget returns NULL. sad but valid 😭


destroyCDKAlphalist

removes the widget from the screen and frees memory the object used. full cleanup, no leftovers, we love a tidy exit 🧚


drawCDKAlphalist

draws the alphalist widget on the screen.

if the box parameter is true, the widget is drawn with a box. cute little frame, obsessed πŸŽ€


eraseCDKAlphalist

removes the widget from the screen. this does NOT destroy the widget. important distinction bestie, don't get it twisted πŸ’…


getCDKAlphalistBox

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


getCDKAlphalistContents

returns the contents of the alphalist.


getCDKAlphalistCurrentItem

returns the current position in the scroll-widget.


getCDKAlphalistFillerChar

returns the character being used as the filler character in the entry field portion of the widget.


getCDKAlphalistHighlight

returns the attribute of the highlight bar of the scrolling list portion of the widget.


injectCDKAlphalist

injects a single character into the widget (actually the entry widget). sneaky little character drop πŸ™ˆ

  • the parameter alphalist is a pointer to a non-NULL alphalist 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 the information in the entry field. the widget data exitType is set to vNORMAL.
  • ESCAPE β€” the function returns a NULL pointer. the widget data exitType is set to vESCAPE_HIT.
  • Otherwise β€” unless modified by preprocessing, postprocessing or key bindings, the function returns a NULL pointer. the widget data exitType is set to vEARLY_EXIT.

moveCDKAlphalist

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). not the cute kind of weird either πŸ’€

the final parameter refresh is a boolean value which states whether the widget will get refreshed after the move.


newCDKAlphalist

creates a pointer to an alphalist widget. parameters:

  • screen is the screen you wish this widget to be placed in.
  • xpos controls the placement of the object along the horizontal axis. this parameter can take 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.
  • 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 scrolling list. the title can be more than one line; just provide a carriage return character at the line break.
  • label is the string which will be displayed in the label of the entry field.
  • list is the list of words which will be displayed in the scrolling list. this list does not have to be sorted, this widget automatically sorts the list (note that it modifies the caller's copy of the list to do this). yeah she's a little bossy, she will rearrange your stuff 😭
  • listSize tells the widget how large the word list is.
  • fillerCharacter is the character which is to be displayed in an empty space in the entry field.
  • highlight is the attribute of the highlight bar in the scrolling list.
  • 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.


positionCDKAlphalist

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


setCDKAlphalist

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

the parameter names correspond to the same parameter names listed in the newCDKAlphalist function.


setCDKAlphalistBackgroundAttrib

sets the background attribute of the widget.

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


setCDKAlphalistBackgroundColor

sets the background color of the widget.

the parameter color is in the format of the Cdk format strings. see cdk_display(3).


setCDKAlphalistBox

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


setCDKAlphalistBoxAttribute

sets the attribute of the box.


setCDKAlphalistContents

sets the contents of the alphalist widget (note that it sorts the caller's copy of the list).


setCDKAlphalistCurrentItem

set the current position in the scroll-widget.


setCDKAlphalistFillerChar

sets the character to use when drawing the entry field portion of the widget.


setCDKAlphalistHighlight

sets the attribute of the highlight bar of the scrolling list portion of the widget.


setCDKAlphalistHorizontalChar

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


setCDKAlphalistLLChar

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


setCDKAlphalistLRChar

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


setCDKAlphalistPostProcess

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


setCDKAlphalistPreProcess

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


setCDKAlphalistULChar

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


setCDKAlphalistURChar

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


setCDKAlphalistVerticalChar

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

πŸŽ€ KEY BINDINGS πŸŽ€

Okay bestie, so once the widget is actually activated, there's a whole lil' set of default key bindings ready to help you get your info in there and mess with it fast. And here's the tea: since this widget is built out of both the scrolling list widget and the entry field widget, the key bindings are literally the same for the respective fields. The extra ones? Listed right below. πŸ’…

  • Up Arrow β€” scrolls the scrolling list up one line. baby steps upward ✨
  • Down Arrow β€” scrolls the scrolling list down one line. lil scoot downward πŸ¦‹
  • Page Up β€” scrolls the scrolling list up one page. big leap energy πŸ”₯
  • CTRL-B β€” scrolls the scrolling list up one page. Page Down/Scrolls the scrolling list down one page.
  • CTRL-F β€” scrolls the scrolling list down one page. πŸ’€
  • Tab β€” tries to complete the word in the entry field. And if the word segment is not unique, the widget will beep at you and present a list of close matches. it's giving "here are your options, choose wisely" πŸ™ˆ
  • Return β€” returns the word in the entry field. It also sets the widget data exitType to vNORMAL. clean exit, no drama πŸ‘‘
  • Escape β€” exits the widget and returns a NULL pointer. It also sets the widget data exitType to vESCAPE_HIT. ghosting the widget fr fr 🫢
not me noticing CTRL-B's description is doing the absolute most up there β€” that's literally what the page says tho, so we keep it exactly as-is. no cap.

πŸ“ NOTES πŸ“

This widget is created from the scrolling list widget and the entry field widget. Which means β€” plot twist β€” this is a genuinely good example on how to build your own widgets using the base widgets provided in this distribution. study her, she's teaching you the whole syllabus 🧚


🌈 SEE ALSO 🌈


and that's the whole page bestie, we ate that πŸ“ this iconic lil' entry comes from the source/version stamped 2025-01-14, filed under cdk_alphalist(3) β€” go forth and scroll, complete, and exit with main character energy πŸ’–βœ¨πŸŒΈ