📄 edinsert.asm
字号:
lea bx,[di+size LineHeader-1]
add bx,es:[di].LineLength
mov si,bx
mov es:[si],al
call NoteRedraw
Invoke ShiftRight
inc si
mov bx,si
Invoke CalcColumn
Invoke SetEditDS
mov ds:CursorPos.X,ax
clc
@@12: ret
CharIntoPage endp
loc H,dword,1
Entry LineToPrevPage
mov bx,ds:CurPage
cmp bx,offset PageTbl
jbe @@2
Invoke LockCurPage
jc @@2
mov bx,ds:CurPage
les bx,[bx-size PageInfo].PageHandle
mov H.Offs,bx
mov H.Segm,es
mov ax,es:[bx]
cmp ax,VMemLimit
ja @@1
push es bx
push es bx
SetTurboDS
Invoke UseHandle
Invoke SetEditDS
pop bx es
mov ax,es:[bx]
cmp ax,VMemLimit
ja @@1
InvokeJ ErrorExit
@@1: mov bx,ds:CurPage
mov ax,ds:PageSize
sub ax,[bx-size PageInfo].pageLength
jbe @@2
les si,ds:LockedPage
mov es,es:[si]
mov cx,es:[size PageHeader].LineLength
add cx,size LineHeader+1
and cl,0feh
cmp ax,cx
jae @@3
@@2: stc
jmp @@4
@@3: Invoke StoreLinesInfo
les bx,H
mov es,es:[bx]
mov bx,ds:CurPage
sub bx,size PageInfo
Invoke StoreLinesInfo
add bx,size PageInfo
inc word ptr [bx-size PageInfo].LinesInPage
dec word ptr [bx].LinesInPage
mov di,[bx-size PageInfo].PageLength
add [bx-size PageInfo].PageLength,cx
sub [bx].PageLength,cx
mov bx,[bx].PageLength
push ds
lds si,ds:LockedPage
mov ds,[si]
mov si,size PageHeader
cld
shr cx,1
rep movsw
push ds
pop es
mov di,size PageHeader
mov ds:CurLineNum,-1
mov cx,bx
sub cx,di
shr cx,1
rep movsw
pop ds
inc ds:CPFirstLine
clc
@@4: Exit LineToPrevPage
loc H,dword,1
Entry LineToNextPage
call UseTwoPages
jc @@3
mov H.Offs,ax
mov H.Segm,dx
mov ax,ds:PageSize
sub ax,[bx+size PageInfo].PageLength
jbe @@3
les si,ds:LockedPage
mov es,es:[si]
mov cx,[bx].PageLength
mov si,cx
mov bx,size PageHeader
mov dx,bx
@@1: cmp bx,si
jae @@2
mov dx,bx
add bx,es:[bx].LineLength
add bx,size LineHeader+1
and bl,0feh
loop @@1
@@2: sub bx,dx
cmp ax,bx
jae @@4
@@3: jmp @@5
@@4: mov ax,bx
les bx,H
mov es,es:[bx]
mov bx,ds:CurPage
add bx,size PageInfo
Invoke StoreLinesInfo
mov bx,ds:CurPage
mov si,[bx+size PageInfo].PageLength
inc word ptr [bx+size PageInfo].LinesInPage
add [bx+size PageInfo].PageLength,ax
dec word ptr [bx].LinesInPage
sub [bx].PageLength,ax
push ds
push es
pop ds
mov ds:CurLineNum,-1
mov cx,si
sub cx,size PageHeader
shr cx,1
dec si
dec si
mov bx,ax
lea di,[bx+si]
std
rep movsw
pop ds
push ds
lds si,ds:LockedPage
mov ds,[si]
mov ds:CurLineNum,-1
mov si,dx
add si,bx
dec si
dec si
mov cx,bx
shr cx,1
rep movsw
cld
pop ds
clc
jmp @@6
@@5: stc
@@6: Exit LineToNextPage
Entry RestToNextPage
Invoke FindCurLine
Invoke UseCurPage
jc @@1
mov ax,ds:CurPage
mov si,ax
add ax,size PageInfo
cmp ax,ds:LastPage
jae @@1
mov cx,[si].PageLength
sub cx,bx
jbe @@2
mov ax,ds:PageSize
sub ax,[si+size PageInfo].PageLength
jbe @@1
cmp ax,cx
jb @@1
push bx cx
call UseTwoPages
pop cx bx
jnc @@3
@@1: jmp @@5
@@2: jmp @@4
@@3: mov si,bx
mov es,dx
mov bx,ax
mov es,es:[bx]
mov bx,ds:CurPage
add bx,size PageInfo
Invoke StoreLinesInfo
mov bx,si
mov si,ds:CurPage
mov dx,[si+size PageInfo].PageLength
xchg bx,[si].PageLength
add [si+size PageInfo].PageLength,cx
push ds
push es
pop ds
mov si,dx
mov di,si
add di,cx
push cx
mov cx,si
sub cx,size PageHeader
shr cx,1
std
dec si
dec si
dec di
dec di
rep movsw
pop cx
pop ds
push ds
lds si,ds:LockedPage
mov ds,[si]
mov si,bx
dec si
dec si
shr cx,1
rep movsw
cld
mov es:CurLineNum,-1
pop ds
mov ax,ds:CursorPos.Y
sub ax,ds:CPFirstLine
mov bx,ds:CurPage
xchg ax,[bx].LinesInPage
sub ax,[bx].LinesInPage
add [bx+size PageInfo].LinesInPage,ax
@@4: clc
jmp @@6
@@5: stc
@@6: Exit RestToNextPage
loc H,dword,1
Entry LineFromNextPage
call DeleteEmptyPages
jnc @@1
sub cx,cx
stc
jmp @@3
@@1: mov H.Offs,ax
mov H.Segm,dx
mov ax,ds:PageSize
sub ax,[bx].PageLength
jbe @@2
les si,H
mov es,es:[si]
mov cx,es:[size PageHeader].LineLength
add cx,size LineHeader+1
and cl,0feh
cmp ax,cx
jb @@2
les si,ds:LockedPage
mov es,es:[si]
Invoke StoreLinesInfo
les si,H
mov es,es:[si]
add bx,size PageInfo
Invoke StoreLinesInfo
Invoke SetEditDS
les si,H
mov es,es:[si]
sub bx,size PageInfo
mov di,[bx].PageLength
mov si,size PageHeader
mov dx,[bx+size PageInfo].PageLength
add [bx].PageLength,cx
inc [bx].LinesInPage
sub [bx+size PageInfo].PageLength,cx
dec [bx+size PageInfo].LinesInPage
push ds
push es
les bx,ds:LockedPage
mov es,es:[bx]
pop ds
cld
shr cx,1
rep movsw
push ds
pop es
mov di,size PageHeader
mov ds:CurLineNum,-1
mov cx,dx
sub cx,si
shr cx,1
rep movsw
pop ds
clc
jmp @@3
@@2: mov cx,1
stc
@@3: Exit LineFromNextPage
_Insert proc near
test ds:Options,eoOverwrite
jnz @@3
cmp byte ptr ds:CParam,0dh
jne @@1
Invoke TotalLines
Invoke SetEditDS
cmp ax,32767
jb @@2
mov ax,erTooManyLines
or ds:Errors,al
mov ds:ReturnCode,ax
stc
jmp @@14
@@1: Invoke FindCurLine
Invoke UseCurPage
jc @@3
cmp es:[bx].LineLength,4000
jle @@3
mov ax,erLineTooLong
or ds:Errors,al
mov ds:ReturnCode,ax
stc
jmp @@14
@@2: inc ax
@@3: mov cx,2
push cx
jmp @@5
@@4: push cx
Invoke CompactPages
@@5: mov cx,4
@@6: push cx
call CharIntoPage
jnc @@12
Invoke LineToPrevPage
jc @@7
call CharIntoPage
jnc @@12
jmp @@8
@@7: Invoke LineToNextPage
jnc @@9
call InsertEmptyPage
jnc @@9
@@8: Invoke InsertPage
jc @@10
Invoke LineToNextPage
jc @@10
@@9: pop cx
loop @@6
jmp @@11
@@10: pop cx
@@11: pop cx
loop @@4
stc
jmp @@13
@@12: pop cx
pop cx
sub ax,ax
@@13: Invoke SetEditDS
@@14: ret
_Insert endp
Entry InsertAllowUndo
push si di
Invoke CheckLine
Invoke SetEditDS
test ds:Options,eoUndoDisabled
jnz @@3
Invoke GoCurPos
Invoke UseCurPage
jc @@3
cmp di,bx
je @@1
mov ax,es:[di].LineLength
test ax,ax
jnz @@2
@@1: Invoke InvalidateUndo
@@2: Invoke UpdateUndo
@@3: call _Insert
pop di si
Exit InsertAllowUndo
Entry InsertAllowWS
push ds:Options
and ds:Options,not eoOverwrite
or ds:Options,eoUseTab+eoNoTruncate
Invoke InsertAllowUndo
Invoke SetEditDS
pop ds:Options
Exit InsertAllowWS
Entry TypeChar
push si di ds:Options
Invoke CheckLine
Invoke SetEditDS
test ds:Options,eoUndoDisabled
jnz @@3
Invoke GoCurPos
Invoke UseCurPage
jc @@1
cmp di,bx
je @@1
mov ax,es:[di].LineLength
test ax,ax
jnz @@2
@@1: Invoke InvalidateUndo
@@2: Invoke UpdateUndo
Invoke SetEditDS
@@3: cmp byte ptr ds:CParam,0dh
jne @@5
test ds:Options,eoAutoIndent
jz @@5
test ds:Options,eoOverwrite
jnz @@5
push ds:CursorPos.X
Invoke SkipWS
Invoke SetEditDS
pop ax
jcxz @@6
cmp ax,ds:CursorPos.X
jg @@6
push ds:CursorPos.X
mov ds:CursorPos.X,1
call _Insert
pop ds:CursorPos.X
@@4: jmp @@14
@@5: call _Insert
jmp @@4
@@6: mov ds:CursorPos.X,ax
call _Insert
jc @@4
push ds:CursorPos.Y
@@7: dec ds:CursorPos.Y
jz @@8
Invoke SkipWS
Invoke SetEditDS
jcxz @@7
@@8: pop ds:CursorPos.Y
Invoke FindCurLine
Invoke UseCurPage
cmp es:[bx].LineLength,0
je @@13
mov cx,ds:CursorPos.X
mov ds:CursorPos.X,1
dec cx
jz @@13
and ds:Options,not eoOverwrite
push cx
mov byte ptr ds:CParam,'x'
call _Insert
mov ds:CursorPos.X,1
pop cx
test ds:Options,eoUseTab
jz @@11
@@9: sub cx,ds:TabSize
jb @@10
push cx
mov byte ptr ds:CParam,9
call _Insert
pop cx
jc @@14
jmp @@9
@@10: add cx,ds:TabSize
jz @@12
@@11: push cx
mov byte ptr ds:CParam,' '
call _Insert
pop cx
jc @@14
loop @@11
@@12: Invoke DeleteChar
Invoke SetEditDS
@@13: clc
@@14: pop ds:Options di si
Exit TypeChar
Entry InsertNoOver
push ds:Options
and ds:Options,not eoOverwrite
Invoke InsertAllowUndo
Invoke SetEditDS
pop ds:Options
Exit InsertNoOver
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -