| Contents of Intermediate File | ||
| Filepicker | Recordpicker | |
| On entry |
|
|
| On exit |
|
|
makeThe simplest way to build it is the following:
make cleanThe make all command should issue no warnings when used with GNU gcc. The make install copies the fpick and rpick executables to the /usr/local/bin directory. If you compile this on a non-Linux system or with a non-GNU C compiler, please let me know how it comes out.
make all
su
make install
|
|
|||||||||||||||||||||||||||||||||
fpick /path/to/intermediate.fileOn entry, the intermediate file must contain a line like this:
dir=/path/to/investigateThat directory is listed by fpick, subdirectories first, showing the dot and doubledot first. From there, subdirectories and superdirectories (via the doubledot) can be navigated. Optionally, the intermediate file can contain a list of permissible and forbidden user actions where user actions are one of cancel, select, superselect, add, change, delete. The superselect user action chooses a directory and returns instead of drilling down into that directory. It's used to choose directories as opposed to files.
action=selectOr, if the user cancels, it looks like this:
file=/home/jones/mp3/artiekegler.m3u
action=cancelThere's also a superselect action to choose a directory (instead of plunging into it). The superselect action does not work on normal files -- directories only:
action=superselectThe filepicker can accommodate all useractions: cancel, select, superselect, add, change and delete. Therefore, you could create a fairly decent filemanager with a 30 line shellscript repeatedly calling the filepicker, especially if later a run user action is added.
file=/home/jones/mp3
| Incoming intermediate file line |
What it does | Default? | Manditory? |
| dir=/path/directory | directory in which to start choosing | manditory | |
| select=y select=n |
SELECT user action OK? | y | optional |
| superselect=y superselect=n |
SUPERSELECT (SELECT DIRECTORY) user action OK? | n | optional |
| cancel=y cancel=n |
CANCEL user action OK? | y | optional |
| add=y add=n |
ADD user action OK? | n | optional |
| change=y change=n |
CHANGE user action OK? | n | optional |
| delete=y delete=n |
DELETE user action OK? | n | optional |
| Intermediate file line from filepicker | What it does | When it's used |
| action=cancel action=select action=superselect action=add action=change action=delete |
Informs calling program of the user's action | Always written to intermediate file on normal termination. |
| file=/full/path/to/file | Informs calling program of filename picked | Written to intermediate file for select, superselect, change and delete. Not written for cancel and add. |
![]() |
The screenshot at the left, run in a graphical terminal, is the filepicker part of a
relatively simple shellscript in which the user chooses a file to put into the less pager. Notice the directory (/etc/) is listed on top. Note that the current record has an arrow in front of it. That arrow moves down as the user presses j and up as the user presses k. Directories are denoted by a preliminary slash. When the user selects (by pressing y) a directory, the contents of that directory fill the list. If the user selects the double dot directory, the parent directory is listed. |
|
In the simple shellscript to the right, first a temporary file is created with mktemp.
That's so you can run several instances of the script without them
clobbering each other. Next, the starting directory is written to the
temporary file, and then superselect=n
is written to the temporary file, so that directories can't be
selected. This is an illustration only, superselect defaults to no. Next fpick is called to offer the user the opportunity to cruise the filesystem, starting with /etc, and choose a file to page. If the user selected rather than cancelled, the file=/etc/Muttrc that fpick wrote to the temporary file is parsed via sed to remove the file=, leaving just the full path filename, and then that file is viewed by the less pager. |
| Incoming intermediate file line |
What it does | Default? | Manditory? | ||
| select=y select=n |
SELECT user action OK? | Y | Optional | ||
| superselect=y superselect=n |
SUPERSELECT (SELECT DIRECTORY) user action OK? | N | Optional | ||
| cancel=y cancel=n |
CANCEL user action OK? | Y | Optional | ||
| add=y add=n |
ADD user action OK? | N | Optional | ||
| change=y change=n |
CHANGE user action OK? | N | Optional | ||
| delete=y delete=n |
DELETE user action OK? | N | Optional | ||
| startofdata | Stops search for configuration parameters and signifies that all following lines are data to go in the picklist. | Manditory | |||
| Line of data | Random strings of data on lines following the startofdata
line. NOTE: If there's no data, the recordpicker disables all useractions except cancel and add. |
| Intermediate file line from recordpicker | What it does | When it's used |
| action=cancel action=select action=superselect action=add action=change action=delete |
Informs calling program of the user's action | Always written to intermediate file on normal termination. |
| recno=picked_number | Informs calling program of zero based line number of the chosen record | Written to intermediate file for select, superselect, change and delete. Not written for cancel and add. |
| string=picked_string | Informs the calling program of the string value of the chosen record | Written to intermediate file whenever the recno= is written to the intermediate file. |
![]() |
The screenshot at the left, run in a graphical terminal, is the recordpicker part of a
relatively simple shellscript presenting the user with the songs in a
playlist, giving the user a chance to pick which song to play, and then
playing the song. Notice that lines are a maximum of 74 characters long, which, when added to the 3 characters used by the arrow prompt at the left of the current record, add up to 77. If a line were to go past the terminal's last column, it would screw up the picklist. It's the calling script's duty to trim all incoming lines. |
|
Notice that the calling program (this shellscript) must trim the length
of each line to 74 in order to fit the 80 column terminal (including
the line pointer that travels in front of the lines). Therefore, the
recordpicker's returned string will not be a full filename and will not
play on the play utility.
Therefore, the record number must be used to reconstitute the full
filename. This is very typical of most record picking operations,
including those involving databases. The shellscript first creates a unique intermediate file using mktemp. It writes the startofdata marker to the intermediate file and then all the lines of the .m3u file, suitably trimmed by the cut command. Next it calls rpick (the recordpicker), in which the user chooses the line corresponding to the song he wants to hear. rpick writes the chosen song's zero based record number (how far it is down the list, with the top being zero), and the string representation, which in this case is meaningless because the strings have been trimmed to 74 characters, and also writes whether the user chose to select or cancel. |