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

📄 editmgr2.asm

📁 dos 6.0 源代码 .对大家提高有一定的帮助。
💻 ASM
📖 第 1 页 / 共 5 页
字号:
; Now check if ip below last line on screen
$I718:
	mov	di, [cLinesCur] 	;pwndEditCur.cLines
	add	di, cx			;di = olntop + cLines
	dec	di			;di = olnBottom of screen
	cmp	di, dx			;dx = ipCur.ip_oln
	jae	$I723			;brif ip below last line of screen
	mov	ax, di			;check if ip between bot. and margin
	add	ax, si
	cmp	ax, dx			;dx = ipCur.ip_oln
	jbe	$I724			;brif below more then margin 
	mov	ax, dx			;else set tos so ip is at bottom
	sub	ax, di
	add	cx, ax
	jmp	SHORT $I725
$I724:
	mov	cx, dx			;ok to adjust tos to put move by
	sub	cx, si			;by margin distance
$I725:
	mov	pdCur.pd_olntop, cx
	inc	[fRefreshScreen]
	
;Here when ready to recalc the columns
$I723:
	mov	cx, pdCur.pd_obleft
	mov	si,[cColumnsCur]	;pwndEditCur.cColumns
	shr	si,1			;calc. margin for columns again
	shr	si,1			;a factor of 1/4 screen width
	mov	ax,shiftWidth
	mov	[shiftWidthSave],ax	;use new shiftWidth based on margin
	cmp	ax,si
	jbe	$I726			;brif shiftWidth less then margin
	mov	shiftWidth,si		;if bigger use margin as shiftWidth
$I726:
	mov	ax,[cColumnsCur]	;pwndEditCur.cColumns
	add	ax,cx			;calc. left edge of screen
	dec	ax
	mov	[obRight],ax		;line offset for left edge
	mov	di,ipCur.ip_ob		;di - ip col. offset
;Check if ip is to left of left margin
	cmp	cx,di
	jbe	$I727			;brif ip to right of left margin
	cmp	di,si			;is ip with margin of start of line
	jae	$I728			;brif ip more the margin from start
	xor	cx, cx			;just set to start of line
	jmp	SHORT $L20064
$I728:
	mov	ax,cx			;check if ip is within margin of 
	sub	ax,si			;left edge
	cmp	ax,di
	jbe	$I730			;brif ip more then margin away
	mov	cx,di
	sub	cx,si			;adjust by margin
	jmp	SHORT $L20064
$I730:
	mov	cx,di			;else don't use margin to adjust
	sub	cx,shiftWidth		;but shiftWidth
$L20064:
	mov	pdCur.pd_obleft, cx	;set up new left margin
$I729:
	inc	[fRefreshScreen]
;How check if ip past right edge of screen
$I727:
	mov	ax,[cColumnsCur]	;pwndEditCur.cColumns
	add	ax, pdCur.pd_obleft
	cmp	ax,di
	;!!! why can't use obright in above compare with temp inc.
	ja	$I732			;brif to left of right edge
	mov	ax,ldCur.ld_cbMax	;check if ip within full screen of edge
	sub	ax,[cColumnsCur]	;pwndEditCur.cColumns
	cmp	ax,di		
	jbe	$L20065			;brif ?
	mov	ax,[obRight]		
	add	ax,si
	cmp	ax,di			;check if ip with margin region
	jbe	$I735			;brif if not
	mov	ax,shiftWidth		;with margin of edge so use shiftWidth
	sub	ax,[cColumnsCur]	;pwndEditCur.cColumns
	add	ax,di
	jmp	SHORT $L20065
$I735:
	mov	ax,di			;else adjust it by margin
	sub	ax,si
$L20065:
	mov	pdCur.pd_obleft,ax
	inc	[fRefreshScreen]
$I732:
	mov	ax,[shiftWidthSave]	;restore shiftWidth
	mov	shiftWidth,ax
$EX711:
cEnd


cProc AutoIndent,<NEAR,PUBLIC>
cBegin
	xor	ax,ax			; Use 0 for last line.
	mov	bx, [ipCur.ip_oln]
	cmp	bx, [clnCur]
	jae	AI_1

	cCall	GetCurLine
	cCall	obGetFirst		;get offset for first non-white spe
AI_1:
	mov	ipCur.ip_ob,ax
cEnd

;*******************************************************************************
;BackTab
;
;Purpose:
;  Back Tab the current line
;Entry:
;	ipCur
;  di == amount to backtab the line
;Exit:
;Uses:
;Exceptions:
;
;*******************************************************************************
cProc BackTab,<NEAR,PUBLIC>
cBegin
	cCall	ModifyLine
	jz	BackTab_Exit

	or	di,di
	jz	BackTab_Exit

	cCall	obGetFirst
	mov	[ipCur.ip_ob], ax
	cmp	ax, di
	jbe	BT_1
	mov	ax, di

