1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
/************************************************************/
/* Windows Write, Copyright 1985-1992 Microsoft Corporation */
/************************************************************/
/* chlook.c -- modify format from the keyboard or directly from dropdown */
#define NOCLIPBOARD
#define NOCTLMGR
#define NOGDICAPMASKS
#define NOWINSTYLES
#define NOWINMESSAGES
#define NOVIRTUALKEYCODES
#include <windows.h>
#include "mw.h"
#include "cmddefs.h"
#include "editdefs.h"
#include "str.h"
#include "prmdefs.h"
#include "propdefs.h"
#include "filedefs.h"
#include "dispdefs.h"
#include "menudefs.h"
/* E X T E R N A L S */
extern HMENU vhMenu;
extern int vfVisiMode;
extern int vfInsLast;
extern int vfSeeSel;
extern int fGrayChar;
extern struct UAB vuab;
#ifdef ENABLE /* myMenus and mpifntfont not used */
extern MENUHANDLE myMenus[];
extern int mpifntfont[];
#endif
extern int vifntMac;
extern int vifntApplication;
#define keyDownMask 8
CHAR rgbAgain[1 + cchINT]; /* holds last sprm with value for Again key */
/* D O C H L O O K */
/* decode ch and apply looks to pchp (or to current sel if pchp == 0) */
DoChLook(ch, pchp)
int ch;
struct CHP *pchp;
{
#ifdef ENABLE /* DoChLook not implemented yet */
typeCP cpFirst, cpLim;
int val;
int sprm;
int enbSave;
vfSeeSel = vfInsLast = fTrue;
if (ch == chAgain)
{
AddOneSprm(rgbAgain, fTrue);
vuab.uac = uacChLook;
SetUndoMenuStr(IDSTRUndoLook);
return;
}
val = fTrue;
switch(ChUpper(ch & 0377))
{
default:
/*---- Error(IDPMTBadLook);----*/
beep();
return;
case chLookStd & 0377:
sprm = sprmCPlain;
val = stcNormal;
goto LApplyCLook;
case chLookItalic & 0377:
sprm = sprmCItalic;
goto LApplyCLook;
case chLookBold & 0377:
sprm = sprmCBold;
goto LApplyCLook;
case chLookUline & 0377:
sprm = sprmCUline;
goto LApplyCLook;
case chLookShadow & 0377:
sprm = sprmCShadow;
goto LApplyCLook;
case chLookOutline & 0377:
sprm = sprmCOutline;
goto LApplyCLook;
case chLookSuper & 0377:
sprm = sprmCPos;
val = ypSubSuper;
goto LApplyCLook;
case chLookSub & 0377:
sprm = sprmCPos;
val = -ypSubSuper;
goto LApplyCLook;
case chLookSmCaps & 0377:
sprm = sprmCCsm;
val = csmSmallCaps;
goto LApplyCLook;
case chLookHpsBig & 0377:
sprm = sprmCChgHps;
val = 1;
goto LApplyCLook;
case chLookHpsSmall & 0377:
sprm = sprmCChgHps;
val = -1;
goto LApplyCLook;
case chLookFont & 0377:
/* Disable eject disk/ print image key handlers */
#define SCRDMPENB (0x2f8L)
enbSave = LDBI(SCRDMPENB);
STBI(0, SCRDMPENB);
ch = ChInpWait();
STBI(enbSave, SCRDMPENB);
if (ch < '0' || ch > '9')
{
/*---- Error(IDPMTBadLook);----*/
beep();
return;
}
sprm = sprmCChgFtc;
val = ch - '0';
/* Map from font index to system font code */
val = val >= vifntMac ? vifntApplication & 0377: mpifntfont[val];
goto LApplyCLook;
/* Paragraph looks */
case chLookGeneral & 0377:
sprm = sprmPNormal;
/*val = 0;*/
break;
case chLookLeft & 0377:
sprm = sprmPJc;
val = jcLeft;
break;
case chLookRight & 0377:
sprm = sprmPJc;
val = jcRight;
break;
case chLookJust & 0377:
sprm = sprmPJc;
val = jcBoth;
break;
case chLookCenter & 0377:
sprm = sprmPJc;
val = jcCenter;
break;
case chLookIndent & 0377:
val = czaInch/2;
sprm = sprmPFIndent;
goto LApplyPLook;
case chLookDouble & 0377:
val = czaLine * 2;
sprm = sprmPDyaLine;
goto LApplyPLook;
case chLookOpen & 0377:
val = czaLine;
sprm = sprmPDyaBefore;
goto LApplyPLook;
case chLookNest & 0377:
sprm = sprmPNest;
/*val = 0;*/
break;
case chLookUnNest & 0377:
sprm = sprmPUnNest;
/*val = 0;*/
break;
case chLookHang & 0377:
sprm = sprmPHang;
/*val = 0;*/
break;
}
/* apply look with 1 char value */
ApplyLooksParaS(pchp, sprm, val);
return;
/* apply look with cchInt char value */
LApplyPLook:
ApplyLooksPara(pchp, sprm, val);
return;
LApplyCLook:
ApplyCLooks(pchp, sprm, val);
return;
#endif /* ENABLE */
}
/* A P P L Y C L O O K S */
/* character looks. val is a 1 char value */
ApplyCLooks(pchp, sprm, val)
struct CHP *pchp;
int sprm, val;
{
/* Assemble sprm */
CHAR *pch = rgbAgain;
*pch++ = sprm;
*pch = val;
if (pchp == 0)
{
/* apply looks to current selection */
AddOneSprm(rgbAgain, fTrue);
vuab.uac = uacChLook;
SetUndoMenuStr(IDSTRUndoLook);
}
else
/* apply looks to pchp */
DoSprm(pchp, 0, sprm, pch);
}
/* A P P L Y L O O K S P A R A S */
/* val is a char value */
ApplyLooksParaS(pchp, sprm, val)
struct CHP *pchp;
int sprm, val;
{
int valT = 0;
CHAR *pch = (CHAR *)&valT;
*pch = val;
/* all the above is just to prepare bltbyte later gets the right byte order */
ApplyLooksPara(pchp, sprm, valT);
}
/* A P P L Y L O O K S P A R A */
/* val is an integer value. Char val's must have been bltbyte'd into val */
ApplyLooksPara(pchp, sprm, val)
struct CHP *pchp;
int sprm, val;
{
#ifdef ENABLE /* related to footnote */
if (FWriteCk(fwcNil)) /* Just check for illegal action in footnote */
#endif
{
/* set Again stuff since we may have been called from the menu */
CHAR *pch = rgbAgain;
*pch++ = sprm;
bltbyte(&val, pch, cchINT);
AddOneSprm(rgbAgain, fTrue);
vuab.uac = uacChLook;
SetUndoMenuStr(IDSTRUndoLook);
}
return;
}
#ifdef ENABLE /* fnChar/fnPara */
/* F N C H A R P L A I N */
void fnCharPlain()
{
ApplyCLooks(0, sprmCPlain, 0);
}
/* F N C H A R B O L D */
void fnCharBold()
{
ApplyCLooks(0, sprmCBold, FMenuUnchecked(imiBold));
}
void fnCharItalic()
{
ApplyCLooks(0, sprmCItalic, FMenuUnchecked(imiItalic));
}
void fnCharUnderline()
{
ApplyCLooks(0, sprmCUline, FMenuUnchecked(imiUnderline));
}
void fnCharSuperscript()
{
ApplyCLooks(0, sprmCPos, FMenuUnchecked(imiSuper) ? ypSubSuper : 0);
}
void fnCharSubscript()
{
ApplyCLooks(0, sprmCPos, FMenuUnchecked(imiSub) ? -ypSubSuper : 0);
}
void fnParaNormal()
{
extern int vfPictSel;
ApplyLooksParaS(0, sprmPNormal, 0);
if (vfPictSel)
CmdUnscalePic();
}
void fnParaLeft()
{
ApplyLooksParaS(0, sprmPJc, jcLeft);
}
void fnParaCentered()
{
ApplyLooksParaS(0, sprmPJc, jcCenter);
}
void fnParaRight()
{
ApplyLooksParaS(0, sprmPJc, jcRight);
}
void fnParaJustified()
{
ApplyLooksParaS(0, sprmPJc, jcBoth);
}
void fnParaOneandhalfspace()
{
ApplyLooksPara(0, sprmPDyaLine, czaLine * 3 / 2);
}
void fnParaDoublespace()
{
ApplyLooksPara(0, sprmPDyaLine, czaLine * 2);
}
void fnParaSinglespace()
{
ApplyLooksPara(0, sprmPDyaLine, czaLine);
}
int
FMenuUnchecked(imi)
int imi;
{ /* Return true if there is NO check mark in front of menu */
int flag;
if (fGrayChar)
return true;
flag = CheckMenuItem(vhMenu, imi, MF_CHECKED);
CheckMenuItem(vhMenu, imi, flag); /* back to original status */
return(flag == MF_UNCHECKED ? true : false);
#ifdef SAND
GetItemMark(myMenus[CHARACTER - 1], imi, &ch);
/***** WRONG COMMENT BELOW! *****/
return (ch != 18); /* Return true is there is a check mark in front of menu */
#endif /* SAND */
}
#endif
int ChInpWait()
{
#ifdef ENABLE /* CpInpWait not implemented yet */
EVENT event;
int i;
for (i = 0; i < 15000; i++)
{
if(GetNextEvent(keyDownMask, &event))
return (event.message.wl & 0x007f);
}
return -1; /* Will cause a beep if the user times out */
#endif /* ENABLE */
}
#ifdef CASHMERE /* smcap, overstrike, dbline, open para, visible mode */
fnCharSmallcaps()
{
ApplyCLooks(0, sprmCCsm, FMenuUnchecked(7) ? csmSmallCaps : csmNormal);
}
fnCharOutline()
{
ApplyCLooks(0, sprmCOutline, FMenuUnchecked(5));
}
fnCharShadow()
{
ApplyCLooks(0, sprmCShadow, FMenuUnchecked(6));
}
fnParaOpenspace()
{
ApplyLooksPara(0, sprmPDyaBefore, czaLine);
}
fnVisiMode()
{
vfVisiMode = !vfVisiMode;
TrashAllWws();
}
#endif /* CASHMERE */
|