Table of Contents
List Files
List Files is one of the sysop-configurable loadable modules: the module executed when a user of the Terminal server lists the files of a file directory, whether one directory or each directory of a scan for new files or a search. The stock module is exec/listfiles.js (new in v3.22).
By default its listings look like those of the file lister built into the Terminal server. What it adds:
- Directory headers and footers from menu files, for one directory, one library or every directory.
- A template, of @-codes, for each file's line.
- Options for its markers, colors, box characters, command keys and prompt, which can also be set for one library or one directory.
- For users with batch flagging enabled, on a terminal that can position the cursor (ANSI or PETSCII), an interactive listing: a highlighted current file moved with the arrow keys, files tagged with the Space bar or a double-click, and mouse selection.
- A choice of two styles for the interactive listing: classic, like the built-in lister, and lightbar, like the message lister
msglist, with a full-width bar on the current file and a preview pane of its information.
Install
Set SCFG->System->Loadable Modules->List Files to listfiles. To go back to the built-in file lister, clear that option.
Being a loadable module, it is easily replaced by a module of the sysop's choosing:
- Set SCFG->System->Loadable Modules->List Files to the name (or command-line) of a different module, or
Invoke
The configured List Files module runs for each directory listed by a command shell's list files, scan for new files and search commands (Baja FILE_LIST, JS bbs.list_files(), bbs.scan_dirs(), etc.), with these arguments:
| Argument | Value |
|---|---|
| 1 | The internal code of the directory |
| 2 | The listing mode: 0 to list files, 1 for new files only, 8 to search for a boolean search expression, 16 to display each file's extended information, 32 to view each file's contents (or a sum of those) |
| 3 and on | The filespec (e.g. *.zip), or the search expression |
It exits with the number of files listed (so a scan of many directories can total them), or -1 when the user aborted the listing. A directory with no files to list displays nothing.
Run with no arguments (e.g. ;EXEC ?listfiles from a sysop's session), it lists every file of the user's current directory.
Use
Batch flagging disabled
The files are listed as by the built-in lister: a directory header, then one line per file (filename, size or FREE, description), the listing pausing at each screenful.
Batch flagging enabled, interactive
For a user with batch flagging enabled (a user setting), on a terminal that can position the cursor, the listing is interactive, in the classic style (the default) or the lightbar style (see the style option below). Each directory starts on a new screen, and one file is current (highlighted).
Classic style
The command keys are displayed at the top of the screen, and the prompt below the files:
| Key | Action |
|---|---|
| Up / Down arrow | Move to the previous / next file, scrolling the list when the current file is the first / last on the screen |
| PgUp / PgDn | Display the previous / next screenful of files (Backspace is the same as PgUp) |
| Home / End | Move to the first / last file |
| Space | Tag or untag the current file (tagged files are marked with a check mark) and move to the next file |
| Ctrl-A | Tag every file of the directory, or untag them all when the first is tagged |
Enter or N | Display the next screenful, or go on to the next directory from the last one |
B / D | Add the tagged files (or the current file, when none is tagged) to the batch download queue, and with D download them right away; what was added, or why not, is displayed before the files are displayed again |
V / E | View the contents / extended information of the tagged files (or the current file) |
T | Toggle the display of extended file descriptions |
P or - | Display the previous screenful |
S | Skip the rest of this directory (in a scan) |
the Quit key (Q) | Stop listing files |
R (or Del) / M | Remove / move the tagged files (or the current file), for a user who may remove files from the directory |
? | Help |
A mouse click on a file makes it the current file, and a double-click tags or untags it.
Arrows on either side of the prompt's Listing show whether there are more files above (an up arrow) or below (a down arrow) those on the screen, and the current file's position (e.g. [file 3 of 99]) is displayed on the line above the prompt. A prompt too wide for the screen has its library and directory names shortened to fit.
Lightbar style
The screen is laid out as in the message lister: the library and directory names and the current file's position on the top row, column headings below them, one row per file with a full-width bar on the current file, and the command keys on the bottom row. Extended descriptions are not displayed beside the files; instead, when the user's extended descriptions setting is on, a preview pane in the lower half of the screen displays the current file's information and extended description. Header and footer files (see below) are not displayed in this style.
| Key | Action |
|---|---|
| Up / Down arrow, PgUp / PgDn, Home / End | Move the bar (or, when the preview pane has the focus, scroll the pane); Backspace and P are the same as PgUp, N as PgDn |
| Space | Tag or untag the current file and move to the next file |
| Ctrl-A | Tag every file of the directory, or untag them all when the first is tagged |
| Enter | Display the next screenful, or go on to the next directory from the last one |
E or T | Show or hide the preview pane (saved as the user's extended descriptions setting) |
| Tab | Show the preview pane, or move the focus between the list and the pane |
I | Display the full-screen extended information (with the uploader's avatar) of the tagged files (or the current file) |
B / D / V / S / Q / R (or Del) / M | As in the classic style |
? or H | Help |
The mouse wheel moves the bar, a click on a file makes it the current file, a double-click tags or untags it, and the command keys on the bottom row can be clicked. The preview pane needs a screen of at least 20 rows; on a shorter screen it is not displayed.
In both interactive styles, files already in the user's batch download queue are marked (with queued_marker, a down arrow) where tagged files are marked.
Batch flagging enabled, other terminals
On a terminal that cannot position the cursor, batch flagging works as it does in the built-in lister: the files of each screenful are lettered A through Z, and the prompt after each screenful asks for the letters (or filenames) of the files to act on.
Configure
Headers and footers
The header displayed before a directory's files is the first of these that exists:
data/dirs/<code>.hdr, for the directory with that internal codelistfiles_lib<N>_head, for the directories of library number Nlistfiles_head, for every directory
Otherwise, the built-in header is displayed: a box with the library, directory and number of files (or, in the interactive mode, the command keys). In the interactive mode the command keys are displayed below any other header too (see interactive_commands below). The lightbar style displays no headers or footers.
After the last file of a directory, the first of listfiles_<code>_tail, listfiles_lib<N>_tail and listfiles_tail that exists is displayed, if any.
Being menu files, each can have a version per terminal type (e.g. .ans, .asc) and language, and can use @-codes. The library and directory @-codes, such as @LIB@, @DIR@ and @FILES@, describe the directory being listed, also in a scan of many directories (as do those of a .hdr file).
Options
The stock listfiles module supports the following options in the [listfiles] section of the ctrl/modopts.ini file. An option set in a [listfiles:lib<N>] section applies to only the directories of library number N, and one set in a [listfiles:<code>] section to only the directory with that internal code.
The color options (named *_attr) are given as attribute letters, as in attr.ini: e.g. WH4 for bright white on blue, V for the mnemonic color. The other options with colors (the formats, command keys and prompt) use Ctrl-A codes.
| Option | Default | Description |
|---|---|---|
| line_fmt | (see below) | One file's line, for users with batch flagging enabled |
| line_fmt_nobatch | (see below) | One file's line, for users with batch flagging disabled |
| line_fmt_interactive | (see below) | One file's line, in the classic style's interactive mode |
| line_fmt_lightbar | (see below) | One file's line, in the lightbar style |
| style | classic | The interactive listing's style: classic or lightbar |
| interactive_commands | the command keys bar | The command keys displayed above the files in the interactive mode, below any header; "" for none (e.g. when a custom header displays them) |
| interactive_prompt | "\x01n\x01c%s \x01hListing \x01n\x01c%s (\x01h%u\x01n\x01c) %s (\x01h%u\x01n\x01c) %s (\x01h\x01`?\x01n\x01c=Menu) (\x01h%u\x01n\x01c Files): \x01n\x01~" | The interactive mode's prompt. Arguments: the up indicator, the down indicator, the library number and name, the directory number and name, and the number of files |
| position_fmt | "\x01n\x01h\x01k[file %u of %u]" | The current file's position, displayed above the interactive mode's prompt: the file's number and the number of files; "" for none |
| more_above | "\x18" (up arrow) | The up indicator when there are more files above those on the screen |
| more_below | "\x19" (down arrow) | The down indicator when there are more files below |
| no_more | "\xfe" (block) | Either indicator when there are no more files that way |
| extdesc_marker | + | Displayed after the filename of a file with an extended description that is not displayed |
| missing_marker | - | Displayed after the size of a file that is offline |
| tagged_marker | "\xfb" (check mark) | Marks a tagged file, in the interactive mode |
| queued_marker | "\x19" (down arrow) | Marks a file in the user's batch download queue, in the interactive mode (when not tagged) |
| untagged_marker | a space | Displayed in place of the tagged marker |
| name_attr, size_attr, desc_attr, letter_attr, free_attr | none | Colors for the filename, size, description, batch flag letter and FREE size; when not set, the colors of the file listing in ctrl/attr.ini |
| tag_attr | WH (bright white) | The color of the tagged and queued markers; empty for the filename color |
| flags_attr | KH (dark grey) | The color of the extended description marker; empty for the filename color |
| hdr_box_attr, hdr_line_attr | none | Colors for the header box and for the underline of the short header; when not set, the attr.ini colors |
| box_top_left, box_top_right, box_bottom_left, box_bottom_right, box_horizontal, box_vertical | "\xc9" "\xbb" "\xc8" "\xbc" "\xcd" "\xba" | The characters of the header box |
| short_hdr_underline | "\xc4" | The character underlining the short header (used in scans) |
| selected_item_attr | V (the attr.ini mnemonic color) | The color highlighting the current file in the classic style |
| highlight_line | true | true to highlight the current file's whole line, false to highlight only its filename (in the classic style) |
| lightbar_area_fmt | "\x01n\x01k\x017 %s / %s\x01h" | The lightbar style's top row: the library name and the directory's long name. Its last color fills the rest of the row |
| lightbar_position_fmt | "[file %u of %u]" | The current file's position, right-justified on the top row (of a screen at least 80 columns wide) |
| lightbar_headings | true | The column headings row: true to generate the headings from line_fmt_lightbar (so they line up with the columns), false for none, or the headings' text |
| lightbar_headings_attr | KH7 | The generated headings' color (filling the row) |
| heading_name, heading_size, heading_desc | Name, Size, Description | The titles of the generated headings' columns |
| lightbar_keys_prefix | "\x01n\x01c\xfe " (a cyan block) | Displayed at the start of the bottom row, before the command keys |
| lightbar_keys | "~Download, ~Batch, ~View, ~Extended, ~Info, Space=Tag, ~Quit or ~?" | The command keys on the bottom row, ~ before each key letter (highlighted and clickable); without Ctrl-A codes, which would turn off the keys' highlighting |
| lightbar_keys_operator | as lightbar_keys with ~Remove, ~Move | The command keys for a user who may remove files from the directory |
| lightbar_attr | WH4 (bright white on blue) | The bar's color |
| lightbar_keys_attr, lightbar_key_attr | none | The bottom row's color (filling the row) and the color of its key letters, e.g. K6 and WH6 for black on cyan with bright white keys; when not set, the attr.ini mnemonic colors |
| preview_name_fmt | Name and the full filename | The preview pane's first line when the list cuts the file's name short, unless its description shows it (as for a file without a description) |
| preview_info_fmt | the file's size, upload date, uploader, downloads and cost | The preview pane's information, of @FILE_*@ @-codes; the extended description follows it |
| preview_separator | "\xc4" | The character of the line above the preview pane |
| preview_info_label, preview_lines_fmt | "\xb4 Info \xc3", "\xb4 Lines %u-%u of %u \xc3" | The label and the lines displayed (first, last, number of lines) on the line above the pane |
| preview_extdesc_attr | WH (bright white) | The color of the extended description in the preview pane (before any of its own color codes) |
| preview_attr, preview_focus_attr | C, WH | The colors of the line above the pane, without and with the focus |
The commented-out [listfiles] section of the modopts.ini file of a new installation lists every option with its default.
File line templates
Each file's line is displayed from a template (line_fmt, line_fmt_nobatch, line_fmt_interactive or line_fmt_lightbar) of @-codes: any of the @FILE_*@ @-codes (e.g. @FILE_DATE@, @FILE_UPLOADER@, @FILE_TIMES_DLED@), with the usual width and alignment modifiers (e.g. @FILE_DATE-R10@), plus these, which only the List Files module expands:
| @-code | Value |
|---|---|
@NAME@ | The filename, formatted to 12 columns as the built-in lister does (its extension kept, the rest shortened or padded), or on a terminal at least 132 columns wide, to the width of the directory's longest filename |
@DESC@ | The description (or, when it has none, the filename), with a searched-for text highlighted; empty when the extended description is displayed beside the line |
@SIZE@ | The size, estimated in at most 6 characters (e.g. 976.6K), or FREE |
@FLAGS@ | extdesc_marker or a space |
@MISSING@ | missing_marker or a space |
@LETTER@ | The batch flag letter (A to Z) |
@TAG@ | tagged_marker or untagged_marker |
@NAME_ATTR@, @SIZE_ATTR@, @DESC_ATTR@, @LETTER_ATTR@ | The colors of the filename, size, description and letter |
@TAG_ATTR@, @FLAGS_ATTR@ | The colors of the tagged marker and the extended description marker (the tag_attr and flags_attr options) |
The defaults, which reproduce the built-in lister's lines (apart from the markers' colors):
[listfiles] line_fmt: "@NAME_ATTR@@NAME@@FLAGS_ATTR@@FLAGS@@LETTER_ATTR@@LETTER@@SIZE_ATTR@@SIZE-R6@@MISSING@@DESC_ATTR@@DESC@" line_fmt_nobatch: "@NAME_ATTR@@NAME@@FLAGS_ATTR@@FLAGS@@SIZE_ATTR@@SIZE-R7@@MISSING@@DESC_ATTR@@DESC@" line_fmt_interactive: "@NAME_ATTR@@NAME@@FLAGS_ATTR@@FLAGS@@TAG_ATTR@@TAG@@SIZE_ATTR@@SIZE-R6@@MISSING@@DESC_ATTR@@DESC@" line_fmt_lightbar: "@NAME_ATTR@@NAME@@FLAGS_ATTR@@FLAGS@@TAG_ATTR@@TAG@@SIZE_ATTR@@SIZE-R6@@MISSING@@DESC_ATTR@@DESC@"
For example, to add each file's upload date in the listings of users with batch flagging disabled:
[listfiles] line_fmt_nobatch: "@NAME_ATTR@@NAME@@FLAGS_ATTR@@FLAGS@@SIZE_ATTR@@SIZE-R7@@MISSING@ \x01n\x01c@FILE_DATE@ @DESC_ATTR@@DESC@"
A line wider than the terminal is truncated at its right edge.
Text
Most of the listing's text strings are those the built-in lister uses, customized by adding a line for each to the ctrl/text.ini file: e.g. BoxHdrLib, BoxHdrDir, BoxHdrFiles, ShortHdrLib, ShortHdrDir, FileListBatchCommands, BatchFlagPrompt and FREE. The interactive mode's command keys and prompt are the interactive_commands and interactive_prompt options instead.
The interactive mode's help (the ? key) is the menu file text/menu/listfiles_help in the classic style and listfiles_lightbar_help in the lightbar style (the built-in lister's batflag help when that file does not exist). The lightbar style's top row, headings and command keys are the lightbar_* options.