BT_1:
	or	ax,ax
	jz	BackTab_Exit

	cCall	DelCh,<ax,ax>
BackTab_Exit:
	mov	[fResetAnchor], 1
cEnd

;Do what little undo we support
cProc Undo,<NEAR,PUBLIC>
cBegin
	and	ldCur.ld_flags, not ld_fDirty
	mov	pdCur.pd_oln,-1		;set to no current line in ld
	cCall	RefreshLine,<[ipCur.ip_oln]>	;get line from buffer
	cCall	HomeLine
	cCall	ResetAnchor		;set ipAnchor to ipCur
cEnd

cProc Cut,<NEAR,PUBLIC>
	parmB	fCopy

	localW	olnBottom
	localW	olnFirst
	localW	obFirst
	localW	olnLast
	localW	obLast
cBegin
	cCall	fCheckReadOnly
	jnz	ExitCut
	mov	bx,pefCur
	cmp	[bx].ef_fSelection,FALSE
	je	$I751			;if no selection then no cut

	lea	ax,[olnFirst]
	lea	bx,[obFirst]
	lea	cx,[olnLast]	
	lea	dx,[obLast]
	cCall	BuildSelection,<ax,bx,cx,dx>
	mov	bx,pefCur		;after cut don't have any selection
	mov	[bx].ef_fSelection,FALSE
	mov	ax,[olnLast]		;check if single line cut
	cmp	[olnFirst],ax	;i.e. first line == last line
	jne	$I749			;brif if multi-line cut
	mov	al,[fCopy]		;check if distructive cut
	sub	ah,ah
	cCall	CutChars,<olnFirst,obFirst,obLast,ax>
	jmp	SHORT $I751
;Here for mult-line cut
$I749:
	cmp	WORD PTR [obLast],0	;if selection is only first ch. of last
	jne	$I752			;line then don't current last line
	dec	WORD PTR [olnLast]	;this is to cut all of current line
$I752:
	mov	ax,[olnLast]
	sub	ax,[olnFirst]
	inc	ax
	mov	bl,[fCopy]
	sub	bh,bh
	cCall	CutLines,<olnFirst,ax,bx>
$I751:
	cCall	ResetAnchor
ExitCut:
cEnd


cProc CutChars,<NEAR>
	parmW	oln
	parmW	obFirst
	parmW	obLast
	parmB	fCopy
cBegin
	cmp	[fCopy],0
	je	$I759
;Here to copy chars to scrap first
	cCall	CopyCharsToScrap,<oln,obFirst,obLast>
$I759:
	cCall	ModifyLine
	mov	ax,[obFirst]		;first character to delete
	mov	ipCur.ip_ob,ax	
	mov	ax,ldCur.ld_cb
	cmp	[obFirst], ax
	jae	$I762

	cmp	[obLast],ax
	jbe	$I761			;brif last char. is not past eol

	mov	[obLast],ax		;cut off del. to eol
$I761:
	mov	ax,[obLast]
	sub	ax,[obFirst]		;ax - # of chars to delete
	cCall	DelCh,<ax,obLast>
$I762:
	cCall	DisplayCurPos		;recalc. screen position in file
	cCall	RefreshLine,<oln>	;redraw the current line
cEnd

cProc CutLines,<NEAR>
	parmW	olnFirst
	parmW	cln
	parmB	fCopy
cBegin
	cmp	[fCopy],0	;check if destructive?
	je	$I766
	cCall	CopyLines,<olnFirst,cln>
	jz	CutLinesExit
$I766:
	cCall	UpdateLine
	mov	[pdCur.pd_oln], -1
	cCall	DeleteLinesBuf,<hBuffer,olnFirst,cln>
	cCall	EMRefreshCache
	mov	ax,[olnFirst]		;update new insertion point
	mov	ipCur.ip_oln,ax
	cCall	AutoIndent		;adjust to start of valid text
	mov	ax,pdCur.pd_olntop
	cmp	[olnFirst],ax		;check of cut start below screen
	jae	$I768			;brif if start of cut below screen
	mov	ax,[olnFirst]		;move screen top to start of cut
	mov	pdCur.pd_olntop,ax
$I768:
	cCall	DisplayCurPos
CutLinesExit:
	inc	[fRefreshScreen]
cEnd

cProc Copy,<NEAR,PUBLIC>

	localW	olnFirst
	localW	obFirst
	localW	olnLast
	localW	obLast
