cdk_uslider(3)

πŸ“¦
version 5.0.20250116 Β· 3 versions
, in debian trixie, ubuntu questing

okay bestie, buckle UP πŸ’– what we have here is cdk_uslider from section 3 (Library calls) of the Cdk manual, and she is so main character. ngl this page is a whole trilogy, so this is part 1 β€” more coming, don't go anywhere 🫢


✨ NAME ✨

cdk_uslider β€” the Cdk slider widget, except make it unsigned πŸ’… no negative vibes allowed in this house


πŸ“œ SYNOPSIS πŸ“œ

cc [ flag ... ] file ...  -lcdk [ library ... ]

#include <cdk.h>

int activateCDKUSlider (
               CDKUSLIDER *slider,
               chtype *actions);

void destroyCDKUSlider (
               CDKUSLIDER *slider);

void drawCDKUSlider (
               CDKUSLIDER *slider,
               boolean box);

void eraseCDKUSlider (
               CDKUSLIDER *slider);

boolean getCDKUSliderBox (
               CDKUSLIDER *slider);

unsigned getCDKUSliderHighValue (
               CDKUSLIDER *slider);

unsigned getCDKUSliderLowValue (
               CDKUSLIDER *slider);

unsigned getCDKUSliderValue (
               CDKUSLIDER *slider);

unsigned injectCDKUSlider (
               CDKUSLIDER *slider,
               chtype input);

void moveCDKUSlider (
               CDKUSLIDER *slider,
               int xpos,
               int ypos,
               boolean relative,
               boolean refresh);

CDKUSLIDER *newCDKUSlider (
               CDKSCREEN *cdkscreen,
               int xpos,
               int ypos,
               const char *title,
               const char *label,
               chtype fillerCharacter,
               int fieldWidth,
               int currentValue,
               unsigned lowValue,
               unsigned highValue,
               unsigned increment,
               unsigned fastIncrement,
               boolean box,
               boolean shadow);

void positionCDKUSlider (
               CDKUSLIDER *slider);

void setCDKUSlider (
               CDKUSLIDER *slider,
               unsigned lowValue,
               unsigned highValue,
               unsigned currentValue,
               boolean box);

void setCDKUSliderBackgroundAttrib (
               CDKUSLIDER *slider,
               chtype attribute);

void setCDKUSliderBackgroundColor (
               CDKUSLIDER *slider,
               const char * color);

void setCDKUSliderBox (
               CDKUSLIDER *slider,
               boolean boxWidget);

