cdk_util(3)

πŸ“¦
version 5.0.20260119 Β· 2 versions
  • 5.0.20260119 Β· debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 5.0.20240619 Β· fedora 43
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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 length parameter.
  • The align parameter 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 🌿

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 list parameter contains the strings to display; there are listSize strings in the list.
  • If numbers is 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 title parameter,
  • a label supplied by the label parameter, and
  • an initial value supplied by the initialValue parameter.

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 mesg parameter,
  • the size of the message in the mesgCount parameter,
  • the button labels in the buttons parameter and
  • the number of buttons in the buttonCount parameter.

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 proposedDim is FULL or zero, the return value will be parentDim.
  • If the proposed dimension proposedDim is positive,
    • and it is larger than parentDim, return proposedDim,
    • otherwise return proposedDim plus adjustment.
  • If the proposed dimension proposedDim is negative, the return value will be parentDim plus proposedDim.
  • 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 filename value.
  • The buttons on the file viewer are supplied by the buttons parameter.

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. πŸ’–βœ¨