picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 00b73207b6cca8c3c260535faf0a28c7ca9d4bcd
parent c4bbf4f9a95f26fd8a62f499ad2fbefe1574b987
Author: Alexander Burger <abu@software-lab.de>
Date:   Fri, 23 Nov 2012 15:00:39 +0100

Line editor arrow-key support (CSI)
Diffstat:
MCHANGES | 1+
Mlib/led.l | 22+++++++++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -1,4 +1,5 @@ * DDmmm12 picoLisp-3.1.1 + Line editor arrow-key support Changed from CTags to ETags format Backtrace with 'trail' and 'up' (64-bit) Changed semantics of token 'read' diff --git a/lib/led.l b/lib/led.l @@ -1,4 +1,4 @@ -# 19nov12abu +# 23nov12abu # (c) Software Lab. Alexander Burger # Line editor @@ -112,6 +112,16 @@ (de xMove () (chgLine "Line" (inc (length "Line"))) ) +# Move up +(de uMove () + (when (< "HPos" (length "History")) + (setHist (inc "HPos")) ) ) + +# Move down +(de dMove () + (unless (=0 "HPos") + (setHist (dec "HPos")) ) ) + # Move word left (de lWord () (use (N L) @@ -332,8 +342,8 @@ ("h" (lMove)) ("i" (doUndo) (on "Insert")) ("I" (doUndo) (bMove) (on "Insert")) - ("j" (unless (=0 "HPos") (setHist (dec "HPos")))) - ("k" (when (< "HPos" (length "History")) (setHist (inc "HPos")))) + ("j" (dMove)) + ("k" (uMove)) ("l" (rMove)) ("n" (ledSearch "Line")) ("N" (if "Found" (setHist (pop '"Found")) (beep))) @@ -382,6 +392,12 @@ (cons (cons Key Prg) (delete @ "FKey")) ) (T (cons (cons Key Prg) "FKey")) ) ) ) +(when (= "xterm" (sys "TERM")) # Hardcoded (because 'tput' gives wrong codes) + (fkey "^[[A" (uMove)) # Is CSI portable enough? + (fkey "^[[B" (dMove)) + (fkey "^[[C" (rMove)) + (fkey "^[[D" (lMove)) ) + # Main editing functions (de _led ("Line1" "tabFun" "skipFun") (default "tabFun"