From c8c3810f380e6228a766f560489262a2b685b507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 10 Aug 2020 11:27:22 +0200 Subject: Add support for arrow keys in term. --- module/output/terminal.scm | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'module') diff --git a/module/output/terminal.scm b/module/output/terminal.scm index 4d12b48d..8fcb9cd5 100644 --- a/module/output/terminal.scm +++ b/module/output/terminal.scm @@ -161,12 +161,12 @@ (set! (page-length this) (length (cached-events this))) (case char - ((#\L #\l) + ((#\L #\l right) (set! (current-page this) = add-day (cached-events this) #f (active-element this) 0)) - ((#\h #\H) + ((#\h #\H left) (set! (current-page this) = remove-day (cached-events this) #f (active-element this) 0)) @@ -280,14 +280,15 @@ (define-method (input (this ) char) (case char - ((#\j #\J) (unless (= (active-element this) (1- (page-length this))) - (set! (active-element this) = (+ 1)))) - ((#\k #\K) (unless (= (active-element this) 0) - (set! (active-element this) = (- 1)))) + ((#\j #\J down) (unless (= (active-element this) (1- (page-length this))) + (set! (active-element this) = (+ 1)))) + ((#\k #\K up) (unless (= (active-element this) 0) + (set! (active-element this) = (- 1)))) ((#\g) (set! (active-element this) 0)) ((#\G) (set! (active-element this) (1- (page-length this)))) + ((#\q) '(pop))) ) @@ -301,8 +302,8 @@ (current-page this)) (active-element this)) 'DTSTART))))) - ((#\h) (set! (current-page this) = ((lambda (old) (max 0 (1- old)))))) - ((#\l) + ((#\h left) (set! (current-page this) = ((lambda (old) (max 0 (1- old)))))) + ((#\l right) (display "\n loading...\n") (set! (current-page this) (next-page (slot-ref this 'search-result) @@ -319,6 +320,15 @@ (when (eof-object? char) (break)) + (when (char=? char #\escape) + (case (read-char) + ((#\[) + (case (read-char) + ((#\A) (set! char 'up)) + ((#\B) (set! char 'down)) + ((#\C) (set! char 'right)) + ((#\D) (set! char 'left)))))) + (match (input (car state) char) (('push new-state) (set! state (cons new-state state))) (('pop) -- cgit v1.2.3