diff options
Diffstat (limited to 'main.c')
| -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; } |