void setCDKUSliderBoxAttribute (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderHorizontalChar (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderLLChar (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderLRChar (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderLowHigh (
               CDKUSLIDER *slider,
               unsigned lowValue,
               unsigned highValue);

void setCDKUSliderPostProcess (
               CDKUSLIDER *slider,
               PROCESSFN callback,
               void * data);

void setCDKUSliderPreProcess (
               CDKUSLIDER *slider,
               PROCESSFN callback,
               void * data);

void setCDKUSliderULChar (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderURChar (
               CDKUSLIDER *slider,
               chtype character);

void setCDKUSliderValue (
               CDKUSLIDER *slider,
               unsigned value);

void setCDKUSliderVerticalChar (
               CDKUSLIDER *slider,
               chtype character);
not me dropping a whole wall of prototypes on you first thing 🫠 but fr fr, every single one of these is getting its own lil moment later, promise πŸ’–

🌸 DESCRIPTION 🌸

okay so here's the tea β˜• the Cdk slider widget makes a visual slider box β€” and it comes with a label plus a slider field, so it's giving very much "pretty AND functional", which we love πŸ˜ŒπŸ’…

and that's literally what all the functions on this page are here to do: create the Cdk slider box widget, or manipulate the Cdk slider box widget. those are the two jobs. she builds, she tweaks. periodt πŸ‘‘

think of it like the group chat of widgets β€” one girl makes the plans, and the rest of them keep the plans from falling apart πŸ¦‹βœ¨

and yes, bestie, there's way more where this came from 🌈


πŸ’– AVAILABLE FUNCTIONS πŸ’–

bestie. this is the main character list right here. every single one of these is a function you can call. let's go 🫢

activateCDKUSlider

okay so this one activates the slider widget and lets the user actually interact with it. hands on the wheel, main character moment ✨

  • the parameter slider is a pointer to a non-NULL slider widget.
  • if the actions parameter 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.

if the character entered into this widget is RETURN or TAB then this function will return a value from the low value to the high value. it will also set the widget data exitType to vNORMAL. slay πŸ’…

if the character entered into this widget was ESCAPE then the widget returns the unknownUnsigned value (see the cdk_objs.h header file). the widget data exitType is set to vESCAPE_HIT. we love a clean exit 😌

destroyCDKUSlider

removes the widget from the screen and frees the memory the object used. it's giving closure. πŸ¦‹

drawCDKUSlider

draws the slider widget on the screen. if the box option is true, the widget is drawn with a box. ✨ iconic framing honestly

eraseCDKUSlider

removes the widget from the screen. this does NOT destroy the widget. just hiding it, not ghosting it forever πŸ’€

getCDKUSliderBox

returns true if the widget will be drawn with a box around it. vibe check on the box situation πŸ“¦

getCDKUSliderHighValue

returns the high value of the slider widget. ⬆️

getCDKUSliderLowValue

returns the low value of the slider widget. ⬇️

getCDKUSliderValue

returns the current value of the widget. the moment. the truth. πŸŽ€

injectCDKUSlider

injects a single character into the widget. one char, big impact πŸ”₯

  • the parameter slider is a pointer to a non-NULL slider widget.
  • the parameter character is 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 a value ranging from the slider's low value to the slider's high value. the widget data exitType is set to vNORMAL.

ESCAPE : the function returns the unknownUnsigned value (see the cdk_objs.h header file). the widget data exitType is set to vESCAPE_HIT.

otherwise β€” unless modified by preprocessing, postprocessing or key bindings β€” the function returns the unknownUnsigned value (see the cdk_objs.h header file). the widget data exitType is set to vEARLY_EXIT.

moveCDKUSlider

moves the given widget to the given position. relocation era 🧳

  • 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). fr fr, don't. 😭
  • the final parameter refresh is a boolean value which states whether the widget will get refreshed after the move.

newCDKUSlider

this function creates a slider widget and returns a pointer to it. baby widget birth announcement πŸ‘Άβœ¨

parameters:

  • screen β€” 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 may be an integer or one of the pre-defined values TOP, BOTTOM, and CENTER.
  • title β€” is the string to display at the top of the widget. the title can be more than one line; just provide a carriage return character at the line break.
  • label β€” is the string to display in the label of the slider field.
  • fillerCharacter β€” is the character to be used to draw the slider bar in the field.
  • fieldWidth β€” controls the width of the widget. if you provide a value of zero the widget will be created with the full width of the screen. if you provide a negative value, the widget will be created the full width minus the value provided.
  • currentValue β€” is the value of the slider field when the widget is activated.
  • lowValue and highValue β€” are the low and high values of the widget respectively.
  • increment β€” is the regular increment value.
  • fastIncrement β€” is the accelerated increment value.
  • 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. πŸ’€ sad but true

positionCDKUSlider

allows the user to move the widget around the screen via the cursor/keypad keys. see cdk_position (3) for key bindings. drag it, drop it, it's yours πŸŽ€

setCDKUSlider

lets the programmer modify certain elements of an existing slider widget. the parameter names correspond to the same parameter names listed in the newCDKUSlider function. glow-up for an existing widget πŸ’…

setCDKUSliderBackgroundAttrib

sets the background attribute of the widget.

the parameter attribute is a curses attribute, e.g., A_BOLD. ✨

setCDKUSliderBackgroundColor

sets the background color of the widget.

the parameter color is in the format of the Cdk format strings.

see cdk_display (3). 🌈

setCDKUSliderBox

sets whether the widget will be drawn with a box around it. πŸ“¦

setCDKUSliderBoxAttribute

this function sets the attribute of the box.

setCDKUSliderHorizontalChar

sets the horizontal drawing character for the box to the given character. βž–

setCDKUSliderLLChar

sets the lower left hand corner of the widget's box to the given character. ↙️

setCDKUSliderLRChar

sets the lower right hand corner of the widget's box to the given character. β†˜οΈ

setCDKUSliderLowHigh

sets the low and high values of the widget.

setCDKUSliderPostProcess

allows the user to have the widget call a function after the key has been applied to the widget.

  • the parameter function is the callback function.
  • the parameter data points to data passed to the callback function.

to learn more about post-processing see cdk_process(3). 🫢

setCDKUSliderPreProcess

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 function is the callback function.
  • the parameter data points to data passed to the callback function.

to learn more about pre-processing see cdk_process(3). 🫢

setCDKUSliderULChar

sets the upper left hand corner of the widget's box to the given character. ↖️

setCDKUSliderURChar

sets the upper right hand corner of the widget's box to the given character. ↗️

setCDKUSliderValue

sets the current value of the widget. ⭐

setCDKUSliderVerticalChar

sets the vertical drawing character for the box to the given character. βž•


⌨️ KEY BINDINGS ⌨️

ok so bestie, when the widget is activated (yes, activated, it's giving main character energy πŸ’…), there are a bunch of default key bindings that help the user type in or mess with the info super fast. no cap. here's the whole rundown of the keys and what they do for this widget ✨

  • Down Arrow β€” decrements the field by the normal decrement value. down bad, but on purpose 🫢
  • Up Arrow β€” increments the field by the normal increment value.
  • u β€” increments the field by the normal increment value.
  • Prev Page β€” decrements the field by the accelerated decrement value. zoom zoom πŸ¦‹
  • U β€” decrements the field by the accelerated decrement value.
  • Ctrl-B β€” decrements the field by the accelerated decrement value.
  • Next Page β€” increments the field by the accelerated increment value.
  • D β€” increments the field by the accelerated increment value.
  • Ctrl-F β€” increments the field by the accelerated increment value.
  • Home β€” sets the value to the low value. rock bottom, but make it iconic 😭
  • g β€” sets the value to the low value.
  • End β€” sets the value to the high value. πŸ‘‘
  • G β€” sets the value to the high value.
  • $ β€” sets the value to the high value.
  • Return β€” exits the widget and returns the current value. this also sets the widget data exitType to vNORMAL. slay, clean exit πŸ’–
  • Tab β€” exits the widget and returns the current value. this also sets the widget data exitType to vNORMAL.
  • Escape β€” exits the widget and returns the unknownUnsigned value (peep the cdk_objs.h header file for that one). this also sets the widget data exitType to vESCAPE_HIT. dramatic exit, no explanation 🌈
  • Ctrl-R β€” refreshes the screen. glow up ✨

ok but wait β€” if the cursor is not pointing to the field's value, a whole different set of key bindings kicks in. not me having two personalities fr fr πŸ™ˆ you can use the left/right arrows to move the cursor onto the field's value, then modify it by typing characters to replace the digits and the sign. periodt.

  • Left Arrow β€” decrements the scale by the normal value.
  • Right Arrow β€” increments the scale by the normal value.

  • d β€” decrements the scale by the normal value.
  • D β€” increments the scale by the accelerated value.
  • - β€” decrements the scale by the normal value.
  • + β€” increments the scale by the normal value.
  • 0 β€” sets the scale to the low value.

πŸ‘€ SEE ALSO πŸ‘€

go read these next bestie, they're literally the friend group:


and that's a wrap on cdk_uslider(3) πŸ’œ this page is living in the Curses Development Kit era, dated 2025-01-14, and it ate, no crumbs. mwah πŸŽ€ go forth and slide those unsigned values, you absolute legend πŸ¦‹βœ¨

πŸ“¦ where this page comes from