On Tue, May 10, 2016 at 09:49:00PM +0200, Cristian Rigamonti wrote:
Is it possible to configure dialog so that by hitting a hot key the
corresponding item will be selected?
Ok, in case anyone else is interested, the attached patch implements this
feature.
Basically, I've duplicated part of the code that implements toggling an item
when pressing the space key (lines 401...).
Disclaimer: this is just a quick hack that works for me, but I don't know the
dialog code base very well, so this might not be the right way to implement it,
or it might even cause strange effects: suggestions and corrections are welcome!
Cri
--
GPG/PGP Key-Id 0x943A5F0E - http://www.linux.it/~cri/cri.asc
Index: dialog-1.3-20160424/checklist.c
===================================================================
--- dialog-1.3-20160424.orig/checklist.c 2015-01-26 00:53:06.000000000
+0100
+++ dialog-1.3-20160424/checklist.c 2016-05-25 14:31:18.000000000 +0200
@@ -537,6 +537,30 @@
print_list(&all, choice, scrollamt, max_choice);
}
}
+ // START hotter-keys
+ int current = scrollamt + choice;
+ int next = items[current].state + 1;
+ if (next >= num_states)
+ next = 0;
+ for (i = 0; i < item_no; i++) {
+ if (i != current) {
+ items[i].state = 0;
+ }
+ }
+ if (items[current].state) {
+ getyx(dialog, cur_y, cur_x);
+ items[current].state = next ? next : 1;
+ print_item(&all, all.list,
+ &items[current],
+ states,
+ choice, TRUE);
+ (void) wnoutrefresh(all.list);
+ (void) wmove(dialog, cur_y, cur_x);
+ } else {
+ items[current].state = 1;
+ print_list(&all, choice, scrollamt, max_choice);
+ }
+ // END hotter-keys
continue; /* wait for another key press */
}