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

📄 uiedit.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 5 页
字号:
					; program that he can't even execute
					; a CLEAR statement.
	pop	bx
ModifyAndGrab ENDP
	;fall into ModifyingHbuf
ModifyingHbuf PROC NEAR
	call	ActivateHbuf		;activate oRs [bx]
	cCall	TxtModified		;remember to save this file
MhExit:
	ret
ModifyingHbuf ENDP

;**************************************************************************
;UnGrab
;Purpose:
;	Release space allocated by ModifyAndGrab
;Entry:
;	ax = hbuf (space not released if hbufOfCmd)
;
;**************************************************************************
UnGrab	PROC NEAR
	cmp	ax,[hbufOfCmd]
	je	NotGrabbed		;brif edit is in Command Window
	call	UiReleaseSpace
NotGrabbed:
	ret
UnGrab	ENDP

; Added with [51]
;***
;fDocumentBuf - Is current text table a document buffer
;
;Purpose:
;	Deturmines if the currently activated text table should be
;	manipulated as a document buffer.  This should be done only
;	if we are started with the /EDITOR switch and this is not
;	a PCODE text table.
;
;	NOTE: we can not assert that all items that we are editing with
;	/EDITOR are document tables, as we will initialize with a
;	pCode table.
;
;Entry:
;	None.
;
;Exit:
;	psw.Z set if not a document
;
;Uses:
;	None.
;****
cProc	fDocumentBuf,<NEAR>
cBegin

	test	[cmdSwitches],CMD_SW_ED ;Started with /editor?
	jz	NotDocument		;no, can't be a large buffer
	test	[mrsCur.MRS_flags2],FM2_NoPcode ; Is it a document?
NotDocument:
cEnd

; Added with [51]
;****
;fEditorActive : test wether we were started with /editor
;
;Purpose:
;	Exports the checking for the /EDITOR switch to the components
;	of the product that do not have access to cmdSwitches.
;
;Entry:
;	None.
;
;Exit:
;	psw.z set if not started with /EDITOR  (jnz EditorActive)
;****
cProc	fEditorActive,<FAR, PUBLIC>
cBegin
	test	[cmdSwitches],CMD_SW_ED ;Started with /editor
cEnd


;****
;fQhelpActive : test wether we were started with /QHELP
;
;Purpose:
;	Exports the checking for the /QHELP switch to the components
;	of the product that do not have access to cmdSwitches.
;
;Entry:
;	None.
;
;Exit:
;	psw.z set if not started with /QHELP  (jnz QhelpActive)
;****
cProc	fQhelpActive,<FAR, PUBLIC>
cBegin
	test	[cmdSwitches],CMD_SW_QHELP ;Started with /QHELP
cEnd


;**************************************************************************
; DeleteLinesBuf - Delete a range of lines from the buffer
; Purpose:
;  Called by  TextWin's editor  when it needs to delete a
;  range of source lines.
;  cln lines are deleted from buffer hbuf starting at line ln.
;
; Entry:
;  hbuf  - buffer to delete lines from.
;  ln    - line number to delete.
;  cln   - Number of lines to delete.
;
; Exit:
;
;**************************************************************************
cProc	DeleteLinesBuf,<PUBLIC,FAR>,<si>
	parmW	hbuf
	parmW	ln
	parmW	cln
cBegin
	mov	bx,[hbuf]
	call	ModifyingHbuf

	call	fDocumentBuf		; Is this a large document buffer?
	jz	DLB_NotDocument 	; brif not, let txtmgr handle it
	push	[mrsCur.MRS_pDocumentBuf] 
	push	ln			
	push	cln			
	call	S_DeleteLinesBuf	; Delete line from document buffer
	jmp	SHORT DLB_Exit		

DLB_NotDocument:
;*** Don't need to do this because TxtChange calls UiFlushCache.
;***	mov	[lnGetNext],0		; clear cache

; TxtChange(OtxOfLn(ln),OtxOfLn(ln+cln),fNoInsert)

	mov	si,[ln]
	cCall	OtxOfLn,<si>
	push	ax			; 1st parm for TxtChange (otxStart)

	add	si,[cln]
	cCall	OtxOfLn,<si>
	push	ax			; 2nd parm for TxtChange (otxEnd)

	push	sp			; 3rd parm for TxtChange (fNoInsert)

	call	TxtChange		; just delete, don't insert anything

	mov	ax,[ln]			; pass line# above edit in ax
	mov	dx,[cln]
	neg	dx			; pass -#lines deleted in dx
	call	UpdAltListWnd

DLB_Exit:
cEnd

