summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWormHeamer2026-01-03 06:09:41 -0500
committerWormHeamer2026-01-03 06:11:13 -0500
commit378cf3f1920a62e2ed00000c66a3548baedfce5a (patch)
tree08f9affc66b36ade5abd47301dbd77569e93e4f2
parentdb8eea8baf396a965cc0c07ea8649dead043747f (diff)
show "no options" if optc=0; start at current in select_buf()
-rw-r--r--main.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/main.c b/main.c
index e9c3865..7b9f10c 100644
--- a/main.c
+++ b/main.c
@@ -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;
}