open
https://gitlab.synchro.net/main/sbbs/-/work_items/1348
## Idea
Give the built-in message listings of the Terminal Server (the `L`ist command when reading mail or a sub-board, and the listings of search and scan results) the list behavior that the area selection lists, `uselect.js`, `text_sec.js` and `xtrn_sec.js` now have through `exec/load/select_item.js` (#1346):
- pagination: a page of messages at a time with an `[x-y of n]` indicator, rather than a stream that scrolls off the top and is stopped with the pause prompt or Ctrl-C
- navigation keys: Up/Down, Home/End and PgUp/PgDn move a selected message, and Enter reads it
- possibly a lightbar look: the selected message highlighted across the row, as with the `[xtrn_sec]` `lightbar` option
- Find (#1345) within the listing
## Current behavior
The listings are C++ loops that print one `list_msg()` line per message until the end of the base or `msgabort()`:
- sub-boards: `sbbs_t::listmsgs()` (`readmsgs.cpp`), from the `L` command of `scanposts()`, `listsub()`, and the ranked list; `searchposts()` and `showposts_toyou()` print their matches the same way (`SubMsgLstFmt`)
- mail: the `L` command of `readmail()` and its second copy after a search, and `searchmail()` (`readmail.cpp`; `MailWaitingLstFmt` / `MailOnSystemLstFmt` with the `MailWaitingLstHdr`, `MailSentLstHdr` or `MailOnSystemLstHdr` heading)
After the list, the user is back at the reading prompt and types a message number. There is no selected message and no way to page backward.
Both `L` commands first try the *List Msgs* loadable module (`cfg.listmsgs_mod`), and `readmail()` the *Read Mail* module, so a sysop can already replace the listings with `exec/msglist.js` (a full-screen list with its own navigation, sorting and reading). This issue is about the default, when no module is configured.
## Approaches
1. **A stock list module on `select_item()`**: a small `exec/` script, the default value of the *List Msgs* module, that lists the messages with the existing `text.dat` formats and returns the number chosen to the reading loop. It reuses the paging, navigation, highlight, lightbar and Find code as is. The C++ `L` handlers already pass the sub-board code (or `mail <which> <usernumber> <lm_mode>`) and act on the module having been invoked; they would need to accept a chosen message number back (e.g. the module's exit value) and jump to it.
2. **Native paging in the C++ loops**: add page/back/select handling around `list_msg()`. No module boundary, but it duplicates in C++ what `select_item.js` does and gains neither Find nor the `modopts.ini` look options.
Approach 1 fits what was done for the other lists. `msglist.js` remains the richer alternative.
## Things to settle
- **List size**: a mail or sub-board listing can be thousands of messages. `select_item()` asks its caller for one item at a time (`print_item(index)`), so headers can be loaded per displayed page rather than all at once; Find would have to read headers as it goes.
- **Starting point**: the built-in list starts at a prompted message number (`get_start_msgnum()`). With paging, starting on the page of the current message may make that prompt unnecessary.
- **Numbers**: the list shows the position within the scan (or the message number, for the ranked list). Typed numbers must keep meaning what they do at the reading prompt.
- **Search and scan results** (`searchposts()`, `showposts_toyou()`, `searchmail()`): these list a subset; the module would need the subset (or the search expression) passed to it, or these stay as they are at first.
- **Without the new options** the listing should look as it does now, so existing systems are unaffected until a sysop opts in (as with the other lists).
- **Text**: the `SubMsgLstFmt`, `MailWaitingLstFmt` and `MailOnSystemLstFmt` formats end the line themselves and have fixed-width fields; the highlight would follow the rules used for the other lists (only when the format's field allows it, or the whole row for a lightbar).
Related: #1346 (the `select_item.js` lists), #1345 (Find).
-- *Authored by Claude (Claude Code), on behalf of @rswindell*
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)