cdk_button(3)
π cdk_button β create and manage a Cdk button widget π
okay so bestie, this is cdk_button, and it lives in the Library calls manual, section 3. Yes we're doing manpage energy today and yes it's gonna be cute. Sit down, grab a snack π, because this widget is genuinely the most "press the button, get the callback" little guy in the whole Cdk lineup.
β¨ SYNOPSIS β¨
compile it like this, no cap:
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
typedef void (*tButtonCallback)(struct SButton *button);
int activateCDKButton (
CDKBUTTON *button,
chtype * actions);
void destroyCDKButton (
CDKBUTTON *button);
void drawCDKButton (
CDKBUTTON *b,
boolean box);
void eraseCDKButton (
CDKBUTTON *button);
boolean getCDKButtonBox (
CDKBUTTON *b);
chtype *getCDKButtonMessage (
CDKBUTTON *b);
int injectCDKButtonbox (
CDKBUTTON *buttonbox,
chtype input);
CDKBUTTON *newCDKButton(
CDKSCREEN *cdkscreen,
int xpos,
int ypos,
const char *message,
tButtonCallback callback,
boolean box,
boolean shadow);
void setCDKButton(
CDKBUTTON *b,
const char *message,
boolean box);
void setCDKButtonBackgroundAttrib (
CDKBUTTON *b,
chtype attribute);
void setCDKButtonBackgroundColor (
CDKBUTTON *b,
const char * color);
void setCDKButtonBox (
CDKBUTTON *button,
boolean box);
void setCDKButtonBoxAttribute (
CDKBUTTON *b,
chtype c);
void setCDKButtonHorizontalChar (
CDKBUTTON *b,
chtype c);
void setCDKButtonLLChar (
CDKBUTTON *b,
chtype c);
void setCDKButtonLRChar (
CDKBUTTON *b,
chtype c);
void setCDKButtonMessage (
CDKBUTTON *b,
const char *message);
void setCDKButtonULChar (
CDKBUTTON *b,
chtype c);
void setCDKButtonURChar (
CDKBUTTON *b,
chtype c);
void setCDKButtonVerticalChar (
CDKBUTTON *b,
chtype c);
void moveCDKButton(
CDKBUTTON *b,
int xpos,
int ypos,
boolean relative,
boolean refresh);
void positionCDKButton (
CDKBUTTON *b);
void waitCDKButton (
CDKBUTTON *button,
char key);
πΈ DESCRIPTION πΈ
okay so here's the vibe: the Cdk button widget shows a message string and runs a callback when the user hits enter or space. That's it. That's the whole personality π
Because of that, it's only useful on a screen that's being managed by some external screen traversal engine, like traverseCDKScreen(). Lowkey important detail, don't skip it.
The button gets highlighted when the widget has the focus β main character energy when it's your turn, invisible side character when it's not. β¨
The functions below either create or manipulate the Cdk button widget. Let's go.
π AVAILABLE FUNCTIONS π
π activateCDKButton
activates the button widget and lets the user actually interact with it.
- the parameter
buttonis a pointer to a non-NULL button widget. - if the
actionsparameter is passed with a non-NULL value, the characters in the array get 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 returns a value from 0 to the number of buttons -1, representing the button selected. It also sets the widget data exitType to vNORMAL.
If the character entered into this widget was ESCAPE, then the widget returns a value of -1 and the widget data exitType gets set to vESCAPE_HIT. π escape hatch activated.
π destroyCDKButton
removes the widget from the screen and frees up any memory the object used. full clean exit, no leftovers, we love to see it. π§
π drawCDKButton
draws the button widget on the screen.
If the box parameter is true, the widget is drawn with a box. π¦
π eraseCDKButton
removes the widget from the screen. this does NOT destroy the widget.
bestie please internalize that. erase β destroy. it's giving "walked out of the room" not "moved out of the country".
π getCDKButtonBox
returns true if the widget will be drawn with a box around it.
π getCDKButtonMessage
returns the contents of the button widget. peek inside, it's just vibes and a string. π«Ά
π injectCDKButton
injects a single character into the widget.
- the parameter
buttonis a pointer to a non-NULL button widget. - the parameter
characteris the character to inject into the widget.
The return value and the side-effect (setting the widget data exitType) depend upon the injected character:
RETURN or TAB
this function returns 0, representing the button 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.
π moveCDKButton
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 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 valuesTOP,BOTTOM,LEFT,RIGHT, orCENTERwhenrelative = TRUE. (weird things may happen). π you have been warned, bestie.
- the final parameter
refreshis a boolean value which states whether the widget will get refreshed after the move.
π newCDKButton
creates a pointer to a buttonbox widget. Parameters:
- the
screenparameter is the screen you wish this widget to be placed in. xposcontrols the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined valuesLEFT,RIGHT, andCENTER.yposcontrols the placement of the object along the vertical axis. It be an integer or one of the pre-defined valuesTOP,BOTTOM, andCENTER.messageis the message to display in the button window, formatted as described incdk_display.callbackis an optional pointer to a callback function that will be executed when the user activates the button by pressing space or enter.boxistrueif the widget should be drawn with a box around it.shadowturns the shadow on or off around this widget.
If the widget could not be created then a NULL pointer is returned. π it happens to the best of us.
π positionCDKButton
allows the user to move the widget around the screen via the cursor/keypad keys. See cdk_position (3) for key bindings. πΉοΈ
π setCDKButton
lets the programmer modify certain elements of an existing buttonbox widget.
The parameter names correspond to the same parameter names listed in the newCDKButton function. matching set, cute.
π setCDKButtonBackgroundAttrib
sets the background attribute of the widget.
The parameter attribute is a curses attribute, e.g., A_BOLD. bold era.
π setCDKButtonBackgroundColor
sets the background color of the widget.
The parameter color is in the format of the Cdk format strings. (See cdk_display). π
π setCDKButtonBox
sets true if the widget will be drawn with a box around it.
π setCDKButtonBoxAttribute
sets the attribute of the box.
π setCDKButtonHorizontalChar
sets the horizontal drawing character for the box to the given character.
π setCDKButtonLLChar
sets the lower left hand corner of the widget's box to the given character.
π setCDKButtonLRChar
sets the lower right hand corner of the widget's box to the given character.
π setCDKButtonMessage
This sets the contents of the label widget.
π setCDKButtonULChar
sets the upper left hand corner of the widget's box to the given character.
π setCDKButtonURChar
sets the upper right hand corner of the widget's box to the given character.
π setCDKButtonVerticalChar
sets the vertical drawing character for the box to the given character.
π BUGS π
Changing the Box attribute after the widget has been created probably does not work right. None of the positioning/movement code has been tested.
not me reading "has not been tested" in an actual manpage π fr fr, tread carefully bestie.
π AUTHORS π
Grant Edwards, Aspen Research Corporation. absolute icons, we stan. π
π¦ SEE ALSO π¦
and that's the whole page, bestie β cdk_button in the Library calls manual, section 3, dated 2024-03-28. go press a button, you've earned it. πβ¨π
π¦ where this page comes from
- debian trixie: libcdk5-dev 5.0.20250116-1 Β· BSD-4-Clause
- fedora 43: cdk 5.0.20240619-4.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- fedora 43: cdk 5.0.20240619-4.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- 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