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

📄 uiedit.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 5 页
字号:
cBegin
	mov	bx,[hbufOfCmd]
	inc	bx			;if hbufOfCmd is UNDEFINED, exit
	je	EndFreeCmdHistory
	dec	bx

	push	[grs.GRS_oRsCur]	;pass oRsCur to UiRsActivate below
	push	[txtErr.TXER_errCode]
	push	[txtErr.TXER_otx]
	push	[txtErr.TXER_oRs]
	push	WORD PTR [txtErr.TXER_fDirect]

	call	UiDelAll
	PUSHI	ax,<DATAOFFSET txdCur.TXD_bdlText>
	call	BdlTrim			;If we don't trim the buffer,
					; the space isn't made available
					; to other callers until TxtDeactivate
	pop	ax
	mov	[txtErr.TXER_fDirect],al
	pop	[txtErr.TXER_oRs]
	pop	[txtErr.TXER_otx]
	pop	[txtErr.TXER_errCode]
	call	UiRsActivate		;parm pushed on entry
EndFreeCmdHistory:
cEnd

;**************************************************************************
; void near FreeScrap()
; Purpose:
;  Release the contents of the 'scrap' buffer.
;
;**************************************************************************
cProc	FreeScrap,<PUBLIC,FAR>
cBegin
	mov	bx,[hbufOfScrap]
	inc	bx			;test for UNDEFINED
	jz	FreeScrap_End		;brif no scrap is allocated
	dec	bx			;restore bx=hbufOfScrap
	call	UiDelAll		;Delete all the lines in hbufOfScrap
FreeScrap_End:
cEnd

;**************************************************************************
; CutAll(hbufSrc)
; Purpose:
;	Cut the entire active text table to the scrap.
; Entry:
;	hbufSrc = hbuf (i.e. oRs) of source text table.
; Exit:
;  returns zero if out-of-memory, non-zero if success
;
;**************************************************************************
cProc	CutAll,<PUBLIC,NEAR>,<si,di>
	parmW	hbufSrc
	localW	lnDst
cBegin
	call	FreeScrap
	DbAssertRel [hbufOfScrap],ne,UNDEFINED,UI,<CutAll: no hbufOfScrap>

	call	StartBigEdit		;so we don't stop inserting just
					; because of a syntax error

; Cycle through all the lines in the source buffer, inserting each line in
; the Scrap buffer.
	sub	di,di
	mov	[lnDst],di		;init lnDst to 0
CA_NextLine:
	cCall	LinesInBuf,<hbufSrc>
	cmp	ax,di
	jna	CA_Done 		;brif done with loop

	;Use the line buffer of the source buffer as a scratch buffer.
	push	[hbufSrc]		;pass hbuf
	push	di			;pass line to get
	push	[ps.PS_bdpSrc.BDP_cbLogical] ;pass cbMax
	push	[ps.PS_bdpSrc.BDP_pb]	;pass pbDst
	call	cbGetLineBuf		;ax = #bytes fetched, uierr may = ER_OM
	inc	di			;bump line count

	push	[hbufOfScrap]		;pass Scrap as destination buffer
	push	[lnDst]
	push	ax			;pass cb
	push	[ps.PS_bdpSrc.BDP_pb]	;pass pbSrc
	call	InsertLineBuf
	je	CA_Done 		;brif line not inserted (out of memory)
	inc	[lnDst]
	jmp	short CA_NextLine

CA_Done:
	mov	bx,[hbufOfScrap]	;activate Scrap text table
	call	ActivateHbuf		; for EndBigEdit
	call	EndBigEdit
	sub	ax,ax			;prepare to return 0 (error)
	cmp	[uierr],ax
	jne	CA_Exit 		;brif got an error

; Now delete all source from text table

	mov	bx,[hbufSrc]
	call	UiDelAll		;delete all text in text table
CA_Exit:
cEnd

