Make key-bindings for INPUT more shell like: CursorUp/CursorDown

cycles through the command history.  Use Ctrl-p/-n to move cursor to
the previous/next line in the input.
This commit is contained in:
eknauel 2005-05-17 13:32:23 +00:00
parent d5a033368a
commit 0cda756391
1 changed files with 28 additions and 28 deletions

View File

@ -91,19 +91,19 @@
(set! pos-col (- pos-col 1))))
values))
;;Nav
((= ch key-up)
;; move cursor to previous line Ctrl-p, keycode 16
((= ch 16)
(if (< pos-fin-ln 2)
values
(let ((length-prev-line
(string-length
(list-ref text (- pos-line 2)))))
(begin
(set! can-write #f)
(set! pos-line (- pos-line 1))
(set! pos-col (+ length-prev-line 2))))))
(set! pos-col (+ length-prev-line 2)))))
((= ch key-down)
;; move cursor to next line Ctrl-n, keycode 141
((= ch 141)
(let ((last-pos (length text)))
(if (>= pos-line last-pos)
values
@ -152,8 +152,8 @@
(set! text (append text-front '("")))
(set! pos-col 2)))))
;;Ctrl+f -> History-forward
((= ch 6)
;; forward in command history -- CursorDown
((= ch key-down)
(if can-write
(begin
(if (< history-pos (- (length text) 1))
@ -167,8 +167,8 @@
(list-ref text (- (length text) 1)))))
(set! pos-col (+ line-length 2))))))
;;Ctrl+b -> History-back
((= ch 2)
;; back in command history -- CursorUp
((= ch key-up)
(if can-write
(begin
(if (> history-pos 0)