From dee61ad017b656e9d9aabda6dee8571783436475 Mon Sep 17 00:00:00 2001 From: xfnw Date: Fri, 24 Jul 2020 17:13:53 +0000 Subject: [PATCH] ctrl+arrow for faster movinh --- getkey.py | 7 +++++++ nboard | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/getkey.py b/getkey.py index 2a48bf9..446350b 100755 --- a/getkey.py +++ b/getkey.py @@ -4,6 +4,13 @@ import curses def main(stdscr): while True: k = stdscr.getkey() + + if k == '\x1b': + k="" + for i in range(5): + k += stdscr.getkey() + + print(repr(k)) diff --git a/nboard b/nboard index 884165f..5726986 100755 --- a/nboard +++ b/nboard @@ -3,7 +3,7 @@ import curses,time,json,sys -dataPath = '/home/lickthecheese/nboard/nboard.json' +dataPath = '/home/xfnw/nboard/nboard.json' allowedChars = " `~1234567890-=!@#$%^&*()_+qwertyuiop[]\\QWERTYUIOP{}|asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?" data = {} @@ -27,6 +27,10 @@ def main(stdscr): height, width = stdscr.getmaxyx() + if k == '\x1b': + k="" + for i in range(5): + k += stdscr.getkey() # detect where to move cursor if k == 'KEY_UP': @@ -41,6 +45,20 @@ def main(stdscr): if k == 'KEY_RIGHT': vx += 1 nl = vx + + if k == '[1;5A': + vy += 0-(height//2) + nl = vx + if k == '[1;5B': + vy += height//2 + nl = vx + if k == '[1;5D': + vx += 0-(width//2) + nl = vx + if k == '[1;5C': + vx += width//2 + nl = vx + if k == '\n': vx = nl vy += 1