cdk_alphalist(3)
π¦ 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
alphalistis a pointer to a non-NULL alphalist 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. 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
alphalistis a pointer to a non-NULL alphalist 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:
- RETURN or TAB β the function returns the information in the entry field. the widget data
exitTypeis set tovNORMAL. - ESCAPE β the function returns a NULL pointer. the widget data
exitTypeis set tovESCAPE_HIT. - Otherwise β unless modified by preprocessing, postprocessing or key bindings, the function returns a NULL pointer. the widget data
exitTypeis set tovEARLY_EXIT.
moveCDKAlphalist
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). 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:
screenis the screen you wish this widget to be placed in.xposcontrols 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.yposcontrols 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.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 scrolling list. the title can be more than one line; just provide a carriage return character at the line break.labelis the string which will be displayed in the label of the entry field.listis 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 πlistSizetells the widget how large the word list is.fillerCharacteris the character which is to be displayed in an empty space in the entry field.highlightis the attribute of the highlight bar in the scrolling list.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.
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
functionis the callback function. - the parameter
datapoints 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
functionis the callback function. - the parameter
datapoints 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 dataexitTypetovNORMAL. clean exit, no drama πEscapeβ exits the widget and returns aNULLpointer. It also sets the widget dataexitTypetovESCAPE_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 πβ¨πΈ
π¦ 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