Manpages

Manpage of cdk_fselect

cdk_fselect

Section: C Library Functions (3)
Updated: 24 April 1997
Index
Return to Main Contents
 

NAME

newCDKFselect, activateCDKFselect, injectCDKFselect, setCDKFselect, setCDKFselectDirectory, getCDKFselectDirectory, setCDKFselectFillerChar, getCDKFselectFillerChar, setCDKFselectHighlight, getCDKFselectHighlight, setCDKFselectFileArttibute, getCDKFselectFileArttibute, setCDKFselectDirArttibute, getCDKFselectDirArttibute, setCDKFselectLinkArttibute, getCDKFselectLinkArttibute, setCDKFselectSocketArttibute, getCDKFselectSocketArttibute, setCDKFselectBox, getCDKFselectBox, setCDKFselectULChar, setCDKFselectURChar, setCDKFselectLLChar, setCDKFselectLRChar, setCDKFselectVerticalChar, setCDKFselectHorizontalChar, setCDKFselectBoxAttribute, setCDKFselectBackgroundColor, drawCDKFselect, eraseCDKFselect, destroyCDKFselect - Creates a managed curses file selector widget.  

SYNOPSIS

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

#include <cdk.h>

CDKFSELECT *newCDKFselect (CDKSCREEN *cdkscreen, int xpos, int ypos, int height, int width, char *title, char *label, chtype fieldAttribute, chtype fillerCharacter, chtype highlight, char *dirAttribute, char *fileAttribute, char *linkAttribute, char *sockAttribute, boolean box, boolean shadow);

char *activateCDKFselect (CDKFSELECT *fselect, chtype *actions);

char *injectCDKFselect (CDKFSELECT *fselect, chtype input);

void setCDKFselect (CDKFSELECT *fselect, chtype fieldAttribute, chtype fillerCharacter, chtype highlight, char *dirAttribute, char *fileAttribute, char *linkAttribute, char *sockAttribute, boolean box);

void setCDKFselectDirectory (CDKFSELECT *fselect, char *directory);

char **getCDKFselectDirectory (CDKFSELECT *fselect);

void setCDKFselectFillerChar (CDKFSELECT *fselect, chtype filler);

chtype getCDKFselectFillerChar (CDKFSELECT *fselect);

void setCDKFselectHighlight (CDKFSELECT *fselect, chtype highlight);

chtype getCDKFselectHighlight (CDKFSELECT *fselect);

void setCDKFselectFileAttribute (CDKFSELECT *fselect, char *attribute);

char *getCDKFselectFileAttribute (CDKFSELECT *fselect);

void setCDKFselectDirAttribute (CDKFSELECT *fselect, char *attribute);

char *getCDKFselectDirAttribute (CDKFSELECT *fselect);

void setCDKFselectLinkAttribute (CDKFSELECT *fselect, char *attribute);

char *getCDKFselectLinkAttribute (CDKFSELECT *fselect);

void setCDKFselectSocketAttribute (CDKFSELECT *fselect, char *attribute);

char *getCDKFselectSocketAttribute (CDKFSELECT *fselect);

void setCDKFselectBox (CDKFSELECT *fselect, boolean box);

boolean getCDKFselectBox (CDKFSELECT *fselect);

void setCDKFselectULChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectURChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectLLChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectLRChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectVerticalChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectHorizontalChar (CDKFSELECT *,fselect, chtype character);

void setCDKFselectBoxAttribute (CDKFSELECT *,fselect, chtype character);

void setCDKFselectBackgroundColor (CDKFSELECT *,fselect, char * color);

void moveCDKFselect (CDKFSELECT *fselect, int box, int box, boolean relative, boolean refresh);

void positionCDKFselect (CDKFSELECT *fselect);

void drawCDKFselect (CDKFSELECT *fselect, boolean box);

void eraseCDKFselect (CDKFSELECT *fselect);

void destroyCDKFselect (CDKFSELECT *fselect);

void bindCDKObject (EObjectType widgetType, void *object, chtype key, BINDFN function, void *data);  

DESCRIPTION

The Cdk file selector widget creates a widget which allows a user to interact with the Unix file system. This widget allows the user to traverse the file system and even delete files. (See NOTES below for more information)

 

AVAILABLE FUNCTIONS

