⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edinsert.asm

📁 Turbo Pascal 6.0编译器源码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	include	ed.inc

	.code

	extrn	DeleteEmptyPages:near,UseTwoPages:near

	Entry	InsertBuf
	sub	si,si
@@1:	les	bx,ds:LParam
	mov	al,es:[bx+si]
	cmp	al,0
	je	@@2
	mov	byte ptr ds:CParam,al
	push	si
	Invoke	InsertAllowWS
	Invoke	SetEditDS
	pop	si
	inc	si
	jmp	@@1
@@2:	Exit	InsertBuf

	Entry	InsertText
	push	ds:Options
	and	ds:Options,not eoOverwrite
	or	ds:Options,eoUseTab+eoNoTruncate
@@1:	Invoke	GetParam
	Invoke	SetEditDS
	cmp	al,0
	je	@@2
	mov	byte ptr ds:CParam,al
	Invoke	TypeChar
	Invoke	SetEditDS
	jmp	@@1
@@2:	pop	ds:Options
	Exit	InsertText

	Entry	SmartTab
	test	ds:Options,eoUseTab
	jz	@@1
	mov	byte ptr ds:CParam,9
	Invoke	TypeChar
	jmp	@@12
@@1:	mov	ax,ds:CursorPos.X
	push	ax
	mov	cx,ds:TabSize
	cmp	cx,1
	jg	@@2
	inc	ax
	jmp	@@3
@@2:	add	ax,cx
	push	ax
	dec	ax
	sub	dx,dx
	div	cx
	pop	ax
	sub	ax,dx
@@3:	pop	cx
	push	ds:CursorPos.Y
	push	ax
@@4:	dec	ds:CursorPos.Y
	jz	@@5
	Invoke	GoLine
	Invoke	SetEditDS
	test	ax,ax
	jz	@@4
	cmp	ax,ds:CursorPos.X
	ja	@@6
@@5:	pop	ax
	jmp	@@10
@@6:	Invoke	GoCurPos
	dec	bx
@@7:	inc	bx
	Invoke	CheckWS
	jc	@@9
	jnz	@@7
@@8:	inc	bx
	Invoke	CheckWS
	jz	@@8
@@9:	Invoke	CalcColumn
	Invoke	SetEditDS
	pop	bx
	cmp	ax,ds:CursorPos.X
	ja	@@10
	mov	ax,bx
@@10:	pop	ds:CursorPos.Y
	sub	ax,ds:CursorPos.X
	mov	cx,ax
@@11:	push	cx
	mov	byte ptr ds:CParam,' '
	Invoke	TypeChar
	Invoke	SetEditDS
	pop	cx
	jc	@@12
	loop	@@11
@@12:	Invoke	CenterFixScreen
	Exit	SmartTab

NoteRedraw	proc	near
	or	ds:RedrawFlags,rfCurLine
	or	ds:Modified,emShow+emUpdate
	ret
NoteRedraw	endp

InsertEmptyPage	proc	near
@@1:	lea	bx,ds:PageTbl
	cmp	bx,ds:LastPage
	je	@@2
	cmp	[bx].LinesInPage,0
	jne	@@3
	Invoke	GoTopPage
	Invoke	DeletePage
	Invoke	SetEditDS
	jmp	@@1
@@2:	Invoke	InsertPage
	jc	@@4
	Invoke	GetCurPage
	Invoke	UseCurPage
	jc	@@4
	mov	bx,[bx].PageLength
	mov	es:[bx].LineLength,0
	mov	es:[bx].LineNumber,0
	lea	ax,[bx+size LineHeader+1]
	mov	bx,ds:CurPage
	mov	[bx].PageLength,ax
	inc	[bx].LinesInPage
	clc
	jmp	@@4
@@3:	stc
@@4:	ret
InsertEmptyPage	endp

BreakLine	proc	near
	mov	ax,dx
	sub	ax,cx
	add	ax,size LineHeader+1
	and	al,0feh
	add	ax,cx
	add	ax,size LineHeader+1
	and	al,0feh
	sub	ax,size LineHeader
	sub	ax,dx
	and	al,0feh
	mov	bx,ds:CurPage
	add	ax,[bx].PageLength
	cmp	ax,ds:PageSize
	jbe	@@1
	stc
	jmp	@@5
