jed-users mailing list

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

Re: [jed-users] getkey ()


You know, I see this a lot, especially with keyboard input. Someone writes a function with a wretchedly inappropriate name like getkey() even though it only returns an octate because that seemed to work for standard letters and numbers. Then users hit function keys, cursor control keys and those lovely multi-media buttons and the gopher goes down the mountain.

Sorry, I'm just in a pissy mood I guess, getkey() needs to get a whole key or it needs to be called getoctate() so nobody gets confused.

I went through this with a plethora of C and BASIC libraries under DOS and other operating systems back in the day of 5 1/4 floppies and we __still__ are going through this with scripted languages. Every one of those methods called themselves "getkey" or something close to it and every one of them only pulled an octate.

Just my 0.000002 cents worth.


On 08/21/2017 04:46 PM, John E. Davis wrote:
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>.


--
Roland Hughes, President
Logikal Solutions
(630)-205-1593

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog
http://lesedi.us/
http://onedollarcontentstore.com


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