support arrow keys, page up/down, etc
This commit is contained in:
parent
676d9f5405
commit
201c549135
52
femto.tal
52
femto.tal
|
@ -96,6 +96,8 @@
|
|||
|
||||
@state [
|
||||
&saw-esc $1 ( did we just see ESC? )
|
||||
&saw-xterm $1 ( did we just see an ESC [ xterm sequence? )
|
||||
&saw-vt $1 ( did we just see an ESC [ $N vt sequence? )
|
||||
&modified $1 ( has the buffer been modified? )
|
||||
&quitting $1 ( are we in the process of quitting? )
|
||||
]
|
||||
|
@ -576,8 +578,11 @@
|
|||
|
||||
;move-to-message-line JSR2
|
||||
.File/success DEI2 STH2r EQU2 ( ok? ) ,&ok JCN
|
||||
;messages/save-failed ,&finish JMP
|
||||
&ok #00 .state/modified STZ ;messages/save-ok
|
||||
;messages/save-failed ,&finish JMP
|
||||
&ok
|
||||
#00 .state/modified STZ
|
||||
;tmp/data ;filename ;str-copy JSR2
|
||||
;messages/save-ok
|
||||
&finish
|
||||
;print JSR2 ;tmp/data ;print JSR2
|
||||
;draw-all JSR2
|
||||
|
@ -595,6 +600,47 @@
|
|||
.Console/read DEI LIT '> EQU ( M-> ) ;goto-end JCN2
|
||||
.Console/read DEI LIT 'g EQU ( M-g ) ;goto-line JCN2
|
||||
.Console/read DEI LIT 'v EQU ( M-v ) ;page-up JCN2
|
||||
.Console/read DEI LIT '[ EQU ( M-[ ) ;xterm JCN2
|
||||
BRK
|
||||
|
||||
@xterm
|
||||
#01 .state/saw-xterm STZ BRK
|
||||
|
||||
@on-key-vt ( -> )
|
||||
.state/saw-vt LDZk STH #00 SWP STZ
|
||||
.Console/read DEI LIT '~ EQU ,&ok JCN
|
||||
POPr BRK
|
||||
&ok
|
||||
STHr DUP LIT '1 NEQ ,¬-1 JCN
|
||||
( ^[[1~ -> home ) POP ;bol JMP2
|
||||
¬-1 DUP LIT '2 NEQ ,¬-2 JCN
|
||||
( ^[[2~ -> insert ) POP BRK
|
||||
¬-2 DUP LIT '3 NEQ ,¬-3 JCN
|
||||
( ^[[3~ -> delete ) POP ;delete JMP2
|
||||
¬-3 DUP LIT '4 NEQ ,¬-4 JCN
|
||||
( ^[[4~ -> end ) POP ;eol JMP2
|
||||
¬-4 DUP LIT '5 NEQ ,¬-5 JCN
|
||||
( ^[[5~ -> page up ) POP ;page-up JMP2
|
||||
¬-5 DUP LIT '6 NEQ ,¬-6 JCN
|
||||
( ^[[6~ -> page down ) POP ;page-down JMP2
|
||||
¬-6 DUP LIT '7 NEQ ,¬-7 JCN
|
||||
( ^[[7~ -> home ) POP ;bol JMP2
|
||||
¬-7 DUP LIT '8 NEQ ,¬-8 JCN
|
||||
( ^[[8~ -> end ) POP ;eol JMP2
|
||||
¬-8
|
||||
( ??? ) POP BRK
|
||||
|
||||
@on-key-xterm ( -> )
|
||||
#00 .state/saw-xterm STZ
|
||||
.Console/read DEI LIT 'A EQU ( ^[[A -> up ) ;up JCN2
|
||||
.Console/read DEI LIT 'B EQU ( ^[[B -> down ) ;down JCN2
|
||||
.Console/read DEI LIT 'C EQU ( ^[[C -> right ) ;forward JCN2
|
||||
.Console/read DEI LIT 'D EQU ( ^[[D -> left ) ;back JCN2
|
||||
.Console/read DEI LIT 'F EQU ( ^[[F -> end ) ;eol JCN2
|
||||
.Console/read DEI LIT 'H EQU ( ^[[H -> home ) ;bol JCN2
|
||||
.Console/read DEI LIT '0 LTH ;ignore JCN2
|
||||
.Console/read DEI LIT '8 GTH ;ignore JCN2
|
||||
.Console/read DEI .state/saw-vt STZ ( ^[[1 through ^[[8 )
|
||||
BRK
|
||||
|
||||
@clear-line ( -> )
|
||||
|
@ -620,6 +666,8 @@
|
|||
@on-key
|
||||
;clear-message-line JSR2
|
||||
.prompt/active LDZ ;on-key-prompt JCN2
|
||||
.state/saw-vt LDZ ;on-key-vt JCN2
|
||||
.state/saw-xterm LDZ ;on-key-xterm JCN2
|
||||
.state/saw-esc LDZ ;on-key-escaped JCN2
|
||||
.Console/read DEI #01 EQU ( C-a ) ;bol JCN2
|
||||
.Console/read DEI #02 EQU ( C-b ) ;back JCN2
|
||||
|
|
Loading…
Reference in New Issue