CDKFSELECT *newCDKFselect (CDKSCREEN *screen, int xpos, int ypos, int height, int width, char *title, char *label, chtype fieldAttribute, chtype fillerChar, chtype highlight, chtype dirAttribute, chtype fileAttribute, chtype linkAttribute, chtype sockAttribute, boolean box, boolean shadow);
This function creates a pointer to a fselect widget. The screen parameter is the screen you wish this widget to be placed in. The parameter xpos controls the placement of the object along the horizontal axis. This parameter can accept an integer value or one of the pre-defined values of LEFT, RIGHT, and CENTER. The parameter ypos controls the placement of the object along the vertical axis. This parameter can accept an integer value or one of the pre-defined values of TOP, BOTTOM, and CENTER. The parameters height and width control the height and width of the widget. If you provide a value of zero for either of the height or the width, 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. The title parameter 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. The parameter label sets the label of the file selector. The fieldAttribute parameter sets the attribute of the entry field at the top of the widget; fillerCharacter defines the filler character for the entry field. The highlight sets the highlight attribute on the scrolling list. The next four parameters: dirAttribute, fileAttribute, linkAttribute, and sockAttribute set the attributes of directories, files, links, and sockets found in the directory list. The box parameter states whether the widget will be drawn with a box around it or not. The shadow parameter accepts a boolean value to turn the shadow on or off around this widget. If the widget could not be created then a NULL pointer is returned.

char *activateCDKFselect (CDKFSELECT *fselect, chtype *actions);

This function activates the file selector widget and lets the user interact with the widget. The parameter fselect is a pointer to a non-NULL file selector 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 char * representing the information typed into the widget and the structure member exitType will be set to vNORMAL. If the character entered was ESCAPE then the function will returns NULL pointer and the structure member exitType is set to vESCAPE_HIT.

char *injectCDKFselect (CDKFSELECT *fselect, chtype character);

This function injects a single character into the widget. The parameter fselect is a pointer to a non-NULL file selector. The parameter character is the character to inject into the widget. If the character injected into this widget was RETURN or TAB then this function will return a char * representing the information typed into the widget and the structure member exitType will be set to vNORMAL. If the character entered was ESCAPE then the function will returns NULL pointer and the structure member exitType is set to vESCAPE_HIT. Any other character injected into the widget will set the structure member exitType to vEARLY_EXIT and the function will return a NULL pointer.

void setCDKFselect (CDKFSELECT *fselect, char *directory, chtype fieldAttribute, chtype fillerChar, chtype highlight, chtype dirAttribute, chtype fileAttribute, chtype linkAttribute, chtype sockAttribute, boolean box);

This function lets the programmer modify certain elements of an already defined fselect widget. The parameter names correspond to the same parameter names listed in the newCDKFselect function.

void setCDKFselectDirectory (CDKFSELECT *fselect, char *directory);

This sets the current directory of the widget.

char *getCDKFselectDirectory (CDKFSELECT *fselect);

This returns the current directory of the widget.

void setCDKFselectFillerChar (CDKFSELECT *fselect, chtype filler);

This sets the character to use when drawing the entry field portion of the widget.

chtype getCDKFselectFillerChar (CDKFSELECT *fselect);

This returns the character being used as the filler character in the entry field portion of the widget.

void setCDKFselectHighlight (CDKFSELECT *fselect, chtype highlight);

This function sets the attribute of the highlight bar of the scrolling list portion of the widget.

chtype getCDKFselectHighlight (CDKFSELECT *fselect);

This returns the attribute of the highlight bar of the scrolling list portion of the widget.

void setCDKFselectFileAttribute (CDKFSELECT *fselect, char *attribute);

This sets the attribute that plain files will be drawn with in the scrolling region of the widget.

char *getCDKFselectFileAttribute (CDKFSELECT *fselect);

This returns the attribute that plain files are drawn with in the scrolling region of the widget.

void setCDKFselectDirAttribute (CDKFSELECT *fselect, char *attribute);

This sets the attribute that directories will be drawn with in the scrolling region of the widget.

char *getCDKFselectDirAttribute (CDKFSELECT *fselect);

This returns the attribute that directories are drawn with in the scrolling region of the widget.

void setCDKFselectLinkAttribute (CDKFSELECT *fselect, char *attribute);

This sets the attribute that symbolic links will be drawn with in the scrolling region of the widget.

char *getCDKFselectLinkAttribute (CDKFSELECT *fselect);

This returns the attribute that symbolic links are drawn with in the scrolling region of the widget.

void setCDKFselectSocketAttribute (CDKFSELECT *fselect, char *attribute);

This sets the attribute that sockets will be drawn with in the scrolling region of the widget.

char *getCDKFselectSocketAttribute (CDKFSELECT *fselect);

This returns the attribute that sockets are drawn with in the scrolling region of the widget.

void setCDKFselectBox (CDKFSELECT *fselect, boolean boxWidget);

This sets whether or not the widget will be draw with a box around it.

boolean getCDKFselectBox (CDKFSELECT *fselect);

This returns whether or not the widget will be drawn with a box around it.

void setCDKFselectULChar (CDKFSELECT *fselect, chtype character);

This function sets the upper left hand corner of the widgets box to the given character.

void setCDKFselectURChar (CDKFSELECT *fselect, chtype character);

This function sets the upper right hand corner of the widgets box to the given character.

void setCDKFselectLLChar (CDKFSELECT *fselect, chtype character);

This function sets the lower left hand corner of the widgets box to the given character.

