Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

850 lines
30 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* WRITE Globals */
  5. #define NOGDICAPMASKS
  6. #define NOVIRTUALKEYCODES
  7. #define NOWINMESSAGES
  8. #define NOWINSTYLES
  9. #define NOSYSMETRICS
  10. #define NOICON
  11. #define NOKEYSTATE
  12. #define NOSYSCOMMANDS
  13. #define NOSHOWWINDOW
  14. #define NOATOM
  15. #define NOCLIPBOARD
  16. #define NOCOLOR
  17. #define NOCREATESTRUCT
  18. #define NOCTLMGR
  19. #define NODRAWTEXT
  20. #define NOMB
  21. #define NOMEMMGR
  22. #define NOMETAFILE
  23. #define NOMINMAX
  24. #define NOOPENFILE
  25. #define NOPEN
  26. #define NOREGION
  27. #define NOSCROLL
  28. #define NOSOUND
  29. #define NOWH
  30. #define NOWINOFFSETS
  31. #define NOWNDCLASS
  32. #define NOCOMM
  33. #include <windows.h>
  34. #include "mw.h"
  35. #define NOUAC
  36. #include "cmddefs.h"
  37. #include "dispdefs.h"
  38. #include "docdefs.h"
  39. #include "filedefs.h"
  40. #include "fmtdefs.h" /* formatdefs.h */
  41. #include "propdefs.h"
  42. #include "fkpdefs.h"
  43. #include "printdef.h" /* printdefs.h */
  44. #include "wwdefs.h"
  45. #include "prmdefs.h"
  46. #include "rulerdef.h"
  47. #include "editdefs.h"
  48. #define NOSTRERRORS
  49. #include "str.h"
  50. #include "fontdefs.h"
  51. #include "globdefs.h" /* text for static strings */
  52. VAL rgval [ivalMax]; /* General purpose parm-passing array */
  53. #ifdef ENABLE
  54. VAL rgvalAgain[ivalMax];
  55. #endif
  56. CHAR vchDecimal = '?'; /* "decimal point" character
  57. real value set in initwin.c */
  58. int vzaTabDflt = vzaTabDfltDef; /* width of default tab in twips */
  59. /* pen windows */
  60. VOID (FAR PASCAL *lpfnRegisterPenApp)(WORD, BOOL) = NULL;
  61. /* page buffers stuff */
  62. CHAR *rgibpHash;
  63. int iibpHashMax;
  64. struct BPS *mpibpbps;
  65. int ibpMax;
  66. int ibpMaxFloat = 128;
  67. typeTS tsMruBps;
  68. CHAR (*rgbp)[cbSector];
  69. struct ERFN dnrfn[rfnMax];
  70. int rfnMac;
  71. typeTS tsMruRfn;
  72. int vfBuffersDirty = FALSE;
  73. /* doc stuff */
  74. struct DOD (**hpdocdod)[];
  75. int docCur; /* current doc */
  76. int docMac;
  77. int docScrap;
  78. #ifdef CASHMERE /* No docBuffer in WRITE */
  79. int docBuffer;
  80. #endif
  81. int docUndo;
  82. #if defined(JAPAN) & defined(DBCS_IME) /* Doc for Insert IR_STRING from IME [yutakan]*/
  83. int docIRString;
  84. #endif
  85. int docRulerSprm;
  86. int docMode = docNil; /* doc with "Page nnn" message */
  87. int vpgn; /* current page number of document */
  88. typeCP cpMinCur;
  89. typeCP cpMacCur;
  90. /* file stuff */
  91. struct FCB (**hpfnfcb)[];
  92. int fnMac;
  93. int ferror;
  94. int errIO; /* i/o error code */
  95. int versFile = 0;
  96. int vrefFile = 0;
  97. int vrefSystem = 0;
  98. #ifdef DBCS_VERT
  99. CHAR szAtSystem [] = szAtSystemDef; // for vertical-sysfont
  100. #endif
  101. WORD vwDosVersion; /* Current DOS version, maj in lo 8, minor in hi */
  102. int vfInitializing = TRUE; /* TRUE during inz, FALSE thereafter */
  103. int vfDiskFull = FALSE; /* Disk full error, fn != fnScratch */
  104. int vfSysFull = FALSE; /* Disk holding fnScratch is full */
  105. int vfDiskError = FALSE; /* Serious Disk Error has occurred */
  106. int vfLargeSys = FALSE;
  107. int vfMemMsgReported = FALSE;
  108. int vfCloseFilesInDialog = FALSE; /* Set inside OPEN, SAVE dialog */
  109. int vfSizeMode;
  110. int vfPictSel;
  111. int vfPMS = FALSE; /* Currently doing picture move/size */
  112. int vfnWriting = fnNil; /* fn that gets written to disk */
  113. int vfnSaving = fnNil; /* Like above, but longer lifetime */
  114. int vibpWriting;
  115. CHAR (**vhrgbSave)[]; /* emergency space for save events */
  116. struct FPRM fprmCache; /* scratch file property modifiers */
  117. /* global boolean flags */
  118. int vfTextOnlySave = FALSE; /* reset by each new/open, use by save as */
  119. int vfBackupSave; /* use by save as box */
  120. #if defined(JAPAN) || defined(KOREA)
  121. int vfWordWrap; /*t-Yoshio WordWrap flag*/
  122. #elif defined(TAIWAN) || defined(PRC) //Daniel/MSTC, 1993/02/25
  123. int vfWordWrap= 1; // always set it on
  124. #endif
  125. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  126. int vfImeHidden; /*T-HIROYN ImeHidden Mode flag*/
  127. #endif
  128. int vfOutOfMemory = FALSE;
  129. int vfOvertype = FALSE; /* still using this ? */
  130. int vfPrintMode = FALSE; /* TRUE if format to printer mode on screen */
  131. int vfDraftMode = FALSE; /* TRUE if the user choose the draft mode option */
  132. int vfRepageConfirm = FALSE; /* repaginate confirm page break option */
  133. int vfVisiMode = FALSE; /* TRUE if visible char mode on */
  134. int vfModeIsFootnote; /* TRUE when szMode contains string "Footnote" */
  135. int vfNoIdle = FALSE;
  136. int vfDeactByOtherApp = FALSE; /* TRUE if we are deactivated by another app */
  137. int vfDownClick = FALSE; /* TRUE when we received a down click in our window */
  138. int vfCursorVisible = FALSE; /* TRUE if want to show the cursor in a mouseless
  139. system */
  140. int vfMouseExist = FALSE; /* TRUE if mouse hardware is installed */
  141. int vfInLongOperation = FALSE; /* TRUE if we are still in a long operation
  142. so that the cursor should stay hourglass */
  143. int vfScrapIsPic = FALSE; /* Whether docScrap contains picture */
  144. BOOL fDestroyOK;
  145. int fGrayChar; /* TRUE if selection consists of mixed char properties */
  146. int fGrayPara; /* TRUE if selection consists of mixed para properties */
  147. int vfPrPages = FALSE; /* TRUE if print page range */
  148. int vpgnBegin; /* starting page number to print */
  149. int vpgnEnd; /* ending page number to print */
  150. int vcCopies = 1; /* nubmer of copies to print */
  151. BOOL vfPrErr = FALSE; /* TRUE iff a printing error occurred */
  152. BOOL vfPrDefault = TRUE; /* TRUE iff Write chose printer */
  153. BOOL vfWarnMargins = FALSE; /* TRUE if we should warn user about bad margins */
  154. /* Show that Print, Help, and Glossary processing is uninitialized */
  155. int vfPrintIsInit = FALSE;
  156. int vfHelpIsInit = FALSE;
  157. int vfGlyIsInit = FALSE;
  158. int vfInsEnd = false; /* Is insert point at end-of-line? */
  159. int vfInsertOn;
  160. int vfMakeInsEnd;
  161. int vfSelAtPara;
  162. int vfSeeSel = FALSE;
  163. int vfLastCursor; /* TRUE iff the last selection was made
  164. by an Up/Down cursor key */
  165. int vfGotoKeyMode = FALSE; /* Apply GOTO meta mode to next cursor
  166. key */
  167. #ifdef SAND
  168. int vftcDaisyPS = -1;
  169. int vftcDaisyNoPS = -1;
  170. int vfDaisyWheel = FALSE;
  171. int vifntApplication;
  172. int vifntMac;
  173. #endif /* SAND */
  174. #ifdef UNUSED
  175. int vfCanPrint;
  176. #endif
  177. int vchInch;
  178. int vfMouse;
  179. typeCP vcpSelect;
  180. #ifdef DEBUG
  181. int fIbpCheck = TRUE;
  182. int fPctbCheck = TRUE;
  183. #ifdef CKSM
  184. unsigned (**hpibpcksm) []; /* Checksums for buffer page contents */
  185. unsigned ibpCksmMax; /* Alloc limit for cksm array */
  186. #endif
  187. #endif /* DEBUG */
  188. int vWordFmtMode = FALSE; /* used during saves. If false, no conversion is
  189. done. True is convert to Word format,CVTFROMWORD
  190. is translate chars from Word character set at
  191. save */
  192. /* **************************************************************** */
  193. /* strings, predefined file names - definitions stored in globdefs.h */
  194. /* */
  195. /* NOTE NOTE NOTE Win 3.0 */
  196. /* */
  197. /* Some of these strings have now been moved from globdefs.h */
  198. /* to write.rc. This was done to easy localization. */
  199. /* */
  200. /* **************************************************************** */
  201. CHAR (**hszTemp)[];
  202. CHAR (**hszGlosFile)[];
  203. CHAR (**hszXfOptions)[];
  204. CHAR szMode[30]; /* buffer for "Page nnn" message */
  205. CHAR szEmpty[] = "";
  206. CHAR szExtDoc[] = szExtDocDef;
  207. CHAR szExtWordDoc[] = szExtWordDocDef;
  208. CHAR szExtGls[] = szExtGlsDef;
  209. CHAR szExtDrv[] = szExtDrvDef;
  210. /* for Intl added szExtWordDoc entry */
  211. CHAR *mpdtyszExt [] = { szExtDoc, szExtGls, szEmpty, szEmpty,
  212. szEmpty, szEmpty,
  213. szExtWordDoc };
  214. CHAR szExtBackup[] = szExtBackupDef;
  215. CHAR szExtWordBak[] = szExtWordBakDef;
  216. /* WIN.INI: our app entry */
  217. CHAR szWriteProduct[] = szWriteProductDef;
  218. CHAR szFontEntry[] = szFontEntryDef; /* WIN.INI: our font list */
  219. CHAR szWriteDocPrompt[25]; /* OpenFile prompts */
  220. CHAR szScratchFilePrompt[25];
  221. CHAR szSaveFilePrompt[25];
  222. #if defined(KOREA) // jinwoo : 10/16/92
  223. CHAR szAppName[13]; /* For message box headings */
  224. #else
  225. CHAR szAppName[10]; /* For message box headings */
  226. #endif
  227. CHAR szUntitled[20]; /* Unnamed doc */
  228. CHAR szSepName[] = szSepNameDef; /* separator between product
  229. name and file name in header */
  230. #ifdef STYLES
  231. CHAR szSshtEmpty[] = szSshtEmptyDef;
  232. #endif /* STYLES */
  233. /* Strings for parsing the user profile. */
  234. CHAR szWindows[] = szWindowsDef;
  235. CHAR szDevice[] = szDeviceDef;
  236. CHAR szDevices[] = szDevicesDef;
  237. CHAR szBackup[] = szBackupDef;
  238. #if defined(JAPAN) || defined(KOREA) //Win3.1J
  239. CHAR szWordWrap[] = szWordWrapDef;
  240. #endif
  241. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  242. CHAR szImeHidden[] = szImeHiddenDef;
  243. #endif
  244. /* Strings for our window classes (MUST BE < 39 CHARS) */
  245. CHAR szParentClass[] = szParentClassDef;
  246. CHAR szDocClass[] = szDocClassDef;
  247. CHAR szRulerClass[] = szRulerClassDef;
  248. CHAR szPageInfoClass[] = szPageInfoClassDef;
  249. #ifdef ONLINEHELP
  250. CHAR szHelpDocClass[] = szHelpDocClassDef;
  251. #endif
  252. CHAR szWRITEText[30];
  253. CHAR szFree[15];
  254. CHAR szMWTemp [] = szMWTempDef;
  255. CHAR szSystem [] = szSystemDef;
  256. CHAR szMw_acctb[] = szMw_acctbDef;
  257. CHAR szNullPort[] = szNullPortDef;
  258. CHAR szNone[15];
  259. CHAR szMwlores[] = szMwloresDef;
  260. CHAR szMwhires[] = szMwhiresDef;
  261. CHAR szMw_icon[] = szMw_iconDef;
  262. CHAR szMw_menu[] = szMw_menuDef;
  263. CHAR szScrollBar[] = szScrollBarDef;
  264. CHAR szAltBS[20];
  265. CHAR szPmsCur[] = szPmsCurDef;
  266. CHAR szHeader[15];
  267. CHAR szFooter[15];
  268. CHAR szModern[] = szModernDef;
  269. CHAR szRoman[] = szRomanDef;
  270. CHAR szSwiss[] = szSwissDef;
  271. CHAR szScript[] = szScriptDef;
  272. CHAR szDecorative[] = szDecorativeDef;
  273. CHAR szExtSearch[] = szExtSearchDef; /* store default search spec */
  274. CHAR szLoadFile[25];
  275. CHAR szCvtLoadFile[45];
  276. CHAR szIntl[] = szIntlDef;
  277. CHAR szsDecimal[] = szsDecimalDef;
  278. CHAR szsDecimalDefault[] = szsDecimalDefaultDef;
  279. CHAR sziCountry[] = sziCountryDef;
  280. CHAR sziCountryDefault[5];
  281. /* table of unit names from util2.c - Must agree with cmddefs.h */
  282. CHAR *mputsz[utMax] =
  283. {
  284. " ",
  285. " ",
  286. " ",
  287. " ",
  288. " ",
  289. " ",
  290. };
  291. /* For convenience, we reserves Mac's st concept, the difference is that
  292. cch stored in the first byte of the array includes the '\0' so that we
  293. can use it as a sz by chopping the 1st byte */
  294. CHAR stBuf[256];
  295. CHAR szCaptionSave[cchMaxFile]; /* save the caption text */
  296. /* insert stuff */
  297. CHAR rgchInsert[cchInsBlock]; /* temporary insert buffer */
  298. typeCP cpInsert; /* beginning cp of insert block */
  299. int ichInsert; /* number of chars used in rgchInsert */
  300. typeFC fcMacPapIns = fc0;
  301. typeFC fcMacChpIns = fc0;
  302. struct FKPD vfkpdCharIns;
  303. struct FKPD vfkpdParaIns;
  304. int vdlIns; /* Display line for current insert */
  305. int vcchBlted=0; /* # of chars blted onto vdlIns */
  306. int vidxpInsertCache=-1; /* Current position in vfli.rgdxp
  307. during fast insert */
  308. int vfInsFontTooTall; /* Ins chr will be too tall for line */
  309. struct EDL *vpedlAdjustCp;
  310. int vfSuperIns; /* whether in super-fast insert mode */
  311. typeCP cpInsLastInval;
  312. int vdypCursLineIns;
  313. int vdypBase;
  314. int vdypAfter;
  315. int vxpIns;
  316. int vxpMacIns;
  317. int vypBaseIns;
  318. int vfTextBltValid;
  319. typeCP cpWall = cp0;
  320. int vfInsLast;
  321. /* Keyboard shift/lock flags */
  322. int vfShiftKey = FALSE; /* whether Shift is down */
  323. int vfCommandKey = FALSE; /* whether Ctrl key is down */
  324. int vfOptionKey = FALSE; /* whether Alt key is down */
  325. /* cache stuff */
  326. CHAR *vpchFetch;
  327. CHAR (**hgchExpand)[];
  328. int vichFetch;
  329. int vdocFetch;
  330. int vccpFetch;
  331. int vcchFetch;
  332. int visedCache;
  333. int vdocExpFetch;
  334. int vdocParaCache = docNil;
  335. int vdocPageCache;
  336. int vdocSectCache;
  337. typeCP vcpFetch;
  338. typeCP vcpFirstParaCache;
  339. typeCP vcpLimParaCache;
  340. typeCP vcpMinPageCache;
  341. typeCP vcpMacPageCache;
  342. typeCP vcpLimSectCache;
  343. typeCP vcpFirstSectCache;
  344. /* cache stuff for display purpose */
  345. int ctrCache = 0;
  346. int itrFirstCache = 0;
  347. int itrLimCache = itrMaxCache;
  348. int dcpCache = 0;
  349. typeCP cpCacheHint = cp0;
  350. /* The picture bitmap cache */
  351. int vdocBitmapCache = docNil;
  352. typeCP vcpBitmapCache;
  353. HBITMAP vhbmBitmapCache = NULL;
  354. BOOL vfBMBitmapCache;
  355. /* style property stuff */
  356. int ichpMacFormat;
  357. struct CHP vchpNormal;
  358. struct CHP vchpAbs;
  359. struct CHP vchpInsert;
  360. struct CHP vchpFetch;
  361. struct CHP vchpSel; /* Holds the props when the selection is
  362. an insert point */
  363. struct CHP *pchpDefault;
  364. struct CHP (**vhgchpFormat)[];
  365. struct PAP vpapPrevIns;
  366. struct PAP vpapAbs;
  367. struct PAP *vppapNormal;
  368. struct SEP vsepNormal;
  369. struct SEP vsepAbs;
  370. struct SEP vsepStd;
  371. struct SEP vsepPage;
  372. #define ESPRM(cch, sgc, spr, fSame, fClobber) \
  373. (cch + (ESPRM_sgcMult * sgc) + (ESPRM_spr * spr) + \
  374. (ESPRM_fSame * fSame) + (ESPRM_fClobber * fClobber))
  375. /* ESPRM fields are:
  376. cch 2 bits of length, 0 means determined by procedure
  377. sgc 2 bits of group: char, para, or running head
  378. spr 1 bit priority, fClobber sprms clobber sprms in same group with
  379. priority less than or equal
  380. fSame means overrides previous instance of same sprm
  381. fClobber see spr
  382. */
  383. #define ESPRMChar ESPRM(2,0,0,1,0)
  384. #define ESPRMPara ESPRM(2,1,1,1,0)
  385. #define ESPRMParaLong ESPRM(3,1,1,1,0)
  386. /* This table corresponds to sprm's in prmdefs.h */
  387. CHAR dnsprm[sprmMax] = {
  388. /* 0 */ 0, /* */
  389. ESPRMParaLong, /* PLMarg */
  390. /* 2 */ ESPRMParaLong, /* PRMarg */
  391. ESPRMParaLong, /* PFIndent */
  392. /* 4 */ ESPRMPara, /* PJc */
  393. ESPRM(1,1,1,1,0), /* Ruler */
  394. /* 6 */ ESPRM(0,1,1,1,0), /* Ruler1 */
  395. ESPRMPara, /* PKeep */
  396. /* 8 */ ESPRM(2,1,1,1,1), /* PNormal (formerly Pstyle) */
  397. ESPRM(2,2,0,1,0), /* PRhc running head code */
  398. /* 10 */ ESPRM(0,1,0,1,1), /* PSame, clobbers all tabs but related ones */
  399. ESPRMParaLong, /* PDyaLine */
  400. /* 12 */ ESPRMParaLong, /* PDyaBefore */
  401. ESPRMParaLong, /* PDyaAfter */
  402. /* 14 */ ESPRM(1,1,1,0,0), /* PNest */
  403. ESPRM(1,1,1,0,0), /* PUnNest */
  404. /* 16 */ ESPRM(1,1,1,0,0), /* PHang - hanging indent */
  405. ESPRM(0,1,1,1,0), /* PRgtbd */
  406. /* 18 */ ESPRMPara, /* PKeepFollow */
  407. ESPRM(1,1,0,1,1), /* PCAll - NUSED */
  408. /* 20 */ ESPRMChar, /* CBold */
  409. ESPRMChar, /* CItalic */
  410. /* 22 */ ESPRMChar, /* CUline */
  411. ESPRMChar, /* CPos */
  412. /* 24 */ ESPRMChar, /* CFtc */
  413. ESPRMChar, /* CHps */
  414. /* 26 */ ESPRM(0,0,0,1,1), /* CSame */
  415. ESPRMChar, /* CChgFtc */
  416. /* 28 */ ESPRMChar, /* CChgHps */
  417. ESPRM(2,0,0,1,0), /* CPlain */
  418. /* 30 */ ESPRMChar, /* CShadow */
  419. ESPRMChar, /* COutline */
  420. /* 32 */ ESPRMChar, /* CCsm - case modification. */
  421. /* The following sprms are unused as of 10/10/84: */
  422. ESPRMChar, /* CStrike */
  423. /* 34 */ ESPRMChar, /* DLine - ? */
  424. ESPRMChar, /* CPitch - obs. */
  425. /* 36 */ ESPRMPara, /* COverset */
  426. ESPRM(2,0,0,1,1), /* CStc Style */
  427. /* The preceding sprms are unused as of 10/10/84: */
  428. /* 38 */ ESPRM(0,0,0,0,0), /* CMapFtc */
  429. ESPRM(0,0,0,0,0), /* COldFtc */
  430. /* 40 */ ESPRM(0,1,1,1,0) /* PRhcNorm -- cch is 4 */
  431. };
  432. /* ruler stuff */
  433. int mprmkdxa[rmkMARGMAX]; /* stores dxa of indents on ruler */
  434. int rgxaRulerSprm[3];
  435. /* This is a global parameter to AdjustCp; if FALSE, no invalidation will
  436. take place. */
  437. BOOL vfInvalid = TRUE; /* if FALSE, no invalidation will take place
  438. in AdjustCp */
  439. int viDigits = 2;
  440. BOOL vbLZero = FALSE;
  441. int utCur = utDefault; /* may be inch or cm depending on value
  442. in globdefs.h */
  443. short itxbMac;
  444. struct TXB (**hgtxb)[];
  445. struct UAB vuab;
  446. /* search stuff */
  447. CHAR (**hszFlatSearch)[];
  448. #if defined(JAPAN) || defined(KOREA)
  449. CHAR (**hszDistFlatSearch)[];
  450. #endif
  451. CHAR (**hszSearch)[];
  452. CHAR (**hszReplace)[];
  453. CHAR (**hszRealReplace)[]; /* used for building replacement text */
  454. CHAR (**hszCaseReplace)[]; /* used for building replacement text with
  455. appropriate capitalization. */
  456. CHAR *szSearch;
  457. BOOL fReplConfirm = TRUE;
  458. BOOL fSearchCase = FALSE;
  459. #if defined(JAPAN) || defined(KOREA)
  460. BOOL fSearchDist = TRUE;
  461. #endif
  462. BOOL fSearchWord = FALSE;
  463. BOOL fSpecialMatch;
  464. BOOL fMatchedWhite = FALSE;
  465. BOOL fParaReplace = FALSE;
  466. /*BOOL fSearchForward = TRUE;*/
  467. typeCP cpMatchLim;
  468. int vfDidSearch = FALSE;
  469. /* Strings for printer selection */
  470. CHAR (**hszPrinter)[]; /* name of the current printer */
  471. CHAR (**hszPrDriver)[]; /* name of the current printer driver */
  472. CHAR (**hszPrPort)[]; /* name of the current printer port */
  473. CHAR szNul[cchMaxIDSTR]; /* name of the null device */
  474. BOOL vfPrinterValid = TRUE; /* FALSE iff the above strings do not
  475. describe the printer DC */
  476. /* global dxa/dya stuff */
  477. int vdxaPaper;
  478. int vdyaPaper;
  479. int vdxaTextRuler; /* from section props used to calculate right margin */
  480. int dxpLogInch;
  481. int dypLogInch;
  482. int dxpLogCm;
  483. int dypLogCm;
  484. int dxaPrPage;
  485. int dyaPrPage;
  486. int dxpPrPage;
  487. int dypPrPage;
  488. int ypSubSuperPr;
  489. #ifdef KINTL
  490. int dxaAdjustPerCm; /* The amount of kick-back to be added to xa per cm in
  491. XaQuantize() to offset a round-off error. */
  492. #endif /* ifdef KINTL */
  493. /* actual position of the cursor line */
  494. int vxpCursLine;
  495. int vypCursLine;
  496. int vdypCursLine;
  497. int vfScrollInval; /* means scroll did not take and UpdateWw must be repeated */
  498. /* selection stuff */
  499. int vfSelHidden = FALSE;
  500. struct SEL selCur; /* current selection (i.e. sel in current ww) */
  501. /* window stuff */
  502. struct WWD rgwwd[wwMax];
  503. int wwMac = 0;
  504. int wwCur = wwNil;
  505. #ifdef ONLINEHELP
  506. int wwHelp=wwNil; /* Help Window */
  507. #endif
  508. int wwClipboard=wwNil; /* Clipboard Display Window */
  509. struct WWD *pwwdCur = &rgwwd[0]; /* current window descriptor */
  510. int vipgd = -1; /* page number displayed in lower corner */
  511. int xpAlpha;
  512. int ypAlpha;
  513. RECT rectParent;
  514. struct FLI vfli =
  515. {
  516. cp0, 0, cp0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0,
  517. FALSE, FALSE, 0, 0, 0, 0, 0, FALSE, 0, 0,
  518. /* rgdxp */
  519. 0x0000, 0xFFFE, 0xffff, 0xffff, 0xe0ff, 0xff3f, 0x00ff, 0xff07,
  520. 0x00fe, 0xff03, 0x00f8, 0xff00, 0x0ff0, 0x7f80, 0x3fe0, 0x3fe0,
  521. 0x7fc0, 0x1ff0, 0xffc0, 0x1ff8, 0xff81, 0x0ffc, 0xff83, 0x0ffe,
  522. 0xff87, 0x0fff, 0x8f07, 0x071f, 0x060f, 0x870f, 0x060f, 0x870f,
  523. 0x8f0f, 0x871f, 0xff0f, 0x87ff, 0xff0f, 0x87ff, 0xff0f, 0x87ff,
  524. 0x1f0f, 0x878f, 0x0f0f, 0x870f, 0x0007, 0x070f, 0x8087, 0x0f1f,
  525. 0xe083, 0x0f7e, 0xff81, 0x0ffc, 0xffc0, 0x1ff8, 0x7fc0, 0x1ff0,
  526. 0x1fe0, 0x3fc0, 0x00f0, 0x7f00, 0x00fc, 0xff01, 0x00fe, 0xff03,
  527. 0xe0ff, 0xff3f, 0x8BEC, 0xFC46, 0xF8D1, 0x4689, 0x2BEA, 0x8BFF,
  528. 0xEBF7, 0xFF55, 0x0A76, 0x468B, 0x2BEC, 0x50C6, 0x8B57, 0x085E,
  529. 0x5FFF, 0xFF08, 0x0A76, 0x8B56, 0xEA46, 0xC703, 0x8B50, 0x085E,
  530. 0x5FFF, 0xFF0C, 0x0A76, 0x468B, 0x03EC, 0x50C6, 0x8B57, 0x085E,
  531. 0x5FFF, 0xFF08, 0x0A76, 0x468B, 0x2BFA, 0x50C6, 0x468B, 0x03EA,
  532. 0x50C7, 0x5E8B, 0xFF08, 0x0C5F, 0x468B, 0xB1FA, 0xD306, 0x03F8,
  533. 0x8BF0, 0xFC46, 0xF8D3, 0xF803, 0x7639, 0x7DEC, 0x5EA6, 0x835F,
  534. 0x02ED, 0xE58B, 0x5D1F, 0xCA4D, 0x0008, 0x0000, 0x0000, 0x0000,
  535. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  536. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  537. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  538. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  539. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  540. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  541. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  542. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  543. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  544. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  545. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  546. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  547. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  548. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  549. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  550. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  551. /* rgch */
  552. 0x11, 0x30, 0x5c, 0x71, 0x84, 0x75, 0x83, 0x84,
  553. 0x30, 0x72, 0x89, 0x30, 0x60, 0x71, 0x85, 0x7c,
  554. 0x64, 0x30, 0x7A, 0x7D, 0x77, 0x7C, 0x64, 0x60,
  555. 0x33, 0x44, 0x61, 0x7A, 0x67, 0x76, 0x33, 0x7B,
  556. 0x72, 0x60, 0x33, 0x71, 0x76, 0x76, 0x7D, 0x33,
  557. 0x71, 0x61, 0x7C, 0x66, 0x74, 0x7B, 0x67, 0x33,
  558. 0x67, 0x7C, 0x33, 0x6A, 0x7C, 0x66, 0x33, 0x71,
  559. 0x6A, 0x33, 0x51, 0x7C, 0x71, 0x3F, 0x33, 0x51,
  560. 0x7C, 0x71, 0x3F, 0x33, 0x51, 0x61, 0x6A, 0x72,
  561. 0x7D, 0x3F, 0x33, 0x50, 0x7B, 0x7A, 0x3E, 0x50,
  562. 0x7B, 0x66, 0x76, 0x7D, 0x3F, 0x33, 0x72, 0x7D,
  563. 0x77, 0x33, 0x43, 0x72, 0x67, 0x00, 0x00, 0x00,
  564. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  565. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  566. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  567. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  568. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  569. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  570. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  571. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  572. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  573. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  574. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  575. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  576. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  577. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  578. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  579. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  580. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  581. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  582. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  583. };
  584. /* Screen dependent measurements */
  585. int DxaPerPix; /* number of twips per xp */
  586. int DyaPerPix; /* number of twips per yp */
  587. int xpInch; /* number of xp's per inch */
  588. int xpMaxUser;
  589. int xpSelBar; /* width of the selection bar in xp's */
  590. int dxpScrlBar; /* width of the scroll bar in xp's */
  591. int dypScrlBar; /* height of the scroll bar in xp's */
  592. int dxpInfoSize; /* width of the page info area */
  593. int xpRightMax;
  594. int xpMinScroll;
  595. int xpRightLim;
  596. int ypMaxWwInit;
  597. int ypMaxAll;
  598. int dypMax;
  599. int dypAveInit;
  600. int dypWwInit;
  601. int dypBand;
  602. int dypRuler = 0;
  603. int dypSplitLine;
  604. int ypSubSuper; /* adjustment from base line for sub/super */
  605. /* idstr stuff */
  606. int idstrCurrentUndo = IDSTRUndoBase;
  607. /* the following two may eventually be deleted -- check usage in ruler.c */
  608. int vfTabsChanged = FALSE; /* TRUE if any tabs are changed from the ruler */
  609. int vfMargChanged = FALSE; /* TRUE if any indents are changed from the ruler */
  610. #ifdef CASHMERE
  611. struct TBD rgtbdRulerSprm[itbdMax];
  612. #endif /* CASHMERE */
  613. #ifdef RULERALSO
  614. BOOL vfDisableMenus = FALSE;/* TRUE if top level menus (including
  615. the system menu are to be disabled */
  616. int vfTempRuler; /* TRUE if ruler is created because of dialog box creation */
  617. HWND vhDlgTab = (HWND)NULL;
  618. HWND vhDlgIndent = (HWND)NULL;
  619. struct TBD rgtbdRuler[itbdMax];
  620. #endif /* RULERALSO */
  621. int flashID = 0; /* timer ID for flashing before we put up a messagebox when we are not the active app */
  622. /*-----------------------------------------------------*/
  623. /* Merged MGLOBALS.C and MGLOBALS2.C ..pault 10/26/89 */
  624. /*-----------------------------------------------------*/
  625. /* internal memory stuff */
  626. int *memory; /* ptr to beginning of free space, get incremented after
  627. allocating chunks from memory */
  628. #ifdef OURHEAP
  629. int *pmemMax;/* ptr to max of memory */
  630. CHAR * pmemStart; /* point to start of memory after global data */
  631. unsigned vcbMemTotal; /* total number of free memory bytes */
  632. unsigned cbTotQuotient;/* for calculating % of free space */
  633. unsigned cbTot; /* for calculating % of free space */
  634. #endif
  635. unsigned cwHeapFree; /* number of free heap space in words */
  636. /* MS-WINDOWS related variables */
  637. HWND hParentWw = NULL; /* handle to parent ww (created in
  638. interface module) */
  639. HANDLE hMmwModInstance = NULL; /* handle to memory module instance */
  640. HANDLE vhReservedSpace; /* space reserved for control manger */
  641. long rgbBkgrnd = -1L; /* rgb color of the background */
  642. long rgbText = -1L; /* rgb color of the text */
  643. HBRUSH hbrBkgrnd = NULL; /* handle to background brush */
  644. long ropErase = WHITENESS; /* raster op to erase the screen */
  645. BOOL vfMonochrome = FALSE; /* TRUE iff display is monochrome */
  646. HMENU vhMenu = NULL; /* handle to top level menu */
  647. CHAR *vpDlgBuf; /* pointer to buffer for dialog boxes */
  648. #ifdef INEFFLOCKDOWN /* SEE NOTE IN FINITFARPROCS() */
  649. /* far pointers to dialog functions exported to WINDOWS */
  650. FARPROC lpDialogOpen;
  651. FARPROC lpDialogSaveAs;
  652. FARPROC lpDialogPrinterSetup;
  653. FARPROC lpDialogPrint;
  654. FARPROC lpDialogCancelPrint;
  655. FARPROC lpDialogRepaginate;
  656. FARPROC lpDialogSetPage;
  657. FARPROC lpDialogPageMark;
  658. FARPROC lpDialogHelp;
  659. #ifdef ONLINEHELP
  660. FARPROC lpDialogHelpInner;
  661. #endif /* ONLINEHELP */
  662. FARPROC lpDialogGoTo;
  663. FARPROC lpDialogFind;
  664. FARPROC lpDialogChange;
  665. FARPROC lpDialogCharFormats;
  666. FARPROC lpDialogParaFormats;
  667. FARPROC lpDialogRunningHead;
  668. FARPROC lpDialogTabs;
  669. FARPROC lpDialogDivision;
  670. FARPROC lpDialogAlert;
  671. FARPROC lpDialogConfirm;
  672. FARPROC lpFontFaceEnum;
  673. FARPROC lpFPrContinue;
  674. FARPROC lpDialogWordCvt;
  675. #endif /* ifdef INEFFLOCKDOWN */
  676. /* Mouse status flags and cursors */
  677. int vfDoubleClick = FALSE; /* whether click is double click */
  678. HCURSOR vhcHourGlass; /* handle to hour glass cursor */
  679. HCURSOR vhcIBeam; /* handle to i-beam cursor */
  680. HCURSOR vhcArrow; /* handle to arrow cursor */
  681. HCURSOR vhcBarCur; /* handle to back arrow cursor */
  682. #ifdef PENWIN // for PenWindows (5/21/91) patlam
  683. #include <penwin.h>
  684. HCURSOR vhcPen; /* handle to pen cursor */
  685. int (FAR PASCAL *lpfnProcessWriting)(HWND, LPRC) = NULL;
  686. VOID (FAR PASCAL *lpfnPostVirtualKeyEvent)(WORD, BOOL) = NULL;
  687. VOID (FAR PASCAL *lpfnTPtoDP)(LPPOINT, int) = NULL;
  688. BOOL (FAR PASCAL *lpfnCorrectWriting)(HWND, LPSTR, int, LPRC, DWORD, DWORD) = NULL;
  689. BOOL (FAR PASCAL *lpfnSymbolToCharacter)(LPSYV, int, LPSTR, LPINT) = NULL;
  690. #endif
  691. /* MS-WINDOWS stuff */
  692. HANDLE vhSysMenu;
  693. HDC vhMDC = NULL; /* memory DC compatible with the screen */
  694. int dxpbmMDC = 0; /* width of the bitmap attatched to vhMDC */
  695. int dypbmMDC = 0; /* height of the bitmap attatched to vhMDC */
  696. HBITMAP hbmNull; /* handle to an empty bitmap */
  697. HDC vhDCPrinter = NULL; /* DC for the printer */
  698. HWND vhWnd; /* handle to document window */
  699. HANDLE vhAccel; /* handle to menu key accelerator table */
  700. /* modeless dialog handles */
  701. HWND vhDlgRunningHead = (HWND)NULL;
  702. HWND vhDlgFind = (HWND)NULL;
  703. /* handle to modeless Find dialog box */
  704. HWND vhDlgChange = (HWND)NULL;
  705. /* handle to modeless Change dialog box */
  706. HWND vhWndRuler = (HWND)NULL;
  707. HWND vhWndCancelPrint = (HWND)NULL;
  708. /* handle to modeless Cancel Print dialog box */
  709. #ifndef NOMORESIZEBOX
  710. HWND vhWndSizeBox; /* handle to the size box */
  711. #endif
  712. HWND vhWndPageInfo; /* handle to the page info window */
  713. HWND vhWndMsgBoxParent = (HWND)NULL; /* parent of the message box */
  714. int vfSkipNextBlink = FALSE;
  715. /* skip next timed off-transition of caret */
  716. int vfFocus = FALSE; /* Whether we have the input focus */
  717. int vfOwnClipboard = FALSE;
  718. /* Whether we are the owner of the clipboard */
  719. MSG vmsgLast; /* last message received */
  720. HFONT vhfPageInfo = NULL; /* handle to the font for the page info */
  721. int ypszPageInfo; /* y position in window to write page info */
  722. /* font related variables */
  723. int vifceMac = ifceMax;
  724. union FCID vfcidScreen;
  725. union FCID vfcidPrint;
  726. struct FCE rgfce[ifceMax];
  727. struct FCE *vpfceMru;
  728. struct FCE *vpfceScreen;
  729. struct FCE *vpfcePrint;
  730. struct FMI vfmiScreen;
  731. struct FMI vfmiPrint;
  732. #ifndef NEWFONTENUM
  733. int aspectXFont;
  734. int aspectYFont;
  735. #endif
  736. #ifdef SYSENDMARK
  737. HFONT vhfSystem = NULL; /* handle to the standard system font for
  738. chEMark. */
  739. struct FMI vfmiSysScreen; /* to keep the metrics info for the system
  740. font. */
  741. int vrgdxpSysScreen[chFmiMax - chFmiMin];
  742. /* Used by vfmiSysScreen. */
  743. #endif /* KANJI */
  744. #if defined(JAPAN) || defined(KOREA) /*t-Yoshio*/
  745. unsigned char Zenstr1[256];
  746. unsigned char Zenstr2[256];
  747. #endif