lines = 5 * 16
Text = "Some text to edit"
PRINT "Move cursor with left / right arrow"
PRINT "Insert / Type over, Append, Delete, Backspace"
PRINT "Move text with up / down arrow. ESC to exit"
curOffset
= _WIDTH * (15 + lines
) + curPosX
'initial
F = 0
X = 0
' IF _MOUSEBUTTON(1) = 0 AND F1 = 3 THEN F1 = 0
selectPosRightX = X
selectPosLowY = Y
F1 = 1
selectOffset = mouseOffset
selectPosLeftX = X
selectPosTopY = Y
insertKeyToggle = 1 'TYPEOVER mode
kh = 0
F = 0
insertKeyToggle = 0 'INSERT MODE
kh = 0
F = 0
F = 0
F = 1
F = 1
F = 0
' PRINT kh
IF insertKeyToggle
= 1 THEN GOSUB cursolidoff: insertKeyToggle
= 0:
GOTO LL3
Text
= LEFT$(Text
, printPos
- 2) + MID$(Text
, printPos
, LEN(Text
) - (printPos
- 1)) curPosX = curPosX - CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
LL3:
'****
'****
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
'****
'****
IF insertKeyToggle
= 0 THEN 'INSERT MODE Text
= LEFT$(Text
, printPos
- 1) + CHR$(kh
) + MID$(Text
, printPos
, LEN(Text
) - printPos
+ 1) curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
IF insertKeyToggle
= 1 AND LEN(Text
) = printPos
THEN 'cursor is pointing to last character insertKeyToggle = 0
Text
= LEFT$(Text
, printPos
- 1) + CHR$(kh
) + MID$(Text
, printPos
+ 1, LEN(Text
) - (printPos
)) curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
IF insertKeyToggle
= 1 AND LEN(Text
) > printPos
THEN 'cursor is pointing to any char except last char Text
= LEFT$(Text
, printPos
- 1) + CHR$(kh
) + MID$(Text
, printPos
+ 1, LEN(Text
) - (printPos
)) curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
END IF 'END INSERT OR TYPE OVER
'****
'****
IF insertKeyToggle
= 1 THEN GOSUB cursolidoff: insertKeyToggle
= 0:
GOTO LL1
Text
= LEFT$(Text
, printPos
- 1) + MID$(Text
, printPos
+ 1, LEN(Text
) - printPos
+ 1) curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
' LL1:
'****
'****
IF kh
= 19200 AND curPosX
> 0 THEN 'LEFT ARROW
curPosX = curPosX - CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
curPosX = curPosX - CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
'****
'****
insertKeyToggle = 0
curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
curPosX = curPosX + CharWidth
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
LL2:
'****
'****
pixelUpDown = pixelUpDown + 1
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
pixelUpDown = pixelUpDown + 1
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
'**** END DOWN ARROW
'****
IF kh
= 18432 AND lines
+ pixelUpDown
> lines
THEN 'UP ARROW
pixelUpDown = pixelUpDown - 1
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
pixelUpDown = pixelUpDown - 1
curOffset
= _WIDTH * (15 + lines
+ pixelUpDown
) + curPosX
'**** END UP ARROW
'****
'****
curmouseon:
FOR Z
= 0 TO CharHeight
- 1 newmouseOffset
= mouseOffset
+ Z
* _WIDTH FOR T
= newmouseOffset
* 4 TO newmouseOffset
* 4 + curWidth
* 4 STEP 4 IF b
= 255 AND g
= 255 AND r
= 255 THEN b
= 0: g
= 0: r
= 255 ' _MEMPUT M, M.OFFSET + T + 100, b
' _MEMPUT M, M.OFFSET + T + 1 + 100, g
' _MEMPUT M, M.OFFSET + T + 2 + 100, r
'****
curmouseoff:
FOR Z
= 0 TO CharHeight
- 1 newmouseOffset
= mouseOffset
+ Z
* _WIDTH
FOR T
= newmouseOffset
* 4 TO newmouseOffset
* 4 + curWidth
* 4 STEP 4 'locate 100,100: print t
IF b
= 0 AND g
= 0 AND r
= 255 THEN b
= 255: g
= 255: r
= 255
'****
cursolidon: 'Cursor for TYPE OVER mode - ON
FOR Z
= 0 TO CharHeight
- 1 newcurOffset
= curOffset
- Z
* _WIDTH
FOR T
= newcurOffset
* 4 TO newcurOffset
* 4 + curWidth
* 4 STEP 4
printPos = curPosX / CharWidth + 1
'****
cursolidoff: 'Cursor for TYPE OVER mode - OFF
newcurOffset
= curOffset
- Z
* _WIDTH
FOR T
= newcurOffset
* 4 TO newcurOffset
* 4 + curWidth
* 4 STEP 4 IF b
= 0 AND g
= 0 AND r
= 255 THEN b
= 255: g
= 255: r
= 255 printPos = curPosX / CharWidth + 1
'****
curon:
FOR T
= curOffset
* 4 TO curOffset
* 4 + curWidth
* 4 STEP 4 b = 255
g = 255
r = 0
printPos = curPosX / CharWidth + 1
'****
curoff:
FOR T
= curOffset
* 4 TO curOffset
* 4 + curWidth
* 4 STEP 4
b = 0
g = 0
r = 0
printPos = curPosX / CharWidth + 1
curSelect:
FOR Z
= 0 TO ABS(selectPosLowY
- selectPosTopY
) 'select block height newSelectOffset
= selectOffset
+ Z
* _WIDTH '* select block width
FOR T
= newSelectOffset
* 4 TO newSelectOffset
* 4 + (ABS(selectPosRightX
- selectPosLeftX
) * 4) STEP 4 IF b
= 255 AND g
= 255 AND r
= 255 THEN b
= 0: g
= 0: r
= 255