1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 05:18:05 +11:00

editor: add cursor pos tracking and display

This commit is contained in:
Virgil Dupras 2020-04-30 20:42:07 -04:00
parent 07f807edee
commit 792c781614
4 changed files with 33 additions and 24 deletions

View File

@ -1,5 +1,5 @@
152 LOAD ( extras ) 152 LOAD ( extras )
103 105 LOADR 103 106 LOADR
: BROWSE : BROWSE
100 _LIST 100 _LIST

27
blk/104
View File

@ -1,16 +1,13 @@
( Line numbers for the user are 1-based, but in code, they're ( Cursor position in buffer. EDPOS/64 is line number )
0-based. )
VARIABLE EDPOS VARIABLE EDPOS
: _bpos 64 * BLK( + ; : _cpos BLK( + ;
: T 1- DUP EDPOS ! _bpos (print) CRLF ; : _lpos 64 * _cpos ;
: P : _pln ( lineno -- )
EDPOS @ _bpos C< DUP _lpos DUP 64 + SWAP DO ( lno )
64 0 DO ( bpos c ) I EDPOS @ _cpos = IF '^' EMIT THEN
DUP 0xd = IF DROP 0 THEN I C@ DUP 0x20 < IF DROP 0x20 THEN
2DUP SWAP I + C! EMIT
DUP IF DROP C< THEN LOOP ( lno )
LOOP 1+ . ;
2DROP ( user-facing lines are 1-based )
BLK!! : T 1- DUP 64 * EDPOS ! _pln ;
;

21
blk/105
View File

@ -1,11 +1,16 @@
: _mvln+ ( ln -- move ln 1 line further ) : P
DUP 14 > IF DROP EXIT THEN EDPOS @ _cpos C<
_bpos DUP 64 + 64 MOVE 64 0 DO ( bpos c )
DUP 0xd = IF DROP 0 THEN
2DUP SWAP I + C!
DUP IF DROP C< THEN
LOOP
2DROP
BLK!!
; ;
: U : _mvln+ ( ln -- move ln 1 line further )
15 EDPOS @ - 0 DO DUP 14 > IF DROP EXIT THEN
14 I - _mvln+ _lpos DUP 64 + 64 MOVE
LOOP
P
; ;

7
blk/106 Normal file
View File

@ -0,0 +1,7 @@
: U
15 EDPOS @ 64 / - 0 DO
14 I - _mvln+
LOOP
P
;