jedsoft / most

GNU General Public License v2.0
41 stars 2 forks source link

Exit search with Escape #2

Open notramo opened 2 years ago

notramo commented 2 years ago

How can I make a keybinding to exit search mode with Escape? It should be used to e.g. goto line number input too.

jedsoft commented 2 years ago

I do not know what you mean by search-mode. If you are talking about aborting the search string prompt, then the default binding to abort the prompt is Ctrl-G. There is currently no mechanism supported by most to permit key-bindings for the prompt.

It is also currently not possible to bind the ESC key itself. Other keys, e.g., arrow keys, send the ESC character as part of their key-sequences. Detecting just the ESC would require code that looks at the relative timing between the ESC character and the following one.

ghost commented 1 year ago

Actually it is no hard, in the IBM PC hardware (old and new) it has to store them immediately was interrupt, or USB which OS can to store it also super fast. Actually in most cases it happens in 20-30 CPU cycles. Delay is needed only for really slow remote connection [which run the most from there] - with bad protocol - and of course if you still have a dinosaur with RS232. Also, we have to emulate it for compatibility, after all we run in terminal emulator and we dont know how they use the stty speed. As I said, if it is one key the next character its already stored in keyboard buffer, but for emulation and remove connection you need to wait a few ms.

--- patched jed code ---
        int ch = my_getkey();
        if ( SLKeyBoard_Quit || SLang_get_error() ) return -1;
        if ( ch == 27 ) {
                int tsecs = 1; // 1 = 100ms
                if ( 0 == input_pending(&tsecs) )
                        return 27; // it is one ESCape alone
                }
        ungetkey(&ch); // or whatever ... 

Since the most we are using a desktop/laptop PC-clones or ARMxx device and we are connected through ethernet or VDSL and not 1200bps without MNP5... the correct is to be used the fast version by default and had something to use delay when it is needed (an environment variable for example for all the JED/S-Lang)...