bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dialog] make hotkeys hotter for quick selection in radiolists?


From: sunnycemetery
Subject: Re: [dialog] make hotkeys hotter for quick selection in radiolists?
Date: Thu, 17 Jan 2019 20:26:54 -0500
User-agent: Mutt/1.11.1 (2018-12-01)

Would including as optional the feature described below be out of the question? 
 It would be nice to make a radio list selection with a single key, provided 
the selection were unambiguous.

(This is an old item from the mailing list that never got the response it 
deserved.)

On 2016年05月25日 14時51分, Cristian Rigamonti wrote:
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 */
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]