cBegin
	mov	bx,pefCur
	cmp	BYTE PTR [bx].ef_fSelection,0
	je	$I776

	lea	ax,[olnFirst]
	lea	bx,[obFirst]
	lea	cx,[olnLast]
	lea	dx,[obLast]
	cCall	BuildSelection,<ax,bx,cx,dx>
	mov	ax,[olnLast]			;check if multi-line copy
	cmp	[olnFirst],ax
	jne	$I775				;brif if multi-line copy
	cCall	CopyCharsToScrap,<olnFirst,obFirst,obLast>
	jmp	SHORT $I776			;jmp around multi-copy
$I775:
	cmp	[obLast],0			;check if last line is copied
	jne	$I777				;brif last line included in copy
	dec	[olnLast]			;no first ch. select. not last
						;line copy
$I777:
	mov	ax,[olnLast]	
	sub	ax,[olnFirst]
	inc	ax
	push	ax
	cCall	UpdateLine
	pop	ax
	cCall	CopyLines,<olnFirst,ax>
$I776:
cEnd

cProc CopyCharsToScrap,<PUBLIC,NEAR>
	parmW	oln
	parmW	obFirst
	parmW	obLast
cBegin
	cCall	FreeScrap
	cCall	EMRefreshCache

	mov     ax,MAXCHARS

	push	[oln]
	push	[obFirst]
	push	[obLast]
ifdef	PROJECT_QB
	mov	dx,SEG sb_buffer
	push	dx
	mov	bx,OFFSET sb_buffer
else	;PROJECT_QB
	push	ds
	mov     bx,OFFSET DGROUP:sb_buffer
endif	;PROJECT_QB
	push	bx
	push	ax
	call    CopyChars

	mov     [_scrap.sb_cb],ax
	mov     [_scrap.sbfMultiLine],0
	mov	[fPasteOk],1
cEnd

ifdef	KK_UNIT

cProc AdjustKKDisplay,<PUBLIC,FAR>,<si>
	parmW	cch
cBegin
	mov	si,[ipCur.ip_ob]
	mov	ax,[cch]
	add	[ipCur.ip_ob],ax
	cCall	DisplayCurPos
	mov	[ipCur.ip_ob],si
	cmp	[fRefreshScreen],0
	jz	@F
	cCall	RefreshScreen
@@:
	cCall	Refreshline,<[ipCur.ip_oln]>
cEnd

endif	; KK_UNIT

cProc CopyChars,<NEAR,PUBLIC>,<SI>
	parmW	oln
	parmW	obFirst
	parmW	obLast
	parmD	fpBuffer
	parmW	cbMax
cBegin
;       register si = cbText

	cCall    GetLine,<oln>

	mov     si,[obLast]
	sub     si,[obFirst]

	mov     ax,[ldCur.LD_cbMax]
	sub     ax,[ldCur.LD_cb]
	jz      CC1

	push    ax
	mov     ax,' '
	push    ax
	mov     ax,[ldCur.LD_cb]
	add     ax,[ldCur.LD_prgch]
	push    ax
	call    _memset
	add     sp,6
CC1:

	cmp     [cbMax],si
	ja      CC2
	mov     si,[cbMax]
	dec     si
CC2:
	or      si,si
	je      CC3

	mov     ax,[obFirst]
	add     ax,[ldCur.LD_prgch]
	push    ds
	push    ax
	push    word ptr [fpBuffer+2]
	push    word ptr [fpBuffer]
	push    si
	call	bltbytex
CC3:
	mov     bx,[ldCur.LD_cb]
	add     bx,[ldCur.LD_prgch]
	mov     BYTE PTR [bx],0

	les     bx,[fpBuffer]
	mov     BYTE PTR es:[bx][si],0

	mov     ax,si
cEnd


cProc CopyLines,<NEAR,PUBLIC>,<SI,DI>
	parmW	olnFirst
	parmW	cln
cBegin
	mov	si,[olnFirst]
	mov	di,[cln]
	inc	di
	cCall	FreeScrap
	cCall	EMRefreshCache
	jmp	SHORT $L20067
$WC793:
	cmp	si, [clnCur]
	jae	CopyLines_Done
	cCall	EMRefreshCache
	cCall	GetLine,<si>
	inc	si

	cCall	hBufScrap
	push	ax			; 1st parm of InsertLineBuf
	cCall	LinesInBuf,<ax>
	push	ax			; 2nd parm of InsertLineBuf
	push	ldCur.ld_cb		; 3rd parm of InsertLineBuf
	push	ldCur.ld_prgch		; 4th parm of InsertLineBuf
	call	InsertLineBuf		;insert into scrap
	cbw
	or	ax,ax			;text of insert was a success
	je	$WB794			;break out of out of memory
