From 4b4ab6a50998219cd94139c5669ef9a624c8f58f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 27 Dec 2015 14:41:30 -0600 Subject: Add scan_key_getsize() doing the ANSI probe, switch scan_key() to TAGGED_ARRAY, and add test_scankey. --- toys/other/hexedit.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'toys/other') diff --git a/toys/other/hexedit.c b/toys/other/hexedit.c index 1c2ad88e..b3bde2e5 100644 --- a/toys/other/hexedit.c +++ b/toys/other/hexedit.c @@ -213,16 +213,21 @@ void hexedit_main(void) pos = ll[--TT.undo]; TT.data[pos] = toybuf[sizeof(long long)*UNDO_LEN+TT.undo]; } - } else if (key==KEY_UP) pos -= 16; - else if (key==KEY_DOWN) pos += 16; - else if (key==KEY_RIGHT) { - if (x<15) pos++; - } else if (key==KEY_LEFT) { - if (x) pos--; - } else if (key==KEY_PGUP) pos -= 16*TT.height; - else if (key==KEY_PGDN) pos += 16*TT.height; - else if (key==KEY_HOME) pos = 0; - else if (key==KEY_END) pos = TT.len-1; + } + if (key>256) { + key -= 256; + + if (key==KEY_UP) pos -= 16; + else if (key==KEY_DOWN) pos += 16; + else if (key==KEY_RIGHT) { + if (x<15) pos++; + } else if (key==KEY_LEFT) { + if (x) pos--; + } else if (key==KEY_PGUP) pos -= 16*TT.height; + else if (key==KEY_PGDN) pos += 16*TT.height; + else if (key==KEY_HOME) pos = 0; + else if (key==KEY_END) pos = TT.len-1; + } } munmap(TT.data, TT.len); close(fd); -- cgit v1.2.3