void setCDKFselectLRChar (CDKFSELECT *fselect, chtype character);

This function sets the lower right hand corner of the widgets box to the given character.

void setCDKFselectVerticalChar (CDKFSELECT *fselect, chtype character);

This function sets the vertical drawing character for the box to the given character.

void setCDKFselectHorizontalChar (CDKFSELECT *fselect, chtype character);

This function sets the horizontal drawing character for the box to the given character.

void setCDKFselectBoxAttribute (CDKFSELECT *fselect, chtype attribute);

This function sets the attribute of the box.

void setCDKFselectBackgroundColor (CDKFSELECT *fselect, char *color);

This sets the background color of the widget. The parameter color is in the format of the Cdk format strings. To get more information look at the cdk_display manual page.

void moveCDKFselect (CDKFSELECT *fselect, int xpos, int ypos, boolean relative, boolean refresh);

This function moves the given widget to the given position. The parameters xpos and ypos is the new position of the widget. The parameter xpos can accept an integer value or one of the pre-defined values of TOP, BOTTOM, and CENTER. The parameter ypos can accept an integer value or one of the pre-defined values of 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 of TOP, BOTTOM, LEFT, RIGHT, or CENTER when relative = TRUE. (wierd things may happen). The final parameter refresh is a boolean value which states whether the widget will get refreshed after the move or not.

void positionCDKFselect (CDKFSELECT *fselect);

This function allows the user to move the widget around the screen via the cursor/keypad keys. The following key bindings can be used to move the widget around the screen.

Key Bindings
Key Action Up Arrow Moves the widget up one line. Down Arrow Moves the widget down one line. Left Arrow Moves the widget left one column Right Arrow Moves the widget right one column Keypad-1 Moves the widget down one line and left one column. Keypad-2 Moves the widget down one line. Keypad-3 Moves the widget down one line and right one column. Keypad-4 Moves the widget left one column Keypad-5 Centers the widget both vertically and horizontally. Keypad-6 Moves the widget right one column Keypad-7 Moves the widget up one line and left one column. Keypad-8 Moves the widget up one line. Keypad-9 Moves the widget up one line and right one column. t Moves the widget to the top of the screen. b Moves the widget to the bottom of the screen. l Moves the widget to the left of the screen. r Moves the widget to the right of the screen. c Centers the widget between the left and right of the window. C Centers the widget between the top and bottom of the window. Escape Returns the widget to it's original position. Return Exits the function and leaves the widget where it was.

Keypad means that if the keyboard you are using has a keypad, then the Num-Lock light has to be on in order to use the keys as listed. (The numeric keys at the top of the keyboard will work as well.)

void drawCDKFselect (CDKFSELECT *fselect, boolean box);

This function draws the fselect widget on the screen. The box option draws the widget with or without a box.

void eraseCDKFselect (CDKFSELECT *fselect);

This function removes the widget from the screen. This does NOT destroy the widget.

void destroyCDKFselect (CDKFSELECT *fselect);

This function removes the widget from the screen and frees up any memory the object may be using.

void bindCDKObject (EObjectType widgetType, void *object, char key, BINDFN function, void *data);

This function allows the user to create special key bindings. The widgetType parameter is a defined type which states what Cdk object type is being used. To learn more about the type EObjectType read the cdk_binding manual page. The object parameter is the pointer to the widget object. The key is the character to bind. The function is the function type. To learn more about the key binding call-back function types read the cdk_binding manual page. The last parameter data is a pointer to any data that needs to get passed to the call-back function.

 

KEY BINDINGS

When the widget is activated there are several default key bindings which will help the user enter or manipulate the information quickly. Since this widget is 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 listed below.

Key Bindings
Key Action 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 structure member exitType in the widget to vNORMAL. Escape Exits the widget and returns a NULL pointer. It also sets the structure member exitType in the widget to vESCAPE_HIT.
 

SEE ALSO

cdk(3), cdk_binding(3), cdk_display(3), cdk_screen(3)  

NOTES

This widget is created from the scrolling list widget and the entry field widget. This is a good example on how to build your own widgets using the base widgets provided in this distribution. In order for you to delete files using the file selector, you must add the following line of code 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.

The header file <cdk.h> automatically includes the header files <curses.h>, <stdlib.h>, <string.h>, <ctype.h>, <unistd.h>, <dirent.h>, <time.h>, <errno.h>, <pwd.h>, <grp.h>, <sys/stat.h>, and <sys/types.h>. The <curses.h> header file includes <stdio.h> and <unctrl.h>.

If you have Ncurses installed on your machine add -DNCURSES to the compile line to include the Ncurses header files instead.


 

Index

NAME
SYNOPSIS
DESCRIPTION
AVAILABLE FUNCTIONS
KEY BINDINGS
SEE ALSO
NOTES

This document was created by man2html, using the manual pages.
Time: 19:22:55 GMT, March 28, 2024