cdk_util(3)
β¨ NAME β¨
okay so this whole page is about cdk_util(3) β aka the Cdk utility functions. π it's giving "tiny besties that help you set up, build, and customize widgets," and honestly? we're obsessed.
π SYNOPSIS π
bestie, here's the compile line and every single function signature, no cap. copy these exactly or the compiler will absolutely side-eye you. π
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
int CDKchdir ( const char *directory);
int CDKgetDirectoryContents (
const char *directory,
char ***list);
int CDKopenFile (
const char *filename,
char *mode);
int CDKreadFile (
const char *filename,
char ***info);
void alignxy ( WINDOW *window,
int *xpos,
int *ypos,
int boxWidth,
int boxHeight);
chtype *char2Chtype (
const char *string,
int *length,
int *align);
EDisplayType char2DisplayType (
const char *string);
int checkForLink (
const char *line,
char *filename);
char *chtype2String (
const chtype *string);
void deleteCursesWindow (
WINDOW *window);
void enableCursesMarkup (
booleanflag);
void eraseCursesWindow (
WINDOW *window);
int getListIndex (
CDKSCREEN *screen,
const char *title,
CDK_CONST char **list,
int listSize,
boolean numbers);
char *getString (
CDKSCREEN *screen,
const char *title,
const char *label,
const char *init);
int justifyString (
int fieldWidth,
int mesglen,
int justify);
int mode2Filetype (
mode_t fileMode);
void moveCursesWindow (
WINDOW *window,
int xdiff,
int ydiff);
int popupDialog (
CDKSCREEN *screen,
CDK_CONST char **mesg,
int mesgCount,
CDK_CONST char **buttons,
int buttonCount);
void popupLabel (
CDKSCREEN *win,
CDK_CONST char **mesg,
int count);
void popupLabelAttrib (
CDKSCREEN *win,
CDK_CONST char **mesg,
int count,
chtype attribute);
char *selectFile (
CDKSCREEN *screen,
const char *title);
int setWidgetDimension (
int parentDim,
int proposedDim,
int adjustment);
void stripWhiteSpace (
EStripType stripType,
char *string);
int viewFile ( CDKSCREEN *screen,
const char *title,
const char *filename,
CDK_CONST char **buttons,
int buttonCount);
int viewInfo ( CDKSCREEN *screen,
const char *title,
CDK_CONST char **info,
int size,
CDK_CONST char **buttons,
int buttonCount,
boolean interpret);
π¦ DESCRIPTION π¦
so these are the utility functions, bestie β the little helpers you can use to initialize, build, or customize widgets. it's giving "glow-up toolkit" fr fr. that's literally what they're for. periodt. π
β¨ AVAILABLE FUNCTIONS β¨
Okay bestie, here's the full roster of helper functions β no skips, no cap. π
CDKchdir
Change working directory to the given path, possibly expanding tilde (~) and wildcards (*). It returns zero on success. periodt β¨
CDKgetDirectoryContents
Opens and reads the contents of the given directory, filling the array list with the sorted contents of the directory. If the directory cannot be opened then it returns a value of -1. not the vibe π
CDKopenFile
Open the file, possibly expanding tilde (~) and wildcards (*). It returns a FILE pointer. iconic π¦
CDKreadFile
Read the file filename, load the contents into a dynamically allocated array, storing its address via info. It returns the number of lines read if the file could be opened, -1 otherwise. slay π
alignxy
Aligns a box on the given window with the height and width given. See cdk_position (3) for the interpretation of the xpos, ypos, boxWidth and boxHeight, parameters. iykyk π
char2Chtype
Translate a character string with embedded HTML-like format markers (e.g., β</X/Y>Blah Blahβ) to a null-terminated array of chtype's.
- The length of the array is stored via the
lengthparameter. - The
alignparameter contains justification information (LEFT,CENTER,RIGHT).
The caller is responsible for freeing the result.
See cdk_display(3) for details on formatting. the way that formatting works π
char2DisplayType
Lookup the given name in string and return the equivalent display type. See also cdk_display(3). obsessed πΏ
checkForLink
Check if the given line is of the form
<F=filename>
If so, extract the filename from the line, storing it in the filename buffer (which must hold at least CDK_PATHMAX characters). Return nonzero if a filename is extracted. gotcha β¨
chtype2String
Extract the characters and formatting information from a null-terminated array of chtype's string. A dynamically allocated string is returned.
See cdk_display(3) for details on Cdk's formatting.
In addition, this function supports a feature needed to represent multi-line title strings returned by getCdkTitle (see cdk_objs(3)). Each newline separating lines in the title is represented by β<#10>β to allow Cdk to display the string in a text field. multi-line tea π΅
deleteCursesWindow
Safely delete a given window, i.e., first check if the window parameter is nonnull. safety first π‘οΈ
enableCursesMarkup
Normally Cdk checks for HTML-like markup in character strings which it translates to curses strings with char2Chtype. Use this function to disable the feature temporarily. temporarily unhinged π
eraseCursesWindow
Safely erase a given window, i.e., first check if the window parameter is nonnull. clean slate π§Ό
getListIndex
Display a scrollable list of strings in a dialog, allow the user to select one. Return the index in the list of the value selected.
- The
listparameter contains the strings to display; there arelistSizestrings in the list. - If
numbersis true, the displayed list items will be numbered.
pick your fighter π
getString
Pops up an entry widget with
- a title supplied by the value of the
titleparameter, - a label supplied by the
labelparameter, and - an initial value supplied by the
initialValueparameter.
It returns a pointer to the value typed in or NULL if the widget was exited early. early exit? relatable π
justifyString
Given a string length mesglen, the available field width fieldWidth and a justification type justify, return the number of characters by which to shift the string. math but make it cute β¨
mode2Filetype
Given a file protection mode fileMode, return ignoring the file-type bits, i.e., ignoring the corresponding permissions data. permissions tea π
moveCursesWindow
Move a given window by the amounts in xdiff and ydiff. shift it π
popupDialog
Creates a quick pop-up dialog box. Pass in
- the message in the
mesgparameter, - the size of the message in the
mesgCountparameter, - the button labels in the
buttonsparameter and - the number of buttons in the
buttonCountparameter.
The dialog box will be centered on the screen. centered and serving π
popupLabel
Creates a quick pop-up label widget.
The message and the size of the message are passed in via the mesg and count parameters respectively.
The label widget waits until the user hits a character and is centered on the screen. wait for it π¦
popupLabelAttrib
Display a simple dialog with a list of count message strings mesg. Use the given attribute for the background of the dialog. aesthetic π
selectFile
Display a file-selection dialog. Return the selected filename, or null if none is selected. The caller should free the return-value. free it, bestie π
setWidgetDimension
This is a helper function used to set the height/width of a widget:
- If the proposed dimension
proposedDimisFULLor zero, the return value will beparentDim. - If the proposed dimension
proposedDimis positive,- and it is larger than
parentDim, returnproposedDim, - otherwise return
proposedDimplusadjustment.
- and it is larger than
- If the proposed dimension
proposedDimis negative, the return value will beparentDimplusproposedDim. - Otherwise, the return value will be
proposedDim.
dimension drama π
stripWhiteSpace
Strip whitespace from the front and/or back of the given string.
The stripType parameter controls the type of stripping done: vFRONT, vBACK or vBOTH. clean it up β¨
viewFile
Read the file specified by filename and display it in a CDKVIEWER window. The title, buttons and buttonCount are applied to the CDKVIEWER window.
- The viewer shows the contents of the file supplied by the
filenamevalue. - The buttons on the file viewer are supplied by the
buttonsparameter.
It returns the index of the button selected, or -1 if the file does not exist or if the widget was exited early. file viewer realness π
Strip_Typeβ Result: -vFRONTβ This tells the function to remove all of the white space from the front of the given string. -vBACKβ This tells the function to remove all of the white space from the back of the given string. -vBOTHβ This tells the function to remove all of the white space from both the front and the back of the given string.
strip type decoded π
viewInfo
Display the list of strings in info in a CDKVIEWER window. The number of strings is given by size. The title, buttons and buttonCount are applied to the CDKVIEWER window. info dump, but make it fashion π
π SEE ALSO π
That's the whole page, bestie. This was cdk_util(3), dated 2025-01-14. Go forth and slay. πβ¨
π¦ 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