mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-26 05:08: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 )
|
152 LOAD ( extras )
|
||||||
103 105 LOADR
|
103 106 LOADR
|
||||||
|
|
||||||
: BROWSE
|
: BROWSE
|
||||||
100 _LIST
|
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
|
( 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
21
blk/105
@ -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
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user