open
https://gitlab.synchro.net/main/sbbs/-/work_items/1413
2026-11-23 18:05:28 -0800
The Terminal Server's line input (`getstr()`, and `console.getstr()` in JavaScript) supports an **input history**: given a list of earlier entries, the user can recall them with the Up/Down arrow keys and complete a partly typed entry with Tab. Few prompts supply a history, and users have almost no way to find out it exists.
## How it works today
`sbbs_t::getstr(str, maxlen, mode, history)` (`src/sbbs3/getstr.cpp`), and `console.getstr([default] [,maxlen] [,mode] [,history[]])` in JS (`js_console.cpp`), take an optional list of strings, most recent first:
- **Up arrow / Ctrl-^**: replace the input with the next older entry (beeps at the oldest).
- **Down arrow / Ctrl-J**: the next newer entry; past the newest, back to what was typed (beeps if already there).
- **Tab**: replace the input with the first entry that starts with what has been typed so far (case-insensitive). Does nothing on an empty line.
- With a history, Tab no longer acts as Enter, and Down arrow no longer acts as Enter in `K_MSG` mode.
The caller keeps the list: `getstr()` only reads it, so adding the entered string, removing duplicates, capping the length and saving it are up to each caller.
## Current uses
| Where | Prompt | History kept |
|---|---|---|
| `postmsg.cpp` (C++) | "To:" when replying to a post | only the replied-to message's recipient; not kept |
| `exec/load/shell_lib.js` `send_netmail()` | NetMail address | last 10, saved per user (`userprops` section `netmail sent`) |
| `exec/privatemsg.js` | user to send a private message/telegram to | recent recipients, saved per user (`userprops`) |
| `exec/sdos.js` (DOS shell) | command line | last 20, for the session |
| `exec/str_cmds.js` `get_arg()` | sysop command arguments | for the session (`bbs.mods`) |
Each JavaScript use reimplements the same "move to front, drop duplicates, cap, save" logic.
## Prompts that would benefit
- **Text searches** (highest value): every search prompt goes through one function, `sbbs_t::get_search_string()` (`prntfile.cpp`), used by the message scan (`scansubs.cpp`), file scan (`scandirs.cpp`), mail reading (`readmail.cpp`), the message reader's find (`readmsgs.cpp`), text file viewing (`prntfile.cpp`) and the user editor (`useredit.cpp`). One change there gives all of them a search history.
- **Local e-mail "To:"**: `shell_lib.js` `send_email()` (and the C++ equivalents: the reader's reply-by-e-mail and mail-forward prompts in `readmsgs.cpp` / `readmail.cpp`) has no history, unlike NetMail.
- **Multinode chat** input lines (`chat.cpp`), so users can recall and resend or correct a line.
- **File specification** prompts (`getfilespec()` in `file.cpp`, the download/upload file name prompts).
- **Remaining sysop commands** in `str_cmds.js` that prompt with plain `console.getstr()` (e.g. BULKMAIL's ARS prompt).
## Proposal
1. **Shared history handling**, so a prompt gets a history with one line of code:
- C++: a helper that returns a named history list for the current user and updates it after input (move to front, drop duplicates, cap length), saved in the user's properties file (`data/user/####.ini`, as `userprops.js` does) or kept for the session only, per prompt.
- JavaScript: a small library (e.g. `exec/load/input_history.js`) doing the same with `userprops.js`, replacing the copies in `shell_lib.js`, `privatemsg.js`, `sdos.js` and `str_cmds.js`.
2. **Use it** in the prompts listed above, starting with `get_search_string()`. 3. **Make it discoverable:**
- Fix the wiki's [user:ctrl_keys](
https://wiki.synchro.net/user:ctrl_keys) "String/line input editing keys" table: it lists **Ctrl-N / Page-down** as "next word / next history item", but Ctrl-N only moves to the next word; history recall is Up/Down arrow (Ctrl-^ / Ctrl-J), and Tab completion isn't listed at all.
- A visual cue when a history is available, e.g. a new `text.dat` string shown with the prompt ("Up/Down: recent, Tab: complete"), so sysops can reword or blank it. Alternatively, offer the most recent entry as the editable default (as `privatemsg.js` already does).
- Mention the keys in the help screens users see at these prompts: `textsrch.msg` (shown for `?` at a search prompt), and the Ctrl-K menu, which could list the line-editing keys.
- Document Tab completion in the `console.getstr()` JSDOC, which currently mentions only Up/Down recall.
_Authored by Claude (Claude Code), on behalf of @rswindell_
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net