Skip to content

Commit

Permalink
Adds go to line editor command.
Browse files Browse the repository at this point in the history
This closes #28.
  • Loading branch information
dmsc committed Jul 8, 2020
1 parent 819c1a7 commit 95bb9dd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 27 deletions.
4 changes: 2 additions & 2 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
' -----------
' Ctrl-A : Move to begining of line
' Ctrl-E : Move to end of line
' Ctrl-U : Page up
' Ctrl-V : Page down
' Ctrl-U / Ctrl-V : Page up / down
' Ctrl-Z : Undo (only current line)
' Ctrl-M : Set Mark to current line
' Ctrl-C : Copy from Mark to here
Expand All @@ -16,6 +15,7 @@
' Ctrl-N : New file
' Ctrl-R : Parse and run program
' Ctrl-W : Compile to binary file
' Ctrl-G : Go to line number
'
'���������������̭Π����������

13 changes: 8 additions & 5 deletions manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ present you with a little help text:
'
' Editor Help
' -----------
' Ctrl-A : Move to beg of line
' Ctrl-A : Move to begining of line
' Ctrl-E : Move to end of line
' Ctrl-U : Page up
' Ctrl-V : Page down
' Ctrl-Z : Undo (only curr line)
' Ctrl-M : Set Mark to curr line
' Ctrl-U / Ctrl-V : Page up / down
' Ctrl-Z : Undo (only current line)
' Ctrl-M : Set Mark to current line
' Ctrl-C : Copy from Mark to here
' Ctrl-Q : Exit to DOS
' Ctrl-S : Save file
' Ctrl-L : Load file
' Ctrl-N : New file
' Ctrl-R : Parse and run program
' Ctrl-W : Compile to binary file
' Ctrl-G : Go to line number
'
'- Press CONTROL-N to begin -

Expand Down Expand Up @@ -202,6 +202,9 @@ above.
Moves the cursor 19 lines up or down
respectively.

- `CONTROL-G`
Moves the cursor to a specific line.

- `CONTROL-Z`
Reverts all editing of the current
line. Note that changing the line
Expand Down
72 changes: 52 additions & 20 deletions src/editor.bas
Original file line number Diff line number Diff line change
Expand Up @@ -71,38 +71,58 @@ do
loop


'-------------------------------------
' Clears top line to show a message
'
PROC ClrTopLine
exec SaveLine
pos. 0,0
? "œ";
ENDPROC

'-------------------------------------
' Gets a filename with minimal line editing
' Edit top line for input
'
PROC InputFilename
' Show current filename:
? "? "; FileName$;
PROC InputLine
do
get key
if key <= 27
exit
' Accept left/right arrows, backspace and standard characters
if key >= 30 and key <= 124 or key = 126
put key
' Process ENTER
elif key = 155
pos. 6, 0
poke @CH, 12: ' Force ENTER
input ; FileName$
key = 0
exit
elif key >= 30 and key <= 124 or key = 126
put key
else
' Otherwise simply exit
exec ShowInfo
exit
endif
loop
exec ShowInfo
ENDPROC

'-------------------------------------
' Gets a filename with minimal line editing
'
PROC InputFilename
' Show current filename:
? "? "; FileName$;
exec InputLine
if not key
input ; FileName$
exec ShowInfo
endif
ENDPROC

'-------------------------------------
' Compile (and run) file
PROC CompileFile
' Compile main file
exec SaveLine
exec ClrTopLine
? "Parsing: ";
poke MemEnd, $9B
pos. 1,0
? "œParsing: ";
if USR( @compile_buffer, key, Adr(MemStart), MemEnd+1)
' Parse error, go to error line
topLine = dpeek(@@linenum) - 11
Expand Down Expand Up @@ -258,9 +278,8 @@ ENDPROC
' Save edited file
'
PROC AskSaveFile
exec SaveLine
pos. 0, 0
? "œSave";
exec ClrTopLine
? "Save";
exec InputFileName
if key
' Don't save
Expand Down Expand Up @@ -943,14 +962,26 @@ PROC ProcessKeys
elif key = $0C
exec AskSaveFileChanged
if not key
pos. 0, 0
? "œLoad";
exec ClrTopLine
? "Load";
exec InputFileName
if not key
exec LoadFile
endif
endif
'
'--------- Control-G (go to line) -----
elif key = $07
exec ClrTopLine
? "Line? ";
exec InputLine
if not key
input ; topLine
topLine = abs(topLine - 1)
scrLine = 0
exec CalcRedrawScreen
endif
'
'--------- Control-Z (undo) -----
elif key = $1A
exec UndoEditLine
Expand All @@ -974,12 +1005,13 @@ ENDPROC
' Save compiled file
'
PROC SaveCompiledFile
exec ClrTopLine

' Save original filename
move Adr(FileName$), EditBuf, 128
poke Len(FileName$) + Adr(FileName$), $58

pos. 0, 0
? "œName";
? "Name";
exec InputFileName
if key
' Don't save
Expand Down

0 comments on commit 95bb9dd

Please sign in to comment.