@@1:	Invoke	ShiftDown
	Invoke	UseCurPage
	Invoke	StoreLinesInfo
	push	ds
	xchg	ax,[bx].PageLength
	inc	[bx].LinesInPage
	mov	es:[di].LineLength,cx
	sub	bx,bx
	test	cx,cx
	jnz	@@2
	xchg	bx,es:[di].LineNumber
@@2:	push	bx
	mov	bx,di
	add	bx,size LineHeader+1
	add	bx,cx
	and	bl,0feh
	add	di,size LineHeader+1
	add	di,dx
	and	di,0fffeh
	sub	dx,cx
	mov	cx,ax
	sub	cx,di
	shr	cx,1
	push	bx
	mov	bx,ds:CurPage
	mov	di,[bx].PageLength
	pop	bx
	dec	di
	dec	di
	push	es
	pop	ds
	push	si
	mov	si,ax
	std
	lodsw
	rep	movsw
	pop	ax
	mov	cx,dx
	test	al,1
	jnz	@@4
	test	cl,1
	jnz	@@3
	inc	si
	inc	si
@@3:	dec	si
@@4:	mov	cx,di
	sub	cx,bx
	shr	cx,1
	rep	movsw
	cld
	mov	[di].LineLength,dx
	pop	ax
	mov	[di].LineNumber,ax
	pop	ds
	mov	ds:CursorPos.X,1
	or	ds:RedrawFlags,rfBelowPrevLine
	Invoke	Down
	Invoke	InvalidateUndo
	Invoke	SetEditDS
	clc
@@5:	ret
BreakLine	endp

CharIntoLine	proc	near
	mov	ax,dx
	add	ax,16
	cmp	ax,ds:PageSize
	jae	@@1
	test	dl,1
	jz	@@4
	mov	bx,ds:CurPage
	mov	ax,[bx].PageLength
	cmp	ax,ds:PageSize
	jb	@@2
@@1:	stc
	jmp	@@5
@@2:	mov	cx,ax
	add	[bx].PageLength,2
	push	si di
	mov	ax,es:[di].LineLength
	add	ax,di
	add	ax,size LineHeader
	push	ds
	push	es
	pop	ds
	mov	di,cx
	sub	cx,ax
	jae	@@3
	sub	cx,cx
@@3:	shr	cx,1
	lea	si,[di-2]
	std
	rep	movsw
	cld
	pop	ds
	pop	di si
@@4:	mov	al,byte ptr ds:CParam
	push	di ds
	push	es
	pop	ds
	mov	cx,[di].LineLength
	inc	[di].LineLength
	sub	cx,si
	add	cx,di
	add	cx,size LineHeader
	add	si,cx
	mov	di,si
	dec	si
	shr	cx,1
	std
	dec	si
	dec	di
	rep	movsw
	inc	si
	inc	di
	rcl	cx,1
	rep	movsb
	cld
	inc	si
	stosb
	pop	ds di
	Invoke	ShiftRight
	inc	si
	mov	bx,si
	Invoke	CalcColumn
	Invoke	SetEditDS
	mov	ds:CursorPos.X,ax
	clc
@@5:	ret
CharIntoLine	endp

_CharIntoPage	proc	near
	test	di,di
	jnz	@@1
	jmp	@@5
@@1:	mov	si,bx
	cmp	di,bx
	je	@@2
	mov	dx,es:[di].LineLength
	mov	cx,si
	sub	cx,di
	sub	cx,size LineHeader
	test	ds:Options,eoOverwrite
	jz	@@3
	mov	al,byte ptr ds:CParam
	cmp	al,0dh
	je	@@6
	cmp	al,0ah
	je	@@6
	cmp	cx,dx
	jae	@@3
	mov	es:[si],al
	call	NoteRedraw
	inc	si
	mov	bx,si
	Invoke	CalcColumn
	Invoke	SetEditDS
	mov	ds:CursorPos.X,ax
	clc
	jmp	@@8
@@2:	lea	ax,[si+size LineHeader]
	inc	ax
	and	al,0feh
	cmp	ax,ds:PageSize
	ja	@@5
	sub	dx,dx
	mov	es:[di].LineLength,dx
	mov	ds:CursorPos.X,1
	or	ds:RedrawFlags,rfBelowPrevLine
	mov	bx,ds:CurPage
	mov	[bx].PageLength,ax
	inc	[bx].LinesInPage
	mov	dx,es:[di].LineLength
	sub	cx,cx
@@3:	cmp	byte ptr ds:CParam,0ah
	je	@@8
	call	NoteRedraw
	cmp	byte ptr ds:CParam,0dh
	je	@@4
	call	CharIntoLine
	jmp	@@8
