cdk_button(3)

πŸ“¦
version 5.0.20260119 Β· 3 versions
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 button is a pointer to a non-NULL button widget.
  • if the actions parameter 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 button is a pointer to a non-NULL button widget.
  • the parameter character is 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 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). πŸ’€ you have been warned, bestie.
  • the final parameter refresh is a boolean value which states whether the widget will get refreshed after the move.

πŸŽ€ newCDKButton

creates a pointer to a buttonbox widget. Parameters:

  • the screen parameter is the screen you wish this widget to be placed in.
  • xpos controls the placement of the object along the horizontal axis. It may be an integer or one of the pre-defined values LEFT, RIGHT, and CENTER.
  • ypos controls the placement of the object along the vertical axis. It be an integer or one of the pre-defined values TOP, BOTTOM, and CENTER.
  • message is the message to display in the button window, formatted as described in cdk_display.
  • callback is an optional pointer to a callback function that will be executed when the user activates the button by pressing space or enter.
  • box is true if the widget should be drawn with a box around it.
  • shadow turns 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. πŸ’–βœ¨πŸŽ€