cdk_matrix(3)

๐Ÿ“ฆ
version 5.0.20260119 ยท 4 versions
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

okay so you just opened cdk_matrix(3) โ€” that's the Cdk matrix widget, filed under Library calls. It's long, like genuinely long, so it got chopped into parts and this is part 1. Grab a snack ๐Ÿ“, hydrate, we're doing this.


๐Ÿ’– NAME ๐Ÿ’–

cdk_matrix โ€” Cdk matrix widget. that's the whole name, short and iconic, no notes ๐Ÿ’…


โœจ SYNOPSIS โœจ

first up, link the library, exactly like this or it simply will not go:

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

and obviously you gotta pull in the header:

#include <cdk.h>

then the entire cast list, in order, no cap. i'm putting them in little friend groups so your eyes don't fall out ๐Ÿ™ˆ

๐Ÿ’… the life-cycle girlies

int activateCDKMatrix (
               CDKMATRIX *matrix,
               chtype * actions);

void cleanCDKMatrix (
               CDKMATRIX *matrix);

void cleanCDKMatrixCell (
               CDKMATRIX *matrix,
               int row,
               int col);

void destroyCDKMatrix (
               CDKMATRIX *matrix);

๐ŸŽ€ draw & erase, the visual besties

void drawCDKMatrix (
               CDKMATRIX *matrix,
               boolean box);

void eraseCDKMatrix (
               CDKMATRIX *matrix);

๐Ÿ” the getters (they hand you stuff back)

boolean getCDKMatrixBox (
               CDKMENTRY *matrix);

char * getCDKMatrixCell (
               CDKMATRIX *matrix,
               int row,
               int col);

int getCDKMatrixCol (
               CDKMENTRY *matrix);

int getCDKMatrixRow (
               CDKMENTRY *matrix);
not me side-eyeing that some of these take CDKMENTRY *matrix instead of CDKMATRIX *matrix ๐Ÿ’€ โ€” i don't write 'em, i just report 'em. copy it character for character, bestie, don't get cute.

๐ŸŽฎ input & moving around

int injectCDKMatrix (
               CDKMATRIX *matrix,
               chtype input);

int jumpToCell (
               CDKMATRIX *matrix,
               int row,
               int col);

void moveCDKMatrix (
               CDKMATRIX *matrix,
               int xpos,
               int ypos,
               boolean relative,
               boolean refresh);

int moveToCDKMatrixCell (
               CDKMATRIX *matrix,
               int row,
               int col);

๐Ÿ‘‘ the main character, newCDKMatrix

she takes nineteen arguments. nineteen. i counted them so you don't have to ๐Ÿ˜ญ

CDKMATRIX *newCDKMatrix (
               CDKSCREEN *cdkscreen,
               int xpos,
               int ypos,
               int screenRows,
               int screenCols,
               int actualRows,
               int actualCols,
               const char *title,
               CDK_CONST char **rowTitles,
               CDK_CONST char **colTitles,
               int *columnWidths,
               int *columnTypes,
               int rowSpace,
               int colSpace,
               chtype filler,
               int dominantAttribute,
               boolean boxMatrix,
               boolean boxCell,
               boolean shadow);

void positionCDKMatrix (
               CDKMATRIX *matrix);

๐ŸŒˆ the setters, an overachiever fr fr

void setCDKMatrix (
               CDKMATRIX *matrix,
               char *info[MAX_MATRIX_ROWS][MAX_MATRIX_COLS],
               int rows,
               int *columnLengths);

void setCDKMatrixBackgroundAttrib (
               CDKMATRIX *matrix,
               chtype attribute);

void setCDKMatrixBackgroundColor (
               CDKMATRIX *matrix,
               const char * color);

void setCDKMatrixBox (
               CDKMENTRY *matrix,
               boolean boxWidget);

