diff options
| author | WormHeamer | 2026-01-03 06:09:41 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-03 06:11:13 -0500 |
| commit | 378cf3f1920a62e2ed00000c66a3548baedfce5a (patch) | |
| tree | 08f9affc66b36ade5abd47301dbd77569e93e4f2 | |
| parent | db8eea8baf396a965cc0c07ea8649dead043747f (diff) | |
show "no options" if optc=0; start at current in select_buf()
| -rw-r--r-- | main.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -1355,12 +1355,15 @@ static inline int umodi(int n, int d) { return (d + n%d) % d; } -int select_opt(Str *optv, u32 optc, Str prompt) { - if (!optc) return -1; +int select_opt_at(Str *optv, u32 optc, Str prompt, u32 opti) { + if (!optc) { + e.msg = S("no options"); + return -1; + } e.optc = optc; e.optvi = new_arr(&e.scratch, u32, optc); e.optv = optv; - e.opti = 0; + e.opti = opti; LineEditor le = line_editor(prompt, &e.scratch); int r = -1; for (;;) { @@ -1399,6 +1402,10 @@ done: return r; } +int select_opt(Str *optv, u32 optc, Str prompt) { + return select_opt_at(optv, optc, prompt, 0); +} + #include <dirent.h> Str select_file_in(const char *path) { @@ -1467,7 +1474,7 @@ int select_buf(void) { opt.n = e.bufn; for (u32 i = 0; i < e.bufn; i++) opt.v[i] = shorten_path(e.buf[i].path, &e.scratch); - int o = select_opt(opt.v, opt.n, S("Buffer: ")); + int o = select_opt_at(opt.v, opt.n, S("Buffer: "), e.bufi); if (o == -1) return -1; return o; } |
