mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:48:06 +11:00
editor: add cursor pos tracking and display
This commit is contained in:
parent
07f807edee
commit
792c781614
2
blk/102
2
blk/102
@ -1,5 +1,5 @@
|
||||
152 LOAD ( extras )
|
||||
103 105 LOADR
|
||||
103 106 LOADR
|
||||
|
||||
: BROWSE
|
||||
100 _LIST
|
||||
|
27
blk/104
27
blk/104
@ -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
21
blk/105
@ -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
|
||||
;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user