void setCDKMatrixBoxAttribute (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixCB (
               CDKMATRIX *matrix,
               MATRIXCB callbackFunction);

int setCDKMatrixCell (
               CDKMATRIX *matrix,
               int row,
               int col,
               const char *value);

void setCDKMatrixCells (
               CDKMATRIX *matrix,
               CDK_CONST char **info,
               int rows,
               int cols,
               int *columnLengths);

void setCDKMatrixHorizontalChar (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixLLChar (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixLRChar (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixPostProcess (
               CDKMATRIX *matrix,
               PROCESSFN callback,
               void * data);

void setCDKMatrixPreProcess (
               CDKMATRIX *matrix,
               PROCESSFN callback,
               void * data);

void setCDKMatrixULChar (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixURChar (
               CDKMATRIX *matrix,
               chtype character);

void setCDKMatrixVerticalChar (
               CDKMATRIX *matrix,
               chtype character);
see? she does the most. every single one of those is real, every parameter, every type, every chtype character โ€” keep the list intact, bestie, we don't skip โœจ

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so the Cdk matrix widget creates a matrix widget. that's the tea. ๐ŸŒธ

and every function listed up there in the synopsis is one of the functions that create or manipulate the Cdk matrix box widget. like, the whole squad: the ones that build her, the ones that clean her, the ones that move her, and the truly unhinged number of setters. all of it, one big happy family ๐Ÿ’–


anyway that's the setup, bestie โ€” the actual function-by-function breakdown is coming right up, keep scrolling ๐Ÿ‘€

โœจ AVAILABLE FUNCTIONS โœจ

okay bestie, this is the whole function lineup and it's literally the moment. every parameter, every return value, every lil caveat โ€” all here. no cap. ๐Ÿ’–


activateCDKMatrix ๐Ÿ’…

  • activates the matrix widget and lets the user interact with it.
  • The parameter matrix is a pointer to a non-NULL matrix 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 then this function will return 1. It will also set the widget data exitType to vNORMAL.
    • If the character entered into this widget was ESCAPE then the widget will return a value of -1 and the widget data exitType will be set to vESCAPE_HIT.
  • The matrix cell contents can be retrieved by using the info array of the matrix widget.

cleanCDKMatrix ๐Ÿงผ

  • clears the information from all cells of the matrix. it's giving reset button โœจ

cleanCDKMatrixCell ๐Ÿงฝ

  • clears the information from the specified cell of the matrix. just one cell, bestie.

destroyCDKMatrix ๐Ÿ’€

  • removes the widget from the screen and frees memory the object used. bye bye, memory.

drawCDKMatrix ๐ŸŽจ

  • draws the matrix widget on the screen. If the box parameter is true, the widget is drawn with a box.

eraseCDKMatrix ๐Ÿซฅ

  • removes the widget from the screen. This does NOT destroy the widget. periodt.

getCDKMatrixBox ๐Ÿ“ฆ

  • returns true if the widget will be drawn with a box around it.

getCDKMatrixCell ๐Ÿ”

  • returns the contents of the cell located by the row and col pair.

getCDKMatrixCol ๐Ÿงญ

  • returns the current column index.

getCDKMatrixRow ๐Ÿงญ

  • returns the current row index.

injectCDKMatrix ๐Ÿ’‰

  • injects a single character into the widget.
  • The parameter matrix is a pointer to a non-NULL matrix 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 1. 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.
  • The matrix cell contents can be retrieved by using the info array of the matrix widget.

jumpToCell ๐Ÿฆ˜

  • provides an interactive method of moving to a cell. It pops up a scale widget and asks which cell the user wants to go to. Then it performs the jump.

moveCDKMatrix ๐Ÿ•บ

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

moveToCDKMatrixCell ๐ŸŽฏ

  • jumps to the given cells dictated by the parameters row and col. It returns a value of TRUE or FALSE depending if the move was successful.

newCDKMatrix ๐Ÿ‘‘

  • creates a matrix widget and returns a pointer to it. 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.
    • screenRows and screenCols โ€” are the number of rows and columns to be displayed on the screen respectively.
    • actualRows and actualCols โ€” are the number of actual rows and columns the matrix has.
    • title โ€” is the string which will be displayed at the top of the widget. The title can be more than one line; just provide a carriage return character at the line break.
    • rowTitles and colTitles โ€” are the titles along the row and columns respectively.
    • columnWidths โ€” is an array of integers stating how wide the individual columns are to be.
    • columnTypes โ€” is an array of integers which correspond to the individual column display types. The values of the array should be assigned a value of type EDisplayType. See cdk_display(3) for legal values of EDisplayType.
    • rowSpace and colSpace โ€” dictate how much white space is to be between rows and columns respectively.
    • filler โ€” is the character to use in empty space within a cell.
    • dominantAttribute โ€” states which (the rows or the columns) will have the dominant character attributes. This is stated when a cell has both a row attribute and a column attribute.
      • If the value of the parameter dominantAttribute is set to ROW then the attribute of the row will be displayed. If it is set to COL then the column's attributes will be displayed instead.
    • boxMatrix โ€” is true if the widget should be drawn with a box around it.
    • boxCell โ€” is true if the individual cells should have boxes drawn around them.
    • shadow โ€” turns the shadow on or off around this widget.
  • If the widget could not be created then a NULL pointer is returned.

positionCDKMatrix ๐Ÿงš

  • allows the user to move the widget around the screen via the cursor/keypad keys. See cdk_position(3) for key bindings.

setCDKMatrix ๐Ÿ“

  • lets the programmer modify certain elements of an existing matrix widget.
  • The parameter info is an array of char * which contains the cell information.
  • The parameter rows has the number of rows
  • the parameter info contains,
  • columnLengths has the lengths of the individual columns in info.
Do not use this function. It is obsolete, provided only for compatibility with older versions of CDK. Use setCDKMatrixCells.

setCDKMatrixBackgroundAttrib ๐ŸŽจ

  • sets the background attribute of the widget. The parameter attribute is a curses attribute, e.g., A_BOLD.

setCDKMatrixBackgroundColor ๐ŸŒˆ

  • sets the background color of the widget. The parameter color is in the format of the Cdk format strings. See cdk_display(3).

setCDKMatrixBox ๐Ÿ“ฆ

  • sets whether the widget will be drawn with a box around it.

setCDKMatrixBoxAttribute ๐Ÿ–Œ๏ธ

  • sets the attribute of the box.

setCDKMatrixCB ๐Ÿซถ

  • allows the programmer to set a different widget input handler. The parameter callbackFunction is of type MATRIXCB. The default function is CDKMatrixCallBack.

setCDKMatrixCell โœ๏ธ

  • sets the contents of the cell located by the row and col pair. The value of the cell will be set to value.

setCDKMatrixCells ๐Ÿงฉ

  • lets the programmer initialize elements of an existing matrix widget.
  • The parameter info is an array of char * which contains the cell information.
    • The parameter rows has the number of rows
    • The parameter cols has the number of columns
    • The parameter info contains, while columnLengths has the lengths of the individual columns in info.

setCDKMatrixHorizontalChar โž–

  • sets the horizontal drawing character for the box to the given character.

setCDKMatrixLLChar โ—ฃ

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

setCDKMatrixLRChar โ—ข

  • sets the lower right hand corner of the widget's box to the given character.

setCDKMatrixPostProcess ๐Ÿซถ

  • 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).

setCDKMatrixPreProcess โœจ

  • 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).

setCDKMatrixULChar โ—ค

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

setCDKMatrixURChar โ—ฅ

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

setCDKMatrixVerticalChar โž•

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

โŒจ๏ธ KEY BINDINGS โŒจ๏ธ

okay bestie so once the widget is activated, there's a whole set of default key bindings just sitting there ready to help you type stuff in and mess with it <em>fast</em>. โœจ Here's the full rundown of every key and what it does in this widget, no skips, no cuts, periodt:

  • Left Arrow โ€” moves you one cell to the left ๐Ÿซถ
  • Right Arrow โ€” moves the cell to the right
  • Tab โ€” moves the cell to the right (same vibe as above, different key, slay)
  • Up Arrow โ€” moves one cell up โฌ†๏ธ
  • Down Arrow โ€” moves one cell down โฌ‡๏ธ
  • Next Page โ€” moves one page forward
  • Ctrl-F โ€” moves one page forward (the keyboard-shortcut twin of Next Page)
  • Prev Page โ€” moves one page backward
  • Ctrl-B โ€” moves one page backward (yep, same thing, just via keyboard)
  • Ctrl-G โ€” calls the function jumpToCell and asks you which cell you wanna jump to ๐Ÿฆ‹
  • Ctrl-P โ€” pastes whatever is chillin' in the paste buffer straight into the current cell
  • Ctrl-K โ€” cuts the contents out of the current cell and saves a copy in the paste buffer โœ‚๏ธ
  • Ctrl-T โ€” copies the contents of the current cell into the paste buffer
  • Ctrl-E โ€” erases the contents of the current cell ๐Ÿงน
  • Delete โ€” deletes the character before the cursor and moves the cursor left. Important note: there is no function to delete the character at the cursor, because there are no functions for moving the cursor within the edited text. iykyk, that's just how it is ๐Ÿ™ˆ
  • Backspace โ€” deletes the character before the cursor, moves cursor left
  • Ctrl-H โ€” deletes the character before the cursor
  • Return โ€” exits the widget and returns 1. This also sets the widget data exitType to vNORMAL ๐Ÿ’…
  • Escape โ€” exits the widget and returns -1. This also sets the widget data exitType to vESCAPE_HIT ๐Ÿ˜ญ
  • Ctrl-L โ€” refreshes the screen ๐Ÿ”„

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go read these too, bestie, they're the whole friend group fr fr:


and that's the whole page, you made it to the end ๐ŸŽ€ this was cdk_matrix(3), dated 2025-01-14 โ€” go forth and matrix, icon ๐Ÿ‘‘โœจ