;**************************************************************************
; ReplaceLineBuf(hbuf, ln, cbNewSrc, pbNewSrc)
; Purpose:
;  Replace the line ln in the buffer hbuf with the text pbNewSrc.
;
; Entry:
;  hbuf - the buffer containing the line to be replaced.
;  ln   - the line to replace.
;  cbNewSrc - the length of the new line.
;  pbNewSrc - the text of the new line.
;
; Exit:
;  uierr is set non-zero if any error occurred.
;  returns zero if we changed hBufs (ie - line was a SUB or FUNCTION
;	definition). This tells the editmgr to stop any futher edits
;	to the entry hBuf (keeps us from inserting a BOL for a CR at
;	a random location in the text table.
;
;**************************************************************************
cProc	ReplaceLineBuf,<PUBLIC,FAR>,<si,di>
	parmW	hbuf
	parmW	ln
	parmW	cbNewSrc
	parmDP	pbNewSrc
	LocalW	cbTextOld
cBegin
DbAssertRel [pbNewSrc],e,[ps.PS_bdpSrc.BDP_pb],UI,<ReplaceLineBuf: bad pbNewSrc>
	mov	si,[ln]

	mov	bx,[hbuf]
	call	ModifyAndGrab

	call	fDocumentBuf		; Is this a large doc buffer?
	jz	RLB_NotDocument 	; brif not, let txtmgr handle it
	push	[mrsCur.MRS_pDocumentBuf] 
	push	ln			
	push	cbNewSrc		
	PUSHI	ax,<dataOffset ps.PS_bdpSrc.BDP_pb> ; Ptr to ptr to buffer
	call	S_ReplaceLineBuf	; Replace line in document buffer
	jmp	SHORT RLB_UnGrab	

RLB_NotDocument:
	mov	cx,[cbNewSrc]
	cCall	KludgePs

;*** Don't need to do this because TxtChange calls UiFlushCache.
;***	mov	[lnGetNext],0		; clear cache

	cCall	OtxOfLn,<si>		; Get otx of begining of line
	xchg	di,ax			; mov di,ax

	inc	si
	cCall	OtxOfLn,<si>		; Get otx of next line
	xchg	si,ax			; mov si,ax

	mov	ax,[txdCur.TXD_bdlText_cbLogical]
	mov	[cbTextOld],ax

; If there is currently an error and it is on the same line as we
; are about to change, clear the error under the assumption it's about
; to be fixed (if it isn't fixed then a new error is generated).
;
	cmp	di,[txtErr.TXER_otx]
	jne	RLB1
	cmp	[uierr],ER_OM
	je	RLB1			;don't clear of uierr=ER_OM
	mov	[uierr],0
RLB1:

;
; Now make the change.
;
	sub	ax,ax			;clear fNoInsert flag
	cCall	TxtChange,<di,si,ax>
	or	ax,ax
	je	RLB2

;
; There was an error
;
	mov	[uierr],ax
	jmp	SHORT RLB_End

RLB2:
; There was no error this time.
;
	cmp	[uierr],ax		; ax is zero
	je	RLB_End
;
; There was an error before this call to ReplaceLineBuf.
; Make sure that the otx reflects the changes this call has made.
;
	cmp	di,[txtErr.TXER_otx]
	ja	RLB_End 		; brif edit passed error loc

	mov	ax,[txdCur.TXD_bdlText_cbLogical]
	sub	ax,[cbTextOld]
	add	[txtErr.TXER_otx],ax

RLB_End:
	mov	ax,[ln]			; pass line# in ax
	sub	dx,dx			; pass line count in dx
	call	UpdAltListWnd
	cCall	UnKludgePs
RLB_UnGrab:
	mov	ax,[hbuf]
	call	UnGrab			;free space reserved by ModifyAndGrab
	sub	ax,ax			; Assume we changed hBufs
	mov	bx,[hBuf]		
	cmp	bx,[grs.GRS_oRsCur]	;see if hBuf on entry = hBuf on Exit
	jne	RLB_Exit		;return FALSE if not
	dec	ax			;return TRUE (same hBuf)
RLB_Exit:
cEnd

;**************************************************************************
; InsertLineBuf(hbuf, ln, cbNewSrc, pbNewSrc)
; Purpose:
;  Inserts the line specified by pbNewSrc and cbNewSrc into the buffer
;  specified by hbuf before the line ln.
;
; Entry:
;  hbuf     - buffer to insert line into
;  ln       - line to insert before
;  cbNewSrc - length of new line
;  pbNewSrc - text to insert
;
; Exit:
;  if the line was inserted, returns non-zero
;  else sets [uierr] and returns FALSE
;
;**************************************************************************
cProc	InsertLineBuf,<PUBLIC,FAR>
	parmW	hbuf
	parmW	ln
	parmW	cbNewSrc
	parmDP	pbNewSrc
cBegin
DbAssertRel [pbNewSrc],e,[ps.PS_bdpSrc.BDP_pb],UI,<InsertLineBuf: bad pbNewSrc>
	mov	bx,[hbuf]
	call	ModifyAndGrab

	call	fDocumentBuf		; is this a large document buffer
	jz	ILB_NotDocument 	; brif not, let txtmgr handle it
	push	[mrsCur.MRS_pDocumentBuf] 
	push	ln			
	push	cbNewSrc		
	PUSHI	ax,<dataOffset ps.PS_bdpSrc.BDP_pb> ; Ptr to ptr to buffer
	PUSHI	ax,0			; FALSE -> check # lines
	call	S_InsertLineBuf 	; Insert line in doc buffer
	push	ax			; save result for ILB_UnGrab
	jmp	SHORT ILB_UnGrab	

ILB_NotDocument:
	mov	cx,[cbNewSrc]
	cCall	KludgePs

	;Speed optimization so we don't call OtxOfLn for scrap.
	;We only insert lines at the end of the scrap.  This makes
	;Cut/Copy MUCH faster.
	
	mov	ax,[hbuf]
	cmp	ax,[hbufOfScrap]
	jne	NotScrap4
	mov	ax,[txdCur.TXD_bdlText_cbLogical]
	sub	ax,CB_EMPTY_TEXT
	jmp	SHORT GotScrap

NotScrap4:
	cCall	OtxOfLn,<ln>		;ax = text offset to line
GotScrap:
	sub	bx,bx			;clear fNoInsert flag
	cCall	TxtChange,<ax,ax,bx>
	or	ax,ax
	je	ILB_End			;brif no error

	mov	[uierr],ax

	mov	ax,-1
ILB_End:
	inc	ax			; return 0 if fail, 1 if Ok

	push	ax			; save return value

	;The next few lines treat a special case bug.
	;If the editor is extending beyond the end of the current window,
	;calling UpdAltListWnd will cause DrawDebugScr to cause the
	;edit mgr to Draw the debug screen, which will cause its partial
	;line to be dumped to ReplaceLineBuf.
	
	cmp	[cbNewSrc],0
	jne	NotExtend
	mov	ax,[txdCur.TXD_cLines]
	dec	ax
	cmp	ax,[ln]			; pass line# in ax
	je	ItsExtend
NotExtend:
	mov	ax,[ln]			; pass line# in ax
	mov	dx,1			; pass line count in dx
	call	UpdAltListWnd
ItsExtend:

	cCall	UnKludgePs

ILB_UnGrab:
	mov	ax,[hbuf]
	call	UnGrab			;free space reserved by ModifyAndGrab
	pop	ax			;restore return value
ILB_Exit:
	or	ax,ax			;set condition codes for caller
cEnd

;**************************************************************************
; fReadOnlyBuf(hbuf)
; Purpose:
;  Tells the EditMgr whether a buffer {is, is not} read only.
;  A buffer is read only if it is code and we are viewing include file lines.
;
; Entry
;  hbuf - The buffer
;
; Exit:
;  if hbuf is read only, Returns TRUE and sets uierr to:
;     MSG_InclOff if current line didn't come from $INCLUDE file
;      (causes ReportError to ask user if he wants View/IncludeLines turned off)
;     MSG_EditIncl if current line came from $INCLUDE file
;      (causes ReportError to ask user if he wants to edit $INCLUDE file)
;
;**************************************************************************
cProc	fReadOnlyBuf,<PUBLIC,FAR>
	parmW	hbuf
cBegin
	mov	bx,[hbuf]
	cmp	bx,hbufHelp		; Check for Help buffer.
	jne	@F
	mov	ax,sp			; If so, is help window, return TRUE
	jmp	short ExitFReadOnlyBuf	

@@:
	call	ActivateHbuf
	xor	ax,ax			;prepare to return FALSE
ExitFReadOnlyBuf:
cEnd


;**************************************************************************
; LinesInBuf(hbuf)
; Purpose:
;  Return number of lines in a given edit buffer
;
; Entry
;  hbuf - The buffer
;
; Exit:
;  return the number of lines in the buffer.
;
;**************************************************************************
cProc	LinesInBuf,<PUBLIC,FAR>
	parmW	hbuf
cBegin

	mov	bx,[hbuf]
	cmp	bx,hbufHelp			; test for help buffer
	jne	@F
	PUSHI	ax,WM_HELPFILESIZE		; message to send
	push	ax				; garbage parameter
	cCall	SendHelpMsg			; AX = # lines
	jmp	short LIB_End			

@@:
; Return 1 is hbuf is UNDEFINED (for single line edit fields).

	mov	ax,1
	inc	bx
	jz	LIB_End
	dec	bx

; else return the number of lines in the buffer.

	call	ActivateHbuf

	mov	ax,[txdCur.TXD_cLines]

	call	fDocumentBuf		; Is this a document buffer?
	jz	LIB_END 		; brif not, AX = # lines
	push	[mrsCur.MRS_pDocumentBuf] 
	call	S_LinesInBuf		; get # lines in document buffer

LIB_End:
cEnd


;**************************************************************************
; ListAxSiDi

⌨️ 快捷键说明

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