;**************************************************************************
; PasteAll
; Purpose:
;	Copy the entire scrap to the active text table.
; Entry:
;	grs.oRsCur identifies source text table.
;
;**************************************************************************
cProc	PasteAll,<PUBLIC,NEAR>
cBegin
	push	[grs.GRS_oRsCur]	;pass hbufSrc
	PUSHI	ax,0			;lnInsert = 0
	push	[hbufOfScrap]		;pass hbufDst
	call	InsertBufInBuf
cEnd



;*********************************************************************
; void NEAR MoveCursorPwndCur(ln, col)
; Purpose:
;  Position cursor to a particular line/column within the active window.
;
; Entry:
;  pwndAct points to active window's structure
;  ln  - line to position cursor to.
;  col - column to position cursor to.
;
; Exit:
;
;*********************************************************************
cProc	MoveCursorPwndCur,<PUBLIC,NEAR>
	parmW	ln
	parmW	col
cBegin
	DbAssertRel [pwndAct],ne,0,UI,<MoveCursorPwndCur: pwndAct=0>

	cCall	MoveCursorPwnd,<pwndAct,ln,col>
cEnd


;*********************************************************************
; void NEAR MoveCursorPwnd(pwnd, ln, col)
; Purpose:
;  Position cursor to a particular line/column within the window
;  specified
;
; Entry:
;  pwnd - points to window's structure
;  ln  - line to position cursor to.
;  col - column to position cursor to.
;
; Exit:
;
;*********************************************************************
cProc	MoveCursorPwnd,<PUBLIC,NEAR>
	parmW	pwnd
	parmW	ln
	parmW	col
cBegin
	DbAssertRel [ln],ne,0ffffH,UI,<MoveCursorPwnd: ln=ffff>
	DbAssertRel [col],ne,0ffffH,UI,<MoveCursorPwnd: col=ffff>
	DbAssertRel [pwnd],ne,0,UI,<MoveCursorPwnd: pwnd=0>

	push	[pwnd]
	PUSHI	ax,EM_SELCHARS		; message
	push	[ln]			; wParam - line.
	mov	ax,[col]
	push	ax			; lParam - start and end column
	push	ax
	call	SendMessage
cEnd


;*********************************************************************
; MoveTxdCursor
; Purpose:
;	Position cursor where it was last time text was visible.
; Entry:
;	pUwinAct points to active window's structure
;	pUwinAct->lnCursor = line to position window at
;
;*********************************************************************
cProc	MoveTxdCursor,<PUBLIC,NEAR>
cBegin
	DbAssertRel [pwndAct],ne,0,UI,<MoveTxdCursor: pwndAct=0>
	call	UiRsActivateWnd 	;activate active window's register set
	mov	ax,[txdCur.TXD_lnCursor]
	inc	ax			;test for UNDEFINED
	je	MtxdFirst		;brif 1st time this txd has been shown
					; line = 0
	dec	ax			;restore ax = last line cursor was on
MtxdFirst:
	mov	[txdCur.TXD_lnCursor],ax ;if it was UNDEFINED, set it to 0
					; now, so we don't think its the first
					; time we've seen it on subsequent calls
	push	ax			;pass line
	PUSHI	ax,0			;pass column = 0
	call	MoveCursorPwndCur	;move pwndCur's cursor
cEnd



;SetUiErrCond added with revision [47]
;*********************************************************************
; SetUiErr, SetUiErrCond
; Purpose:
;	Set uierr, and txterr properly.
;	SetUiErrCond conditionally sets uierr and txterr if:
;	    1. error code is non-zero
;	    2. uierr is not already set.
;
; Entry:
;	errCode is the error code
; Exit:
;	Sets uierr and txterr
;	callers assume that only AX is used.
;	AX = error code
;
;*********************************************************************
cProc	SetUiErrCond,<PUBLIC,NEAR>	; Same parms as SetUiErr
	parmW	errCode
cBegin
	mov	ax,[errCode]		; to return error in AX
	or	ax,ax			; got an error?
	jz	NoError			; brif not -- just
	cmp	uierr,0			; already got another error?
	je	SetUiErr_Start		; brif not -- go ahead & set uierr
NoError:
cEnd

cProc	SetUiErr,<PUBLIC,NEAR>
	parmW	errCode
cBegin
SetUiErr_Start:				; entry point for SetUiErrCond
	mov	[txtErr.TXER_oRs],UNDEFINED
	mov	ax,[errCode]
	mov	[uierr],ax
cEnd

cProc	SetUiErrOm,<PUBLIC,NEAR>
cBegin
	PUSHI	ax,ER_OM
	call	SetUiErr
cEnd

;*********************************************************************
; SetUiErrFar
;	Added with revision [26].
; Purpose:
;	Set uierr, and txterr properly.
; Entry:
;	AX is the error code
; Exit:
;	Sets uierr and txterr
;	callers assume that only AX is used.
;
;*********************************************************************

cProc	SetUiErrFar,<PUBLIC,FAR>
cBegin
	cCall	SetUiErr,<ax>
cEnd

;*********************************************************************
; void near ReportError()
; Purpose:
;  Display an error dialog box and, if appropriate, position the cursor
;  where the error was encountered.
;
; Entry:
;  uierr contains an offset into the standard BASIC message table.
;     If uierr=ER_GoDirect, this function just returns.
;     If high bit is set, the ASCII error message is contained in the
;     parser's global structure ps.bdErr.
;     If txtErr.oRs is UNDEFINED
;	 the cursor will not be positioned
;     Else
;        if txtErr.fDirect is TRUE
;           The cursor is put on the last line entered in the command window
;	    txtErr.oSrc = column where cursor is to be positioned (0..n)
;	 else
;	    A list window with register set txtErr.oRs is made active
;	    The cursor is put on the line indicated by txtErr.otx
;	    if txtErr.oSrc = UNDEFINED,
;	       cursor is placed at start of statement indicated by txtErr.otx
;	    else
;	       txtErr.oSrc = column where cursor is to be positioned (0..n)
;     If b$fCompErr is non-zero, error was in compiled code
;	 b$ErrLin = line # of last runtime error (ERL)
;	 b$ErrMod = far ptr to 0-terminated module name
;	 b$ErrAdr = far ptr where runtime call was made
;     Else
;	 error was in interpreted pcode, a simple dialog is displayed
;
;     If uierr == MSG_MrsNotFound
;        an OK/Cancel dialog box will be put up.  If the user selects
;	 OK, the current mrs will be unloaded.
;
;*********************************************************************
cProc	ReportError,<PUBLIC,NEAR>,<si>
	localW	pwndOldFocus
	localW	colSelect
	localW	lnSelect
	localW	cbSelect
	localW	fSelect
cBegin
ReWhileErr:
	sub	si,si
	mov	[pwndOldFocus],si
	mov	[fSelect],0ffffH	;initialize to UNDEFINED
	xchg	si,[uierr]		;si=uierr, uierr=0
	cmp	si,ER_OM
	jne	NotOmErr
	sub	bx,bx
	mov	bl,[b$ErrInfo]		;bx = extended error code
	shl	bx,1			;bx = 2*extended error code
	mov	si,cs:twExtOmErr[bx]	; si = extended error msg

	;If user wants to enter a direct mode stmt (like SYSTEM), make sure
	; there is room in the command window's buffer to hold the command.
	; If we didn't do this, it could be an infinite out-of-memory loop.
	
	call	FreeCmdHistory
NotOmErr:
	cCall	FlushMsgs		;Don't let any pending keys
					;foul us up.
	cmp	si,MSG_GoDirect
	jne	NotGoDirect
	jmp	ReEnd			;brif user pressed CANCEL
					; button in some Dialog box
NotGoDirect:
	cmp	si,MSG_HelpOOM		; Memory problems in help?
	jne	NotHelpOOM		; no, continue checking
	cCall	DisplayHelpOOM		; handled in shared code
	jmp	ReEnd			; exit
NotHelpOOM:				

	mov	ax,[txtErr.TXER_oRs]
	cmp	[hbufOfScrap],ax	;see if error during cut/paste
					; (like out-of-memory)
	je	ReNoCursor		;can't position to scrap
	cmp	[hbufOfCmd],ax
	je	ReCmdWndErr		;brif error in command window
					; since no syntax checking
					; in cmd window, probably
					; out-of-memory
	inc	ax			;test for UNDEFINED
	je	ReNoCursor		;brif can't position cursor

	cmp	[txtErr.TXER_fDirect],FALSE
	je	ReListCursor		;brif error wasn't in cmd wnd

ReCmdWndErr:
	;Position cursor at offending point in command window
	mov	ax,[txtErr.TXER_oSrc]	; if txtErr.TXER_oSrc=UNDEFINED
	inc	ax			;  then column = 0
	je	SkipDec1
	dec	ax			; otherwise, restore its value
SkipDec1:
	cCall	MoveCursorPwndCur,<lnCmdLast, ax> 
	jmp	SHORT ReNoCursor

ReListCursor:
	;Position cursor at offending point in list window
	mov	ax,txtErr.TXER_otx	;if txtErr.TXER_otx=UNDEFINED
	mov	[fSelect],ax		;set Select flag
	inc	ax			;then otx=0
	jz	short SkipDec
	dec	ax
SkipDec:
	cCall	ShowTok,<txtErr.TXER_oRs,ax,txtErr.TXER_oSrc>

;Since activation of a dialog box kills an edit window's input focus,
;which causes it to turn off the current selection, we have to play
;some tricks to cause the offending token to be highlighted while the
;dialog box is up.  First we find out what line, column and word size the
;cursor is currently on.  Then call FlushFocus() to kill the input focus.
;Then select the text.
;
	cmp	[fSelect],0ffffH	;See if we have selection
	je	short ReNoCursor	;if not, don't highlight
	inc	[fAdjustMsgBox] 	;set flag for moving error box
	call	GetEditColumn		;ax = edit column
	mov	[colSelect],ax
	call	GetEditLine		;ax = edit line
	mov	[lnSelect],ax
	PUSHI	ax,<DATAOFFSET bufStdMsg>
	PUSHI	ax,41d			;40 + 0-byte terminator
	PUSHI	ax,GEW_NODOTMASK	; do not include . in search
	call	GetEditWordMask 	; ax = #chars in current word
	mov	[cbSelect],ax
	cCall	FlushFocus

	push	[lnSelect]
	push	[colSelect]
	push	[cbSelect]
	call	SelectTextPwndCur	;select offending token

; Display a message box containing the error
; if high bit of si is set, the message is in ps.PS_bdErr
; else si is the error number.
;
ReNoCursor:
	cmp	[b$fCompErr],0
	je	NotCompCodeErr
	jmp	CompCodeErr		;brif err was in compiled code

NotCompCodeErr:
	mov	dx,dataOFFSET ps.PS_bdErr
	or	si,si
	jns	ReStdMsg		;brif caller didn't build msg
	cmp	[ps.PS_bdErr.BD_cbLogical],76d
	mov	si,ER_SN		;if msg too long to fit on
	ja	ReStdMsg		; one line, Syntax error
	mov	iHelpId,9999
	PUSHI	ax,MB_OK
	push	dx			;pass <dataOFFSET ps.PS_bdErr>
	call	MsgBoxBd		
J1_ReEnd:
	jmp	SHORT ReEnd		

ReStdMsg:
	mov	ax,MB_OK
	push	ax			;pass dialog box type
					; to MsgBoxStd, MsgBoxStd2
					; and MsgBoxStdBd


NotMsg2:
	push	si			;pass iMsg to MsgBoxStd
	test	HelpFlags,HLP_RTERR	; did this error come from RT?
	jz	NotRtError		; no, call MsgBoxStd
	call	MsgBoxStdRt		; don't muck with iHelpId
	jmp	SHORT ReEnd		; we are done with error
NotRtError:				
	call	MsgBoxStd
	jmp	SHORT ReEnd

;runtime error was in compiled code
CompCodeErr:
	mov	[uierr],si		;set uierr properly
	call	MsgBoxCompErr
	mov	[b$fCompErr],0
	cmp	[uierr],si		;see if uierr is the same
	jne	ReEnd			;if not, then we have new error
	mov	[uierr],0		;otherwise, reset uierr

⌨️ 快捷键说明

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