mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 00:32:44 +00:00
548 lines
12 KiB
Plaintext
548 lines
12 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF bin/edit
|
||
*--------------------------------------
|
||
FILEBUF.SIZE .EQ 2048
|
||
*--------------------------------------
|
||
.INB inc/macros.i
|
||
.INB inc/a2osx.i
|
||
.INB inc/mli.i
|
||
.INB inc/mli.e.i
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
BufPtr .BS 2
|
||
BufPtrDst .BS 2
|
||
ClipboardPtr .BS 2
|
||
LineBufPtr .BS 2
|
||
|
||
BUF.LOffset .BS 2
|
||
BUF.COffset .BS 2
|
||
BUF.TmpLine1 .BS 2
|
||
BUF.TmpLine2 .BS 2
|
||
|
||
FileLen .BS 2
|
||
BufLen .BS 2
|
||
SelLen .BS 2
|
||
ZPPTR1 .BS 2
|
||
|
||
bRepaint .BS 1
|
||
bSelected .BS 1
|
||
|
||
ZPPTR2 .EQ *
|
||
TmpLen .BS 2
|
||
|
||
TmpIndex .BS 2
|
||
TmpCount .BS 1
|
||
TmpByte .BS 1
|
||
|
||
ZS.END .ED
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA #S.PS.F.EVENT S.PS.F
|
||
.DA #0
|
||
.DA CS.END-CS.START CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #64 SS
|
||
.DA #ZS.END-ZS.START Zero Page Size
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.SEQ.INIT .DA SEQ.INIT
|
||
L.SEQ.SCROLLRGN .DA SEQ.SCROLLRGN
|
||
L.SEQ.RESET .DA SEQ.RESET
|
||
L.SEQ.SCROLLUP .DA SEQ.SCROLLUP
|
||
L.SEQ.SCROLLDN .DA SEQ.SCROLLDN
|
||
L.SEQ.SCROLLCURUP .DA SEQ.SCROLLCURUP
|
||
L.SEQ.SCROLLCURDN .DA SEQ.SCROLLCURDN
|
||
L.SEQ.EDIT .DA SEQ.EDIT
|
||
L.MSG.TERMCAP .DA MSG.TERMCAP
|
||
L.MSG.TOPBAR .DA MSG.TOPBAR
|
||
L.MSG.FILETYPES .DA MSG.TXTCR
|
||
.DA MSG.TXTCRLF
|
||
.DA MSG.ASM
|
||
L.MSG.STATUSBAR .DA MSG.STATUSBAR
|
||
L.MSG.STATUSBAR.H .DA MSG.STATUSBAR.H
|
||
L.MSG.STATUSBAR.U .DA MSG.STATUSBAR.U
|
||
L.MSG.STATUSBAR.S .DA MSG.STATUSBAR.S
|
||
L.MSG.STATUSBAR.E .DA MSG.STATUSBAR.E
|
||
L.MSG.NEWFILE .DA MSG.NEWFILE
|
||
L.MSG.GOTOXY .DA MSG.GOTOXY
|
||
L.MSG.HELPLINE .DA MSG.HELPLINE
|
||
L.MSG.HELP .DA MSG.HELP
|
||
J.SAVE .DA FILE.Save.CR
|
||
.DA FILE.Save.CRLF
|
||
.DA FILE.Save.ASM
|
||
J.CTRL .DA Ctrl.Invalid
|
||
.DA Ctrl.A
|
||
.DA Ctrl.B
|
||
.DA Ctrl.C
|
||
.DA Ctrl.D
|
||
.DA Ctrl.E
|
||
.DA Ctrl.F
|
||
.DA Ctrl.G
|
||
.DA Ctrl.BS
|
||
.DA Ctrl.TAB
|
||
.DA Ctrl.LF
|
||
.DA Ctrl.VT
|
||
.DA Ctrl.L
|
||
.DA Ctrl.CR
|
||
.DA Ctrl.N
|
||
.DA Ctrl.O
|
||
.DA Ctrl.P
|
||
.DA Ctrl.Q
|
||
.DA Ctrl.R
|
||
.DA Ctrl.S
|
||
.DA Ctrl.T
|
||
.DA Ctrl.FS
|
||
.DA Ctrl.V
|
||
.DA Ctrl.W
|
||
.DA Ctrl.X
|
||
.DA Ctrl.Y
|
||
.DA Ctrl.Z
|
||
.DA Ctrl.Invalid
|
||
.DA Ctrl.Invalid
|
||
.DA Ctrl.Invalid
|
||
.DA Ctrl.Invalid
|
||
.DA Ctrl.Invalid
|
||
L.DLG.SAVE .DA DLG.SAVE
|
||
L.DLG.FIND .DA DLG.FIND
|
||
J.DLG.CTRL.Draw .DA DLG.CTRL.Draw.LBL
|
||
.DA DLG.CTRL.Draw.TB
|
||
.DA DLG.CTRL.Draw.OL
|
||
.DA DLG.CTRL.Draw.BUT
|
||
J.DLG.CTRL.Focus
|
||
.DA DLG.CTRL.Focus.LBL
|
||
.DA DLG.CTRL.Focus.TB
|
||
.DA DLG.CTRL.Focus.OL
|
||
.DA DLG.CTRL.Focus.BUT
|
||
J.DLG.CTRL.GetWitdh
|
||
.DA DLG.CTRL.GetWitdh.LBL
|
||
.DA DLG.CTRL.GetWitdh.TB
|
||
.DA DLG.CTRL.GetWitdh.OL
|
||
.DA DLG.CTRL.GetWitdh.BUT
|
||
J.DLG.CTRL.CharIn
|
||
.DA DLG.CTRL.CharIn.LBL
|
||
.DA DLG.CTRL.CharIn.TB
|
||
.DA DLG.CTRL.CharIn.OL
|
||
.DA DLG.CTRL.CharIn.BUT
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
CS.INIT.RTS rts
|
||
*--------------------------------------
|
||
CS.RUN >PUSHW L.MSG.TERMCAP
|
||
>PUSHBI 0
|
||
>SYSCALL PrintF Send Query for term W & H
|
||
bcs CS.INIT.RTS
|
||
|
||
.1 jsr IO.GetCh
|
||
bcs CS.INIT.RTS
|
||
|
||
>LDA.G ScreenW Wait for Response from terminal for W & H
|
||
beq .1
|
||
|
||
jsr SCRN.Init
|
||
|
||
>LDYAI 510+5+5+4+1 potentially 255*\\ NORM,INV,CEOL & \0
|
||
>SYSCALL GetMem
|
||
bcs CS.INIT.RTS
|
||
|
||
>STYA.G LineBufBase
|
||
txa
|
||
>STA.G hLineBuf
|
||
|
||
lda #1
|
||
>SYSCALL ArgV
|
||
bcs .2 No arg, new file....
|
||
|
||
jsr FILE.Load
|
||
bcc .3 if CS, Failed to load file, keep name, but new file....
|
||
|
||
cmp #E.OOM
|
||
beq CS.RUN.RTS
|
||
|
||
bra .3
|
||
|
||
.2 jsr FILE.New
|
||
bcs CS.RUN.RTS
|
||
|
||
.3 jsr SCRN.Repaint
|
||
bcs CS.RUN.RTS
|
||
|
||
jsr CS.RUN.GetBuf64
|
||
bcs CS.RUN.RTS
|
||
|
||
>STA.G hFind
|
||
|
||
jsr CS.RUN.GetBuf64
|
||
bcs CS.RUN.RTS
|
||
|
||
>STA.G hReplace
|
||
*--------------------------------------
|
||
CS.RUN.LOOP jsr IO.GetCh
|
||
bcs CS.RUN.RTS I/O error
|
||
|
||
beq .8
|
||
|
||
jsr CS.RUN.LOOP.CharIn
|
||
bcs .9
|
||
|
||
.8 >LDA.G bExit
|
||
bpl CS.RUN.LOOP
|
||
|
||
lda #0
|
||
|
||
.9 pha
|
||
>PUSHW L.SEQ.RESET
|
||
>PUSHBI 0
|
||
>SYSCALL PrintF
|
||
pla
|
||
sec
|
||
CS.RUN.RTS rts
|
||
*--------------------------------------
|
||
CS.RUN.LOOP.CharIn
|
||
cmp #C.DEL
|
||
bne .1
|
||
|
||
jmp Ctrl.DEL
|
||
|
||
.1 cmp #C.SPACE
|
||
bcc .2
|
||
|
||
jsr BUF.InsertA
|
||
bcs .9
|
||
|
||
jsr SCRN.UpdateCurrentEOL
|
||
bcs .9
|
||
|
||
jmp Ctrl.FS
|
||
|
||
.2 asl
|
||
tax
|
||
jmp (J.CTRL,x)
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.GetBuf64 >LDYAI 64
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
|
||
>STYA ZPPTR1
|
||
|
||
lda #0
|
||
sta (ZPPTR1)
|
||
|
||
txa
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.DOEVENT lda (pEvent)
|
||
bpl .9 is it a TIMER event?
|
||
|
||
asl
|
||
bpl .9
|
||
|
||
>STA.G bUpdateStatus
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT ldy #hLineBuf
|
||
jsr .7
|
||
|
||
ldy #hBuf
|
||
jsr .7
|
||
|
||
ldy #hBufBackup
|
||
jsr .7
|
||
|
||
ldy #hClipBoard
|
||
jsr .7
|
||
|
||
ldy #hFileName
|
||
jsr .7
|
||
|
||
ldy #hFind
|
||
jsr .7
|
||
|
||
ldy #hReplace
|
||
|
||
.7 lda (pData),y
|
||
beq .8
|
||
|
||
>SYSCALL FreeMem
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
.INB usr/src/bin/edit.s.buf
|
||
.INB usr/src/bin/edit.s.ctrl
|
||
.INB usr/src/bin/edit.s.dlg
|
||
.INB usr/src/bin/edit.s.file
|
||
.INB usr/src/bin/edit.s.io
|
||
.INB usr/src/bin/edit.s.scrn
|
||
*--------------------------------------
|
||
CS.END
|
||
SEQS .EQ *
|
||
SEQ.BAR .CZ "\e[7m\e[37;40m"
|
||
SEQ.DLG.TBAR .CS "\e[0m\e[93;104m"
|
||
.DA #C.SO,#'l',#C.SI
|
||
.CZ "\e[7m\e[37;40m"
|
||
SEQ.DLG.TBAR.E .CS "\e[0m\e[93;104m"
|
||
.DA #C.SO,#'k',#C.SI
|
||
.DA #0
|
||
SEQ.DLG .CS "\e[93;104m"
|
||
.DA #C.SO,#'x',#C.SI
|
||
.DA #0
|
||
SEQ.DLG.VBAR .CS "\e[93;104m"
|
||
.DA #C.SO,#'x',#C.SI
|
||
.DA #0
|
||
SEQ.DLG.SBAR .CS "\e[0m\e[93;104m"
|
||
.DA #C.SO,#'m',#C.SI
|
||
.CZ "\e[7m\e[37;40m"
|
||
SEQ.DLG.SBAR.E .CS "\e[0m\e[93;104m"
|
||
.DA #C.SO,#'j',#C.SI
|
||
.DA #0
|
||
SEQ.DLG.LBL .CZ "\e[0m\e[30;104m"
|
||
SEQ.DLG.TB .CZ "\e[0m\e[93;44m"
|
||
SEQ.DLG.BUT .CZ "\e[7m\e[93;44m"
|
||
SEQ.EDIT .CS "\e[0m\e[93;44m" +CEOL
|
||
SEQ.CEOL .CZ "\e[K"
|
||
SEQ.NORM .CZ "\e[0m"
|
||
SEQ.INV .CZ "\e[7m"
|
||
SEQ.CURSAVE .CZ "\e7"
|
||
SEQ.CURRESTORE .CZ "\e8"
|
||
*--------------------------------------
|
||
SEQ.INIT .CS "\ec"
|
||
.CS "\e(B" font select
|
||
.CS "\e)0" font select
|
||
.CZ "\e[?7l" Disable Line Wrap
|
||
SEQ.RESET .CZ "\ec\e[?7h" Enable Line Wrap
|
||
*--------------------------------------
|
||
SEQ.SCROLLRGN .CZ "\e[2;%dr"
|
||
SEQ.SCROLLCURUP .CS "\e[%d;%dr"
|
||
SEQ.SCROLLUP .CZ "\eD"
|
||
SEQ.SCROLLCURDN .CS "\e[%d;%dr"
|
||
SEQ.SCROLLDN .CZ "\eM"
|
||
*--------------------------------------
|
||
MSG.TERMCAP .CZ "\r\n\e[999;999H\e[6n"
|
||
MSG.TOPBAR .CZ "A2osX Edit %d.%d:%s (%s)"
|
||
MSG.TXTCR .CZ "TXT/CR"
|
||
MSG.TXTCRLF .CZ "TXT/CRLF"
|
||
MSG.ASM .CZ "ASM"
|
||
MSG.STATUSBAR .CZ "Press Ctrl-A For Help Len:%5D Pos:%5D Col:%3d Line:%5D"
|
||
MSG.STATUSBAR.H .CZ "Press any key to exit this screen "
|
||
MSG.STATUSBAR.U .CZ "Quit without Saving [Y/N] ? "
|
||
MSG.STATUSBAR.S .CZ "%s Saved."
|
||
MSG.STATUSBAR.E .CZ "Error:%h"
|
||
MSG.GOTOXY .CZ "\e[%d;%dH"
|
||
MSG.HELPLINE .CZ "\e[0m\e[93;44m%S\e[K"
|
||
*--------------------------------------
|
||
MSG.HELP .PS "All commands:"
|
||
.PS "-------------"
|
||
.PS " Ctrl-A : This help screen"
|
||
.PS " Ctrl-B : Mark beginning of selection"
|
||
.PS " Ctrl-C : Copy selection to clipboard"
|
||
.PS " Ctrl-D : Delete selection"
|
||
.PS " Ctrl-E : Mark end of selection"
|
||
.PS " Ctrl-F : Find/Replace..."
|
||
.PS " Ctrl-G : Go to start of current line"
|
||
.PS " Ctrl-L : Go to end of current line"
|
||
.PS " Ctrl-N : Find next"
|
||
.PS " Ctrl-O : Page up"
|
||
.PS " Ctrl-P : Page down"
|
||
.PS " Ctrl-Q : Quit"
|
||
.PS " Ctrl-R : Replace next"
|
||
.PS " Ctrl-S : Save file..."
|
||
.PS " Ctrl-T : Go to top of file"
|
||
.PS " Ctrl-V : Paste clipboard at cursor position"
|
||
.PS " Ctrl-W : Erase current line"
|
||
.PS " Ctrl-X : Cut block to clipboard"
|
||
.PS " Ctrl-Y : Go to end of file"
|
||
.PS " Ctrl-Z : Erase char under cursor"
|
||
.HS 00
|
||
*--------------------------------------
|
||
MSG.NEWFILE .AZ "newfile"
|
||
EscChars .AS "DABC"
|
||
EscChars.Cnt .EQ *-EscChars
|
||
EscAscii .DA #C.BS,#C.VT,#C.LF,#21
|
||
*--------------------------------------
|
||
S.DLG.Size .EQ 0
|
||
S.DLG.X .EQ 1
|
||
S.DLG.Y .EQ 2
|
||
S.DLG.W .EQ 3
|
||
S.DLG.H .EQ 4
|
||
S.DLG.Title .EQ 5
|
||
S.DLG.Status .EQ 6
|
||
S.DLG.Focus .EQ 7
|
||
S.DLG.Ctrls .EQ 8
|
||
S.DLG.Ctrl.LBL .EQ 0
|
||
S.DLG.Ctrl.TB .EQ 2
|
||
S.DLG.Ctrl.OL .EQ 4
|
||
S.DLG.Ctrl.BUT .EQ 6
|
||
*--------------------------------------
|
||
DLG.SAVE .DA #DLG.SAVE.LEN Size
|
||
.DA #0 X
|
||
.DA #0 Y
|
||
.DA #70 W
|
||
.DA #11 H
|
||
.DA #DLG.SAVE.T-DLG.SAVE Title
|
||
.DA #DLG.SAVE.S-DLG.SAVE Status
|
||
|
||
.DA #9 Focus
|
||
.DA #DLG.SAVE.1-DLG.SAVE
|
||
.DA #DLG.SAVE.2-DLG.SAVE
|
||
.DA #DLG.SAVE.3-DLG.SAVE
|
||
.DA #DLG.SAVE.4-DLG.SAVE
|
||
.DA #DLG.SAVE.5-DLG.SAVE
|
||
.DA #DLG.SAVE.6-DLG.SAVE
|
||
.DA #DLG.SAVE.7-DLG.SAVE
|
||
.DA #DLG.SAVE.8-DLG.SAVE
|
||
.DA #0
|
||
|
||
DLG.SAVE.1 .DA #S.DLG.Ctrl.LBL,#2,#2
|
||
.AZ "Filename :"
|
||
|
||
DLG.SAVE.2 .DA #S.DLG.Ctrl.TB,#2,#3
|
||
.DA #0,#64,#hFileName CURPOS,MAXCHAR,hMem
|
||
|
||
DLG.SAVE.3 .DA #S.DLG.Ctrl.LBL,#2,#5
|
||
.AZ "Filetype :"
|
||
|
||
DLG.SAVE.4 .DA #S.DLG.Ctrl.OL,#2,#6
|
||
.DA #18 Ctrl-R
|
||
.DA #FileType
|
||
.DA #0
|
||
.AZ "TXT/CR"
|
||
|
||
DLG.SAVE.5 .DA #S.DLG.Ctrl.OL,#13,#6
|
||
.DA #12 Ctrl-L
|
||
.DA #FileType
|
||
.DA #1
|
||
.AZ "TXT/CRLF"
|
||
|
||
DLG.SAVE.6 .DA #S.DLG.Ctrl.OL,#26,#6
|
||
.DA #1 Ctrl-A
|
||
.DA #FileType
|
||
.DA #2
|
||
.AZ "ASM"
|
||
|
||
DLG.SAVE.7 .DA #S.DLG.Ctrl.BUT,#40,#8
|
||
.DA #C.CR
|
||
.AZ " Save "
|
||
|
||
DLG.SAVE.8 .DA #S.DLG.Ctrl.BUT,#52,#8
|
||
.DA #3 Ctrl-C
|
||
.AZ " Cancel "
|
||
|
||
DLG.SAVE.T .AZ "Save As..." Title
|
||
DLG.SAVE.S .AZ "CR:Save, Ctrl-R/L/A:Change Type, Ctrl-C:Cancel"
|
||
DLG.SAVE.LEN .EQ *-DLG.SAVE
|
||
*--------------------------------------
|
||
DLG.FIND .DA #DLG.FIND.LEN Size
|
||
.DA #0 X
|
||
.DA #0 Y
|
||
.DA #70 W
|
||
.DA #11 H
|
||
.DA #DLG.FIND.T-DLG.FIND Title
|
||
.DA #DLG.FIND.S-DLG.FIND Status
|
||
|
||
.DA #9 Focus
|
||
.DA #DLG.FIND.1-DLG.FIND
|
||
.DA #DLG.FIND.2-DLG.FIND
|
||
.DA #DLG.FIND.3-DLG.FIND
|
||
.DA #DLG.FIND.4-DLG.FIND
|
||
.DA #DLG.FIND.5-DLG.FIND
|
||
.DA #DLG.FIND.6-DLG.FIND
|
||
.DA #0
|
||
|
||
DLG.FIND.1 .DA #S.DLG.Ctrl.LBL,#2,#2
|
||
.AZ "Find :"
|
||
|
||
DLG.FIND.2 .DA #S.DLG.Ctrl.TB,#2,#3
|
||
.DA #0,#63,#hFind
|
||
|
||
DLG.FIND.3 .DA #S.DLG.Ctrl.LBL,#2,#5
|
||
.AZ "Replace :"
|
||
|
||
DLG.FIND.4 .DA #S.DLG.Ctrl.TB,#2,#6
|
||
.DA #0,#63,#hReplace
|
||
|
||
DLG.FIND.5 .DA #S.DLG.Ctrl.BUT,#40,#8
|
||
.DA #C.CR
|
||
.AZ " Find "
|
||
|
||
DLG.FIND.6 .DA #S.DLG.Ctrl.BUT,#52,#8
|
||
.DA #3 Ctrl-C
|
||
.AZ " Cancel "
|
||
|
||
DLG.FIND.T .AZ "Find/Replace..." Title
|
||
DLG.FIND.S .AZ "CR:Find, Ctrl-C:Cancel"
|
||
DLG.FIND.LEN .EQ *-DLG.FIND
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
EscBuffer .BS 16
|
||
|
||
bEscMode .BS 1
|
||
bCSIMode .BS 1
|
||
bExit .BS 1
|
||
bUnSaved .BS 1
|
||
|
||
bUpdateStatus .BS 1
|
||
|
||
hFileName .BS 1
|
||
FileType .BS 1
|
||
|
||
hFind .BS 1
|
||
hReplace .BS 1
|
||
|
||
hLineBuf .BS 1
|
||
LineBufBase .BS 2
|
||
|
||
hBuf .BS 1
|
||
BufBase .BS 2
|
||
hBufBackup .BS 1
|
||
hClipBoard .BS 1
|
||
ClipBoardLen .BS 2
|
||
|
||
SelStart .BS 2
|
||
SelEnd .BS 2
|
||
|
||
ScreenW .BS 1
|
||
ScreenH .BS 1
|
||
ViewPortH .BS 1
|
||
ViewPortHm1 .BS 1
|
||
FileX .BS 1
|
||
FileY .BS 2
|
||
ScreenX .BS 1
|
||
ScreenY .BS 2
|
||
CurX .BS 1
|
||
CurY .BS 1
|
||
|
||
hDLG .BS 1
|
||
|
||
STATBUF .BS S.STAT
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/edit.s
|
||
ASM
|