mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
Added Back command line History
This commit is contained in:
parent
11591911b9
commit
0c3f235d13
144
SBIN/SHELL.S.txt
144
SBIN/SHELL.S.txt
@ -56,13 +56,18 @@ T.INTCMDS .DA EXEC.CMD.CD
|
|||||||
CS.INIT lda #0
|
CS.INIT lda #0
|
||||||
ldy #bEXIT
|
ldy #bEXIT
|
||||||
sta (pData),y
|
sta (pData),y
|
||||||
ldy #CmdHistory
|
|
||||||
sta (pData),y
|
|
||||||
ldy #CmdHistory.IDX
|
ldy #CmdHistory.IDX
|
||||||
sta (pData),y
|
sta (pData),y
|
||||||
ldy #CmdHistory.END
|
ldy #CmdHistory.END
|
||||||
sta (pData),y
|
sta (pData),y
|
||||||
|
|
||||||
|
>PUSHWI 256 Get a buffer for History
|
||||||
|
>PUSHBI S.MEM.F.INIT0
|
||||||
|
>SYSCALL SYS.GetMem
|
||||||
|
bcs .99
|
||||||
|
|
||||||
|
stx hCmdHistory
|
||||||
|
|
||||||
>LDYA L.LIBSTR
|
>LDYA L.LIBSTR
|
||||||
>LOADLIBYA
|
>LOADLIBYA
|
||||||
bcs .99
|
bcs .99
|
||||||
@ -95,11 +100,9 @@ CS.RUN lda #0
|
|||||||
lda #" "
|
lda #" "
|
||||||
jsr COUT
|
jsr COUT
|
||||||
|
|
||||||
.1 lda (pData)
|
.1 jsr A2osX.SLEEP
|
||||||
bmi .2
|
lda (pData)
|
||||||
jsr A2osX.SLEEP
|
bpl .1
|
||||||
|
|
||||||
bra .1
|
|
||||||
|
|
||||||
.2 and #$7F
|
.2 and #$7F
|
||||||
sta (pData)
|
sta (pData)
|
||||||
@ -111,7 +114,7 @@ CS.RUN lda #0
|
|||||||
|
|
||||||
ldy #hCMDLINE
|
ldy #hCMDLINE
|
||||||
sta (pData),y
|
sta (pData),y
|
||||||
* jsr HISTORY.ADD
|
jsr HISTORY.ADD
|
||||||
jsr EXEC.CMD
|
jsr EXEC.CMD
|
||||||
bcc .3
|
bcc .3
|
||||||
|
|
||||||
@ -214,14 +217,14 @@ CS.EVENT.CTRL.CHAR
|
|||||||
.2 cmp #10 LF (down arrow)
|
.2 cmp #10 LF (down arrow)
|
||||||
bne .3
|
bne .3
|
||||||
|
|
||||||
* jsr HISTORY.GETNEXT
|
jsr HISTORY.GETNEXT
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.3 cmp #11 VT (up arrow)
|
.3 cmp #11 VT (up arrow)
|
||||||
bne .4
|
bne .4
|
||||||
|
|
||||||
* jsr HISTORY.GETPREV
|
jsr HISTORY.GETPREV
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -235,7 +238,11 @@ CS.EVENT.CTRL.CHAR
|
|||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.QUIT lda hLIBSTR
|
CS.QUIT lda hCmdHistory
|
||||||
|
beq .1
|
||||||
|
>SYSCALL SYS.FreeMemA
|
||||||
|
|
||||||
|
.1 lda hLIBSTR
|
||||||
>SYSCALL SYS.UnloadLibA
|
>SYSCALL SYS.UnloadLibA
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
@ -487,46 +494,73 @@ EXEC.CMD.EXIT ldy #bEXIT
|
|||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
HISTORY.ADD lda CmdHistory.END ending 0
|
HISTORY.ADD lda hCmdHistory
|
||||||
|
>SYSCALL SYS.GetMemPtrA
|
||||||
|
>STYA ZPPTR1
|
||||||
|
|
||||||
|
.10 lda CmdHistory.END ending 0
|
||||||
inc keep room for new ending 0
|
inc keep room for new ending 0
|
||||||
sec add len+1
|
sec add len+1
|
||||||
adc CmdBuffer
|
adc (pData) CmdBuffer
|
||||||
bcc .2 enough room
|
bcc .2 enough room
|
||||||
|
|
||||||
ldx CmdHistory get len of oldest string
|
lda (ZPPTR1) get len of oldest string
|
||||||
ldy #0
|
sec
|
||||||
.1 inx
|
adc ZPPTR1
|
||||||
iny
|
sta ZPPTR2
|
||||||
lda CmdHistory,x move back until 0 found
|
lda ZPPTR1+1
|
||||||
sta CmdHistory-1,y
|
adc #0
|
||||||
bne .1
|
sta ZPPTR2+1
|
||||||
sty CmdHistory.END mark new end of history
|
|
||||||
bra HISTORY.ADD retry....
|
|
||||||
|
|
||||||
.2 ldx CmdHistory.END
|
|
||||||
ldy #$FF
|
ldy #$FF
|
||||||
.3 iny
|
|
||||||
lda CmdBuffer,y
|
.1 iny
|
||||||
sta CmdHistory,x
|
lda (ZPPTR2),y move back until 0 found
|
||||||
inx
|
sta (ZPPTR1),y
|
||||||
cpy CmdBuffer
|
bne .1
|
||||||
bne .3
|
|
||||||
stz CmdHistory,x set ending 0
|
sty CmdHistory.END mark new end of history
|
||||||
stx CmdHistory.IDX
|
bra .10 retry....
|
||||||
stx CmdHistory.END
|
|
||||||
|
.2 ldy CmdHistory.END
|
||||||
|
lda (pData)
|
||||||
|
tax
|
||||||
|
lda pData
|
||||||
|
sta ZPPTR2
|
||||||
|
lda pData+1
|
||||||
|
sta ZPPTR2+1
|
||||||
|
|
||||||
|
.3 lda (ZPPTR2)
|
||||||
|
sta (ZPPTR1),y
|
||||||
|
inc ZPPTR2
|
||||||
|
bne .4
|
||||||
|
inc ZPPTR2+1
|
||||||
|
.4 iny
|
||||||
|
dex
|
||||||
|
bpl .3
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta (ZPPTR1),y set ending 0
|
||||||
|
sty CmdHistory.IDX
|
||||||
|
sty CmdHistory.END
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
HISTORY.GETPREV lda CmdHistory.END
|
HISTORY.GETPREV lda CmdHistory.END
|
||||||
beq HISTORY.RTS empty history,nothing to do
|
beq HISTORY.RTS empty history,nothing to do
|
||||||
lda CmdHistory.IDX
|
lda CmdHistory.IDX
|
||||||
beq HISTORY.RTS already oldest,nothing to do
|
beq HISTORY.RTS already oldest,nothing to do
|
||||||
|
|
||||||
|
lda hCmdHistory
|
||||||
|
>SYSCALL SYS.GetMemPtrA
|
||||||
|
>STYA ZPPTR1
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
.1 tax save current index
|
.1 tay save current index
|
||||||
sec
|
sec
|
||||||
adc CmdHistory,x
|
adc (ZPPTR1),y
|
||||||
cmp CmdHistory.IDX
|
cmp CmdHistory.IDX
|
||||||
bne .1 not yet reached current index
|
bne .1 not yet reached current index
|
||||||
stx CmdHistory.IDX set new index
|
sty CmdHistory.IDX set new index
|
||||||
bra HISTORY.SETBUF
|
bra HISTORY.SETBUF
|
||||||
HISTORY.RTS rts
|
HISTORY.RTS rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
@ -534,8 +568,13 @@ HISTORY.GETNEXT ldx CmdHistory.END
|
|||||||
beq HISTORY.RTS empty history,nothing to do
|
beq HISTORY.RTS empty history,nothing to do
|
||||||
cpx CmdHistory.IDX
|
cpx CmdHistory.IDX
|
||||||
beq HISTORY.RTS
|
beq HISTORY.RTS
|
||||||
ldx CmdHistory.IDX
|
|
||||||
lda CmdHistory,x
|
lda hCmdHistory
|
||||||
|
>SYSCALL SYS.GetMemPtrA
|
||||||
|
>STYA ZPPTR1
|
||||||
|
|
||||||
|
ldy CmdHistory.IDX
|
||||||
|
lda (ZPPTR1),y
|
||||||
sec
|
sec
|
||||||
adc CmdHistory.IDX
|
adc CmdHistory.IDX
|
||||||
cmp CmdHistory.END
|
cmp CmdHistory.END
|
||||||
@ -543,15 +582,26 @@ HISTORY.GETNEXT ldx CmdHistory.END
|
|||||||
beq CmdBuffer.CLR end of history, just blank buffer
|
beq CmdBuffer.CLR end of history, just blank buffer
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
HISTORY.SETBUF jsr CmdBuffer.CLR
|
HISTORY.SETBUF jsr CmdBuffer.CLR
|
||||||
ldx CmdHistory.IDX
|
|
||||||
ldy #$ff
|
lda pData
|
||||||
.1 iny
|
sta ZPPTR2
|
||||||
lda CmdHistory,x
|
lda pData+1
|
||||||
inx
|
sta ZPPTR2+1
|
||||||
sta CmdBuffer,y
|
|
||||||
cpy CmdBuffer
|
ldy CmdHistory.IDX
|
||||||
bne .1
|
lda (ZPPTR1),y
|
||||||
bra CmdBuffer.PRINT
|
tax
|
||||||
|
|
||||||
|
.1 lda (ZPPTR1),y
|
||||||
|
sta (ZPPTR2)
|
||||||
|
|
||||||
|
inc ZPPTR2
|
||||||
|
bne .2
|
||||||
|
inc ZPPTR2+1
|
||||||
|
|
||||||
|
.2 iny
|
||||||
|
dex
|
||||||
|
bpl .1
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CmdBuffer.PRINT ldy #0
|
CmdBuffer.PRINT ldy #0
|
||||||
.1 iny
|
.1 iny
|
||||||
@ -631,7 +681,7 @@ bEXIT .BS 1
|
|||||||
hCMDLINE .BS 1
|
hCMDLINE .BS 1
|
||||||
hCMD .BS 1
|
hCMD .BS 1
|
||||||
hARGS .BS 1
|
hARGS .BS 1
|
||||||
CmdHistory .BS 256
|
hCmdHistory .BS 1
|
||||||
CmdHistory.IDX .BS 1
|
CmdHistory.IDX .BS 1
|
||||||
CmdHistory.END .BS 1
|
CmdHistory.END .BS 1
|
||||||
DS.END
|
DS.END
|
||||||
|
Loading…
Reference in New Issue
Block a user