jed-users mailing list

[2017 Date Index] [2017 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed-users] getkey ()


Morten Bo Johansen <mbj@xxxxxxxxxxx> wrote:
> If you execute the getkey () function from e.g. the S-Lang
> prompt, like this 
>
>     S-Lang> getkey
>
> and then type return, nothing should happen. However, if you
> press e.g. a function key or an arrow key, then the terminfo
> code for that key is inserted into the buffer. In my case, if I
> press the arrow right key, then "OC" is inserted into the buffer.
>
> Isn't that a bug?

No. `getkey` is a low-level function that returns a character (a byte,
actually) from the keyboard buffer.  Your right-arrow key is producing
3 bytes: ESC O C.  `getkey` returns the ESC character, leaving the
other 2 in the buffer.  After returning to the main editing loop, jed
checks to see if there is input waiting to be read.  It will see the
'O' character, which is bound to the `self_insert_cmd` causing the `O'
to be inserted into the buffer.  A similar action will occur for the
`C' character.  I think you want something like:

  define get_keysequence ()
  {
     variable s = char (getkey());
     while (input_pending (1))
       s += char (getkey());
     return s;
  }

I hope this helps.
--John

_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


[2017 date index] [2017 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]