cdk_fselect(3)
π cdk_fselect β Cdk file selector widget π
okay bestie, pull up a chair because we're talking about cdk_fselect, the Cdk file selector widget, from the Library calls section of the manual. it's giving "let your users roam the filesystem from inside your TUI" and honestly? iconic.
β¨ NAME β¨
cdk_fselect β Cdk file selector widget π
πΈ SYNOPSIS πΈ
first things first, you gotta link the library, no cap:
cc [ flag ... ] file ... -lcdk [ library ... ]
and obvi you pull in the header:
#include <cdk.h>
then it's function o'clock. here's the whole roster, bestie, every single one:
char *activateCDKFselect (
CDKFSELECT *fselect,
chtype *actions);
void deleteFileCB (
EObjectType objectType,
void *object,
void *clientData);
void destroyCDKFselect (
CDKFSELECT *fselect);
void drawCDKFselect (
CDKFSELECT *fselect,
boolean box);
void eraseCDKFselect (
CDKFSELECT *fselect);
boolean getCDKFselectBox (
CDKFSELECT *fselect);
char **getCDKFselectContents (
CDKFSELECT *widget,
int *size);
int getCDKFselectCurrentItem (
CDKFSELECT *widget);
char *getCDKFselectDirAttribute (
CDKFSELECT *fselect);
char **getCDKFselectDirContents (
CDKFSELECT *fselect,
int *count);
char *getCDKFselectDirectory (
CDKFSELECT *fselect);
char *getCDKFselectFileAttribute (
CDKFSELECT *fselect);
chtype getCDKFselectFillerChar (
CDKFSELECT *fselect);
chtype getCDKFselectHighlight (
CDKFSELECT *fselect);
char *getCDKFselectLinkAttribute (
CDKFSELECT *fselect);
char *getCDKFselectSocketAttribute (
CDKFSELECT *fselect);
char *injectCDKFselect (
CDKFSELECT *fselect,
chtype input);
void moveCDKFselect (
CDKFSELECT *fselect,
int xpos,
int ypos,
boolean relative,
boolean refresh);
CDKFSELECT *newCDKFselect (
CDKSCREEN *cdkscreen,
int xpos,
int ypos,
int height,
int width,
const char *title,
const char *label,
chtype fieldAttribute,
chtype fillerCharacter,
chtype highlight,
const char *dirAttribute,
const char *fileAttribute,
const char *linkAttribute,
const char *sockAttribute,
boolean box,
boolean shadow);
void positionCDKFselect (
CDKFSELECT *fselect);
void setCDKFselect (
CDKFSELECT *fselect,
const char *directory,
chtype fieldAttribute,
chtype fillerCharacter,
chtype highlight,
const char *dirAttribute,
const char *fileAttribute,
const char *linkAttribute,
const char *sockAttribute,
boolean box);
void setCDKFselectBackgroundAttrib (
CDKFSELECT *fselect,
chtype attribute);
void setCDKFselectBackgroundColor (
CDKFSELECT *fselect,
const char * color);
void setCDKFselectBox (
CDKFSELECT *fselect,
boolean box);
void setCDKFselectBoxAttribute (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectContents (
CDKFSELECT *widget,
CDK_CONST char **list,
int listSize);
void setCDKFselectCurrentItem (
CDKFSELECT *widget,
int item);
void setCDKFselectDirAttribute (
CDKFSELECT *fselect,
const char *attribute);
int setCDKFselectDirContents (
CDKFSELECT *fselect);
int setCDKFselectDirectory (
CDKFSELECT *fselect,
const char *directory);
void setCDKFselectFileAttribute (
CDKFSELECT *fselect,
const char *attribute);
void setCDKFselectFillerChar (
CDKFSELECT *fselect,
chtype filler);
void setCDKFselectHighlight (
CDKFSELECT *fselect,
chtype highlight);
void setCDKFselectHorizontalChar (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectLLChar (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectLRChar (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectLinkAttribute (
CDKFSELECT *fselect,
const char *attribute);
void setCDKFselectSocketAttribute (
CDKFSELECT *fselect,
const char *attribute);
void setCDKFselectULChar (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectURChar (
CDKFSELECT *fselect,
chtype character);
void setCDKFselectVerticalChar (
CDKFSELECT *fselect,
chtype character);
π¦ DESCRIPTION π¦
okay so the Cdk file selector widget? it literally creates a widget which allows a user to interact with the Unix file system. that's the whole vibe. your user gets to traverse the file system β like, walk around it, browse it, poke at it β and it can even delete files. bestie. DELETE FILES. that is a lot of power in one little widget and we are not being chill about it.
β οΈ heads up, the deleting-files situation has its own lore β go read the NOTES section below (coming in a later part of this page, iykyk) for more information before you let anyone go feral with this thing. π
to be continued, bestie β more sections incoming π
π«Ά AVAILABLE FUNCTIONS π«Ά
okay bestie, here's the whole roster of functions, and I'm not skipping a single one. every param, every return, every lil caveat. lock in π
activateCDKFselectβ wakes the file selector widget up and lets the user actually interact with it.- the parameter
fselectis a pointer to a non-NULL file selector widget. - if the
actionsparameter gets passed a non-NULL value, the characters in that array get injected into the widget.
- the parameter
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 char * representing the info typed into the widget, and the widget data exitType gets set to vNORMAL.
if the character entered was ESCAPE, the function returns a NULL pointer and the widget data exitType is set to vESCAPE_HIT.
deleteFileCBβ prompts the user to confirm, and deletes the current item in the file-list. π (yes it really does that, be careful)destroyCDKFselectβ removes the widget from the screen and frees the memory the object used. bye bestie, gone for real π¦drawCDKFselectβ draws the fselect widget on the screen. if theboxoption is true, the widget is drawn with a box. π¦eraseCDKFselectβ removes the widget from the screen. this does NOT destroy the widget. it's just hiding, not ghosting β¨getCDKFselectBoxβ returns true if the widget will be drawn with a box around it.getCDKFselectContentsβ returns the directory-contents (which are formatted), and sets the number of entries via thesizeparameter.getCDKFselectCurrentItemβ returns the current position in the scroll-widget.getCDKFselectDirAttributeβ returns the attribute that directories are drawn with in the scrolling region of the widget.getCDKFselectDirContentsβ returns the list of files and the corresponding count as a side-effect. if no files are found, this function returns zero, otherwise one.getCDKFselectDirectoryβ returns the current directory of the widget.getCDKFselectFileAttributeβ returns the attribute that plain files are drawn with in the scrolling region of the widget.getCDKFselectFillerCharβ returns the character being used as the filler character in the entry field portion of the widget.getCDKFselectHighlightβ returns the attribute of the highlight bar of the scrolling list portion of the widget. the moment πgetCDKFselectLinkAttributeβ returns the attribute that symbolic links are drawn with in the scrolling region of the widget.getCDKFselectSocketAttributeβ returns the attribute that sockets are drawn with in the scrolling region of the widget.injectCDKFselectβ injects a single character into the widget. the parameterfselectis a pointer to a non-NULL file selector widget. the parametercharacteris the character to inject into the widget. the return value and the side-effect (setting the widget dataexitType) depend on which character you injected:RETURNorTABβ the function returns achar *representing the info typed into the widget. the widget dataexitTypeis set tovNORMAL.ESCAPEβ the function returns aNULLpointer. the widget dataexitTypeis set tovESCAPE_HIT.- otherwise β unless it got modified by preprocessing, postprocessing or key bindings, the function returns a
NULLpointer. the widget dataexitTypeis set tovEARLY_EXIT.
moveCDKFselectβ moves the given widget to the given position. π- the parameters
xposandyposare the new position of the widget. - the parameter
xposmay be an integer or one of the pre-defined valuesTOP,BOTTOM, andCENTER. - the parameter
yposmay be an integer or one of the pre-defined valuesLEFT,RIGHT, andCENTER. - the parameter
relativestates whether thexpos/ypospair is a relative move or an absolute move.
- the parameters
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
refreshis a boolean value which states whether the widget will get refreshed after the move.
newCDKFselectβ creates an fselect widget and returns a pointer to it. parameters:- the
screenparameter is the screen you wish this widget to be placed in. - the parameter
xposcontrols the placement of the object along the horizontal axis. this parameter may be an integer or one of the pre-defined valuesLEFT,RIGHT, andCENTER. yposcontrols the placement of the object along the vertical axis. it may be an integer value or one of the pre-defined valuesTOP,BOTTOM, andCENTER.heightandwidthcontrol the height and width of the widget. if you provide a value of zero for either of theheightor thewidth, the widget will be created with the full width and height of the screen. if you provide a negative value, the widget will be created the full height or width minus the value provided.titleis 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.labelis the text to use as the label of the file selector.fieldAttributeis the attribute of the entry field at the top of the widget;fillerCharacteris the filler character for the entry field.highlightis the highlight attribute on the scrolling list.dirAttribute,fileAttribute,linkAttributeandsockAttributeare the attributes of directories, files, links, and sockets found in the directory list.boxis true if the widget should be drawn with a box around it.shadowturns the shadow on or off around this widget.
- the
if the widget could not be created then a NULL pointer is returned. π
positionCDKFselectβ allows the user to move the widget around the screen via the cursor/keypad keys. seecdk_position (3)for key bindings.setCDKFselectβ lets the programmer modify certain elements of an existing fselect widget. the parameter names correspond to the same parameter names listed in thenewCDKFselectfunction.setCDKFselectBackgroundAttribβ sets the background attribute of the widget. the parameterattributeis a curses attribute, e.g.,A_BOLD.setCDKFselectBackgroundColorβ sets the background color of the widget. the parametercoloris in the format of the Cdk format strings. seecdk_display (3). πsetCDKFselectBoxβ sets whether the widget will be drawn with a box around it.setCDKFselectBoxAttributeβ sets the attribute of the box.setCDKFselectContentsβ sets the contents of the widget.setCDKFselectCurrentItemβ set the current position in the scroll-widget.setCDKFselectDirAttributeβ sets the attribute that directories will be drawn with in the scrolling region of the widget.setCDKFselectDirContentsβ this creates a list of the files in the current directory. seegetCDKFselectDirContents.setCDKFselectDirectoryβ sets the current directory of the widget.setCDKFselectFileAttributeβ sets the attribute that plain files will be drawn with in the scrolling region of the widget.setCDKFselectFillerCharβ sets the character to use when drawing the entry field portion of the widget.setCDKFselectHighlightβ sets the attribute of the highlight bar of the scrolling list portion of the widget.setCDKFselectHorizontalCharβ sets the horizontal drawing character for the box to the given character.setCDKFselectLLCharβ sets the lower left hand corner of the widget's box to the given character.setCDKFselectLRCharβ sets the lower right hand corner of the widget's box to the given character.setCDKFselectLinkAttributeβ sets the attribute that symbolic links will be drawn with in the scrolling region of the widget.setCDKFselectSocketAttributeβ sets the attribute that sockets will be drawn with in the scrolling region of the widget.setCDKFselectULCharβ sets the upper left hand corner of the widget's box to the given character.setCDKFselectURCharβ sets the upper right hand corner of the widget's box to the given character.setCDKFselectVerticalCharβ sets the vertical drawing character for the box to the given character.
β¨ KEY BINDINGS β¨
okay so when the widget gets activated, there's a whole set of default key bindings ready to help you enter or manipulate info fast π . and because this widget is literally built from both the scrolling list widget and the entry field widget, the key bindings are the same for the respective fields π«Ά. the extra key bindings are the ones listed below, bestie:
CTRL-^β shows you stats about the current filename πTabβ tries to complete the current filename β¨Up Arrowβ scrolls the scrolling list up one line β¬οΈDown Arrowβ scrolls the scrolling list down one line β¬οΈPage Upβ scrolls the scrolling list up one page πCTRL-Bβ scrolls the scrolling list up one page πPage Downβ scrolls the scrolling list down one page πCTRL-Fβ scrolls the scrolling list down one page πReturnβ returns the filename in the entry field of the file selector. it also sets the widget dataexitTypetovNORMALπEscapeβ exits the widget and returns aNULLpointer. it also sets the widget dataexitTypetovESCAPE_HITπ
πΈ NOTES πΈ
this widget is created from the scrolling list widget, and the entry field widget π¦. it's lowkey a great example of how to build your own widgets using the base widgets provided in this distribution β main character energy fr fr π
so, in order for you to delete files using the file selector, you must add the following call into your program. (the character X is the character you wish to use to tell the file selector you want to delete a file.) ποΈ
bindCDKObject (vSCROLL, fselect->filelist, X, deleteFile, fselect);
where fselect is a pointer to the object. this was originally turned on, but I thought it better to put the control of file deletion on an 'as-need' basis π
π SEE ALSO π
and that's the whole page bestie, we ate and left no crumbs πβ¨ this one's from 2024-03-28 and it lives at cdk_fselect(3) β go forth and select files, icon π
π
π¦ 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