📄 uiview.c
字号:
/***
*uiview.c - Support View menu items.
*
* Copyright <C> 1985-1988, Microsoft Corporation
*
*Purpose:
* All View menu support routines, and C Debug menu support.
*
*******************************************************************************/
/* First, include version definition header */
#include <version.h>
/* Next, include TextWin's interface headers */
#include <cw/version.h>
#include <cw/windows.h>
#include <cw/edityp.h>
#include <uiext.h>
/* include dialog information */
#include <cw/dlg.h>
#include "uiview.hs"
#include "uiview.sdm"
/* Next, include QBI's headers */
#ifndef CONTEXT_H
#include <context.h>
#endif
#ifndef NAMES_H /* [1] */
#include <names.h> /* [1] */
#endif /* [1] */
#ifndef PARSER_H
#include <parser.h>
#endif
#ifndef QBIMSGS_H
#include <qbimsgs.h>
#endif
#ifndef RTPS_H
#include <rtps.h>
#endif
#ifndef TXTMGR_H
#include <txtmgr.h>
#endif
#ifndef UI_H
#include <ui.h>
#endif
#ifndef UIINT_H
#include <uiint.h>
#endif
#ifndef UTIL_H
#include <util.h>
#endif
ushort oRsOfAlphaMrs(ushort);
void NEAR DrawViewListBox(PWND, ushort, ushort);
STATICF(bool) UnloadFile(ushort); //[32]
STATICF(void) DescribeORs(void);
WORD NEAR DoViewSub (TMC);
bool NEAR FChInSet(char ch, char *szSet); //[26]
bool NEAR FValidId(char *szName); //[26]
bool fPcodeOnly;
extern ushort iHelpId; //[11]
ushort oRsInitial; /* set by CmdViewSubs() for ViewSubsDialog() */
ushort oRsView; /* set by ViewSubsDialog() for CmdViewSubs() */
ushort oRsDst; /* set by ViewSubsDialog() for CmdViewSubs() */
ushort oProcOrModule;
#define CB_LISTBOX_COL 20
#define CBMAX_EXPLEN 40 /* [10] max length of expression for instant watch */
/**********************************************************************
* oRsOfAlphaMrs(iAlpha)
* Purpose:
* Just like oRsOfAlpha, but it skips prs entries.
* Returns the oRs of the iAlpha'th alphabetically sorted mrs.
*
**********************************************************************/
ushort oRsOfAlphaMrs(iAlpha)
ushort iAlpha;
{
ushort i;
ushort oRs;
i = 0;
while (TRUE) {
if (((oRs = oRsOfAlpha (i++)) & 0x8000) == 0) {
if (oRs == 0x7fff) {
return (UNDEFINED);
}
UiRsActivate (oRs);
if (!fPcodeOnly || !(mrsCur.flags2 & (FM2_NoPcode | FM2_Include))) {
if (iAlpha-- == 0) {
return (oRs);
}
}
}
}
}
WORD FAR
WListProcModuleAndSub (tmm, sz, isz, tmc, wParam, bArg)
WORD tmm;
char *sz;
WORD isz;
TMC tmc;
WORD wParam, bArg;
{
WORD cRs, oRs;
Unreferenced (wParam);
Unreferenced (bArg);
switch (tmm) {
case tmmCount:
oProcOrModule = 0;
return ((WORD) -1);
case tmmText:
case tmmEditText:
cRs = UiAlphaORsBuild();
if (!cRs) {
SetUiErrOm ();
}
if (uierr) { //[27] if any errors occured
*sz = '\0'; //[27] return a null string if needed
return (isz == 0); //[27] no error for first time
}
if (isz >= cRs) {
return (FALSE);
}
switch (tmc) {
case tmcListModulesAndSubs: oRs = oRsOfAlpha (isz); break;
}
if (oRs == UNDEFINED) {
return (FALSE);
}
UiRsActivate (oRs);
if (oRs == oRsInitial) {
oProcOrModule = isz;
}
GetRsName (grs.oRsCur,
(grs.oRsCur & 0x8000) ? RSN_fIndent : 0,
CB_LISTBOX_COL);
strcpy (sz, bufStdMsg);
break;
}
return (TRUE);
}
/* -------------------------------- *
* View Subs *
* -------------------------------- */
STATICF(bool) UnloadFile (oRsDiscard) //[32]
ushort oRsDiscard;
{
ushort result;
EditMgrFlush1 (); // [22] [16] CmdFileSave used editmgr buffer
UiRsActivate (oRsDiscard);
DbAssert ((mrsCur.flags2 & FM2_File) != 0);
/* Give user a chance to back out of action, descan module's text
* table to SS_RUDE (need to at least descan to SS_PARSE before
* calling MrsDiscard().
*/
if (!AskRudeEditFar ())
return(FALSE); /* [32] user pressed CANCEL button */
DoDrawDebugScr ();
/* calling AskRudeEditFar can cause the output screen to be shown
* (because of RunInit()), in which case, we need to re-draw the
* list windows now.
*/
if (mrsCur.flags2 & FM2_Modified) {
/* give user a chance to save modified file */
oRsDiscard = grs.oRsCur;
if ((result = MsgBoxStd (MB_YESNOCANCEL, MSG_NotSaved)) == IDYES) {
if (!CmdFileSave()) {
/* I/O error, or user pressed CANCEL button */
if (uierr != 0)
ReportError (); /* user didn't press CANCEL */
return(FALSE); //[32]
}
}
if (result == tmcCancel)
return(FALSE); //[32]
UiRsActivate (oRsDiscard); /* CmdFileSave could activate other mrs's */
}
MrsDiscard ();
return(TRUE); //[32]
}
/**************************************************************************
* DescribeORs()
* Purpose:
* Display the type of file currently selected in the ViewSubs dialog.
* This message is one of the following (in 50 columns or less):
* 00000000011111111112222222222333333333344444444445
* 12345678901234567890123456789012345678901234567890
* xxxxxxxx.xxx is the Main Module
* xxxxxxxx.xxx is a Module
* xxxxxxxx.xxx is an Include File
* xxxxxxxx.xxx is a Document
* xxxxxxxxxxxxxxxxxx is a Subprogram in yyyyyyyy.yyy
* xxxxxxxxxxxxxxxxxx is a Function in yyyyyyyy.yyy
* 00000000011111111112222222222333333333344444444445
* 12345678901234567890123456789012345678901234567890
*
* Entry:
* grs.oRsCur identifies currently selected module.
*
**************************************************************************/
STATICF(void)
DescribeORs()
{
ushort msgId;
char szDesc[71]; //IPG- from 51, length of buffer needed to increase.
// since functions names were being truncated in view box
*szDesc = '\0';
GetRsName(grs.oRsCur, 0, (grs.oRsCur & 0x8000) ? 18 : 12);
strcat (szDesc, bufStdMsg);
ListStdMsg(MSG_Is);
strcat (szDesc, bufStdMsg);
if (grs.oRsCur & 0x8000) {
/* it is an prs, not a mrs */
msgId = (prsCur.procType == PT_FUNCTION) ?
MSG_Function : MSG_Sub;
}
else {
/* it is an mrs, not a prs */
msgId = (mrsCur.flags2 & FM2_Include) ?
MSG_IncludeFile : (mrsCur.flags2 & FM2_NoPcode) ?
MSG_Document : (grs.oMrsMain == grs.oRsCur) ?
MSG_MainModule : MSG_Module;
}
ListStdMsg(msgId);
strcat (szDesc, bufStdMsg);
if (grs.oRsCur & 0x8000) {
/* it is an prs, not a mrs */
GetRsName(grs.oMrsCur, 0, 12);
strcat (szDesc, bufStdMsg);
}
SetTmcText (tmcViewSubsDescription, szDesc);
}
BOOL FAR
FDlgViewSubs (dlm, tmc, wNew, wOld, wParam)
WORD dlm;
TMC tmc;
WORD wNew, wOld, wParam;
{
Unreferenced (wNew);
Unreferenced (wOld);
Unreferenced (wParam);
Unreferenced (tmc);
if (uierr && dlm != dlmTerm) //[36] Return FALSE if OM error, unless
return (FALSE); //[36] we are trying to terminate
switch (dlm) {
case dlmInit:
SetTmcVal (tmcListModulesAndSubs, oProcOrModule);
SetTmcListWidth (tmcListModulesAndSubs, 3); //[12]
case dlmClick:
if (uierr) //[27] if there was an error, the call
break; //[27] to oRsOfAlpha would be bogus.
oRsView = oRsOfAlpha (GetTmcVal (tmcListModulesAndSubs));
UiRsActivate (oRsView);
DescribeORs ();
break;
case dlmTerm: //[27] we always want to
return (TRUE); //[27] allow termination.
}
return (!uierr);
}
/***
*VOID NEAR CmdViewSubs ()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -