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

📄 uiview.c

📁 [随书类]Dos6.0源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
*Purpose:
*	Perform View/Subs command.
*
*Entry:
*	None.
*
*Exit:
*	mrsCur is changed to new oRs from View/Subs dialog.
*
*Exceptions:
*	None.
*******************************************************************************/
VOID NEAR CmdViewSubs()
{
    REG1 ushort oRsReg;
    sd sdName;
    HCABViewSubs hcabViewSubs;
    TMC tmc;
    ushort ogNam;

/*********************************************************************
 *    If there is selected text then we want to jump directly to
 *    that procedure. If there is no selected text, but the cursor
 *    is on the name of a procedure, then we want to bring up the
 *    list box with that procedure name selected.
 *********************************************************************/
    oRsReg = oRsInitial = UNDEFINED;

    if (GetSelText(&bufStdMsg[0], CB_IDNAM_MAX + 1) != 0) {
	/* user has selected an identifier, make it the default */
	oRsReg = 0;
    }
    else if (GetEditWord( bufStdMsg, CB_IDNAM_MAX + 1) != 0) {
	/* cursor is after an identifier */
	oRsReg = oRsInitial = 0;
    }

    if (oRsReg == 0) {
	sdName.pb = bufStdMsg;
	sdName.cb = CbSzUi(bufStdMsg);
	if (!(ogNam = OgNamOfPsd(&sdName))) {
	   /* couldn't find the ogNam don't preselect a prs */
	   oRsReg = UNDEFINED;
	}
	else {
	    oRsReg = PrsFind(ogNam) | 0x8000;		/* [1] */
	    UiRsActivate(oRsReg);
	    if (txdCur.flags & FTX_mrs) {
		/* selected name was for a prs with no text table, like a
		 * DEF FN or SUB which is only called but has not text table.
		 * Treat this the same as if nothing was selected.
		 */
		oRsReg = UNDEFINED;
	    }
	    if (oRsInitial != UNDEFINED) {
		oRsInitial = oRsReg;
		oRsReg = UNDEFINED;
	    }
	}
    }

    if ((oRsView = oRsReg) == UNDEFINED) {
	/* Selected text (if any) didn't match any known prs.
	 * Let user select prs from a list */

	DbAssert(uierr == 0)	//[29]

	hcabViewSubs = (HCABViewSubs) HcabAlloc (cabiCABViewSubs);
	/* [5] Catch HcabAlloc errors */
	if (uierr)
	    return;

	(*hcabViewSubs)->oModuleOrSub = 0;

	while (DoViewSub (tmc = TmcDoDlgFar (&dlgViewSubs, sizeof (dlgViewSubs), hcabViewSubs))) ;

	FreeCab (hcabViewSubs);

	/* user pressed CANCEL or got error (like out-of-memory) */
	if (tmc == tmcCancel || uierr != 0) {
	    return;
	}

	/* user didn't press CANCEL button */
	UiRsActivate (oRsView); 	//[30] if DIALOG_NOSAVE, oRs may be wrong
    }

    /* [5] Fix QB4.1 PTR #107, fix View/Subs Split functionality */
    /* else user wants to edit new oRs in current window */
    UiRsActivate(oRsView);
    /* open list window if only command window is open.
     * make sure active window is a list window.
     * show text table identified by grs.oRsCur in that list window.
     */
    WndAssignList();
}

WORD NEAR
DoViewSub (tmc)
TMC tmc;
{

    if (tmc != tmcDelete)	//[33]
	return (FALSE);

    if ((oRsView & 0x8000) == 0) {
	/* user selected a module */
    }
    else {
	/* deleting or moving a procedure */
	    /* deleting a procedure, make sure its not a mistake */
	    if (MsgBoxStd(MB_OKCANCEL, MSG_DelProc) != IDDEFAULT)
		return (TRUE);	 /* user pressed cancel */
    } /* deleting or moving a procedure */
    AlphaORsFree();
    oRsInitial = grs.oMrsCur;

    if (tmc == tmcDelete) {
	if ((oRsView & 0x8000) == 0) {
	    /* user selected a module */

	    UnloadFile(oRsView);
	}
	else {
	    /* user selected a procedure */

	    /* Give user a chance to back out of action */
	    if (AskCantCONT()) {
		UiRsActivate(oRsView);
		PrsDiscard();
	    }
	}
    }


    /* redraw list window behind dialog box to reflect change */
    DoDrawDebugScr();
    return (uierr == 0);
}


/*** 
*bool NEAR FChInSet(char ch, char *szSet)
*Purpose:
*	Returns TRUE if ch is in the set specified by szSet.
*
*	new for revision [26]
*
*Entry:
*	ch - The char to check for.
*	szSet - a string of characters to check ch against.
*	        if szSet[n] == '-' then
*		    check if ch is in the interval szSet[n+1]...szSet[n+2]
*
*Exit:
*	returns TRUE if ch is in the specified set.
*
*******************************************************************************/
bool NEAR FChInSet(ch, szSet)
REG2 char ch;
REG1 char *szSet;
{

    while (*szSet != 0) {
	if (*szSet == '-') {
	    if (ch >= szSet[1] && ch <= szSet[2])
	       return(TRUE);
	    szSet += 3;
	}
	else if (ch == *szSet++)
	   return(TRUE);
    }
    return(FALSE);
}

/*** 
*bool NEAR FValidId(char *szName)
*Purpose:
*	Checks if szName is a valid identifier.
*
*	new for revision [26]
*
*Entry:
*	szName - The name to check.
*
*Exit:
*	returns TRUE if szName is valid
*
*******************************************************************************/
bool NEAR FValidId(szName)
REG1 char *szName;
{
    REG2 char *szCharsCur;
    static char szCharsId[] = "-09.-AZ-az";

    /* First character must be alphabetic */
    szCharsCur = szCharsId + 4;
    do {
	if (!FChInSet(*szName++, szCharsCur))
	    return(FALSE);
	/* Subsequent characters can also be numberic or period */
	szCharsCur = szCharsId;
    } while (*szName);
   
    return(TRUE);
}

sd sdProcName;

VOID NEAR CmdNewProc (rsType)
char rsType;
{
    ushort lnCursor;
    ushort oRsProc;
    char szProcName[CB_IDNAM_MAX + 1];
    HCABNewProc hcabNewProc;
    ushort oType;	//[26]

    /* New Sub/Function is a Rude Edit */
    if (!AskRudeEditFar())
	return;   /* user wants to abort action */

    DbAssert(uierr == 0);	 //[29]

    hcabNewProc = (HCABNewProc) HcabAlloc (cabiCABNewProc);
    /* [5] Catch HcabAlloc errors */
    if (uierr)
	return;

    sdProcName.pb = szProcName;
    bufStdMsg[0] = 0;
    if (GetSelText (&bufStdMsg[0], CB_IDNAM_MAX + 1) == 0) {
	GetEditWord (bufStdMsg, CB_IDNAM_MAX + 1);
	/* fill bufStdMsg with id if cursor is after an identifier */
    }
    strcpy (szProcName, bufStdMsg );
    sdProcName.cb = CbSzUi (szProcName);
    SzToCab (hcabNewProc, szProcName, Iag (CABNewProc, szProcName));
    // [18] if SzToCab memory allocation failed, free cab and exit.
    if (uierr)
	goto CmdNewProcEnd;

Retry:
    if (TmcDoDlgFar (&dlgNewProc, sizeof (dlgNewProc), hcabNewProc) != tmcCancel) {
	SzFromCab (hcabNewProc, szProcName, CB_IDNAM_MAX + 1,	// [15]
		   Iag (CABNewProc, szProcName));
	if ((sdProcName.cb = CbSzUi (szProcName)) == 0) {
	    MsgBoxStd (MB_OK, MSG_MustSpecifyName);
	    goto Retry;
	}

	oType = OTypeOfTypeCharFar(szProcName[sdProcName.cb-1]);	//[26]
	if (oType)							//[26]
	    szProcName[--(sdProcName.cb)] = 0;				//[26]

	/* don't let user try to put param list in with name */
	if ((rsType != RS_function && oType != ET_IMP)  //[26]
		|| !FValidId(szProcName)) {		//[26]
	    MsgBoxStd (MB_OK, MSG_BadId);
	    goto Retry;
	}

	UiGrabSpace ();
	/* Don't allocate memory that could steal
	 * from our ability to execute a SYSTEM, CLEAR, or SETMEM stmt.
	 */
	if ((oRsProc = RsMake (&sdProcName, rsType)) != UNDEFINED) {
	    WndAssignList ();	/* make new proc visible in list window */
	    /* RsMake encountered no errors */
	    TxtPrsInit (oType); /* Insert module's DEFxxx state in proc */
	    /* Place cursor at end of SUB/FUNCTION line */
	    lnCursor = txdCur.cLines - 2;
	    MoveCursorPwndCur (lnCursor,
			       cbGetLineBuf (oRsProc,
					     lnCursor,
					     ps.bdpSrc.cbLogical,
					     ps.bdpSrc.pb));
	    DrawDebugScr ();
	}
	UiReleaseSpace ();
    }

CmdNewProcEnd:	// [18]
    FreeCab (hcabNewProc);
}

/*************************************************************************
* CmdViewInclude(fShow)
* Purpose:
*	Make $INCLUDE files in all list windows visible if fShow!=0,
*	or invisible if fShow==0.
*	Cursor is kept as close to current line as possible.
*
*************************************************************************/
VOID FAR CmdViewInclude(fShow)
REG1 bool fShow;
{

    if (fShow != fViewInclude) {
	DbAssert(FALSE);	//[35] shouldn't ever get here
    }
} /* CmdViewInclude */

⌨️ 快捷键说明

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