$L20067:
	dec	di
	jnz	$WC793

CopyLines_Done:
	mov	ax, sp			; Return TRUE

$WB794:
	push	ax			; Save return value
	cCall	EMRefreshCache
	pop	ax

	or	ax,ax
	jz	CopyLines_Fail
					; NZ flag still set
	mov	_scrap.SBfMultiLine,1	; NZ flag still set
	mov	[fPasteOk],1            ; NZ flag still set
	jmp	short CopyLines_Exit    ; return NZ

CopyLines_Fail:
	cCall	FreeScrap		; Ran out of memory - free the scrap
	cCall	EMRefreshCache
	xor	ax,ax			; Return Z
CopyLines_Exit:
cEnd

cProc Paste,<NEAR,PUBLIC>,<SI,DI>
	parmDP	pch
cBegin
	cCall	fCheckReadOnly
	jz	@F
	jmp	ExitPaste
@@:
	mov	di,pch
	cmp	_scrap.SBfMultiLine,0
	je	@F			;brif single line scrap
	or	di,di
	je	MultilinePaste		;brif if nothing to paste
@@:
	cmp	_scrap.SB_cb,0
	jne	@F			;brif something in scrap
	or	di,di
	jne	@F
	jmp	ExitPaste
@@:
;Here if single line paste
	cCall	StartBigEdit
	sub	ax,ax
	cCall	Cut,<ax>
	cCall	ModifyLine
	cCall	EndBigEdit
	cCall	EMRefreshCache
	push	ipCur.ip_ob		;save where to start insertion
	or	di,di
	je	@F			;brif to insert from scrap
	push	ds
	push	di			;get size of insertion
	call	fstrlen
	xchg	si,ax			;si = cb
ifdef	PROJECT_QB
	push	ds			;save source segment
endif	;PROJECT_QB
	jmp	SHORT PasteSpaces
@@:
	mov	si,_scrap.SB_cb	;just insert scrap
ifdef	PROJECT_QB
	mov	di,OFFSET SB_buffer	; source offset
	mov	bx,SEG SB_buffer	; source segment
	push	bx			; save source segment
else	;PROJECT_QB
	mov	di,OFFSET DGROUP:SB_buffer
endif	;PROJECT_QB
PasteSpaces:
	;insert spaces to make room for insertion
	mov	ax,32
	cCall	InsCh,<si,ax,ax>	; InsCh( obFirst, ' ', TRUE );
	mov	si,ax
ifdef	PROJECT_QB
	pop	bx			; BX = source segment
endif	;PROJECT_QB
	pop	cx			; CX = thing saved way above
	or	si,si
	je	@F
ifdef	PROJECT_QB
	push	bx			; source addr
	push	di
	push	ds			; dest addr
	add	cx,ldCur.ld_prgch
	push	cx
	push	si			; length 
	call	bltbytex		; do the copy
else	;PROJECT_QB
	push	si
	push	di
	add	cx,ldCur.ld_prgch
	push	cx
	call	_memmove		;copy over spaces just inserted
	add	sp,6
endif	;PROJECT_QB
@@:
	cCall	RefreshLine,<[ipCur.ip_oln]>
	jmp	SHORT ExitPaste

;Here if multi-line paste
MultilinePaste:
	cCall	StartBigEdit
	sub	ax,ax
	cCall	Cut,<ax>
	cCall	UpdateLine
	cCall	EndBigEdit
	cCall	EMRefreshCache
	push	hBuffer
	push	ipCur.ip_oln
	cCall	hBufScrap
	push	ax
	call	InsertBufInBuf		;insert scrap into source
	cCall	EMRefreshCache
	mov	pdCur.pd_oln,-1 	;invalidate ldCur
	inc	[fRefreshScreen]
ExitPaste:
cEnd

cProc NextTab,<NEAR,PUBLIC>,<SI>
	parmW	obCur
cBegin
	;return (obCur/tabStops + 1)*tabStops)
	mov	si,[obCur]
	mov	ax,si
	sub	dx,dx
	div	tabStops
	inc	ax
	mul	tabStops
cEnd

cProc GetTabs,<FAR,PUBLIC>
cBegin
	mov	ax,tabStops
cEnd

cProc SetTabs,<FAR,PUBLIC>
	parmW	value
cBegin
	mov	ax,[value]
	mov	tabStops,ax
cEnd

cProc ResetAnchor,<NEAR,PUBLIC>
cBegin
	mov	ax, ipCur.ip_ob
	mov	ipAnchor.ip_ob, ax
	mov	ax, ipCur.ip_oln
	mov	ipAnchor.ip_oln, ax
cEnd

;*****************************************************************************

⌨️ 快捷键说明

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