1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 04:48:06 +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 )
103 105 LOADR
103 106 LOADR
: BROWSE
100 _LIST

27
blk/104
View File

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

21
blk/105
View File

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

7
blk/106 Normal file
View File

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