@@4:	call	BreakLine
	jmp	@@8
@@5:	stc
	jmp	@@8
@@6:	Invoke	CheckForLastLine
	jc	@@7
	Invoke	Down
	Invoke	LOfLine
	Invoke	SetEditDS
	test	ds:Options,eoAutoIndent
	jz	@@8
	Invoke	SkipWS
	Invoke	SetEditDS
	jmp	@@8
@@7:	Invoke	ROfLine
	Invoke	SetEditDS
	push	ds:Options
	and	ds:Options,not eoOverwrite
	Invoke	TypeChar
	Invoke	SetEditDS
	pop	ds:Options
@@8:	ret
_CharIntoPage	endp

CharIntoPage	proc	near
	Invoke	GoCurPos
	Invoke	UseCurPage
	jc	@@4
	cmp	byte ptr ds:CParam,0dh
	je	@@2
	mov	cx,ax
	mov	ax,bx
	sub	ax,di
	sub	ax,size LineHeader
	sub	ax,es:[di].LineLength
	jz	@@3
	test	cx,cx
	jz	@@2
	cmp	byte ptr ds:CParam,9
	je	@@2
	mov	al,byte ptr ds:CParam
	push	ax ds:Options
	and	ds:Options,not eoOverwrite
	mov	byte ptr ds:CParam,' '
@@1:	push	cx
	call	_CharIntoPage
	Invoke	GoCurPos
	Invoke	UseCurPage
	pop	cx
	loop	@@1
	pop	ds:Options ax
	mov	byte ptr ds:CParam,al
@@2:	call	_CharIntoPage
	jmp	@@4
@@3:	inc	cx
	mov	ax,cx
	add	ax,es:[di].LineLength
	jc	@@4
	add	ax,16
	jc	@@4
	cmp	ax,ds:PageSize
	jb	@@5
	stc
@@4:	jmp	@@12
@@5:	mov	si,ds:CurPage
	mov	ax,ds:PageSize
	sub	ax,[si].PageLength
	cmp	ax,cx
	jb	@@6
	jmp	@@11
@@6:	add	ax,di
	sub	ax,size PageHeader
	cmp	ax,cx
	jae	@@9
	mov	ax,ds:PageSize
	sub	ax,di
	sub	ax,size LineHeader
	sub	ax,es:[di].LineLength
	cmp	ax,cx
	jae	@@8
	Invoke	ReserveSpace
	Invoke	SetEditDS
	jnc	@@8
@@7:	jmp	@@4
@@8:	Invoke	FindCurLine
	Invoke	UseCurPage
	mov	ax,es:[bx].LineLength
	add	ax,bx
	add	ax,size LineHeader+1
	mov	bx,ds:CurPage
	cmp	ax,[bx].PageLength
	jae	@@10
	inc	ds:CursorPos.Y
	Invoke	RestToNextPage
	Invoke	SetEditDS
	dec	ds:CursorPos.Y
	jnc	@@9
	Invoke	InsertPage
	Invoke	SetEditDS
	jc	@@4
	inc	ds:CursorPos.Y
	Invoke	RestToNextPage
	Invoke	SetEditDS
	dec	ds:CursorPos.Y
	jnc	@@10
	jmp	@@7
@@9:	Invoke	ReserveSpace
	Invoke	SetEditDS
	jc	@@7
@@10:	Invoke	GoCurPos
	Invoke	UseCurPage
	mov	cx,ax
	inc	cx
@@11:	mov	bx,es:[di].LineLength
	lea	ax,[di+size LineHeader+bx+1]
	and	al,0feh
	add	bx,cx
	lea	bx,[di+size LineHeader+bx+1]
	and	bl,0feh
	sub	bx,ax
	push	di cx
	mov	di,ds:CurPage
	mov	si,[di].PageLength
	mov	cx,si
	sub	cx,ax
	shr	cx,1
	add	[di].PageLength,bx
	dec	si
	dec	si
	lea	di,[bx+si]
	push	ds
	push	es
	pop	ds
	std
	rep	movsw
	pop	ds
	cld
	pop	cx di
	mov	bx,es:[di].LineLength
	add	es:[di].LineLength,cx
	mov	si,di
	lea	di,[di+size LineHeader+bx]
	mov	al,' '
	dec	cx
	rep	stosb
	mov	al,byte ptr ds:CParam
	mov	di,si

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -