1 /************************************************************************/
2 /*									*/
3 /*  Ted, main module.							*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"tedConfig.h"
8 
9 #   include	<stddef.h>
10 #   include	<stdio.h>
11 
12 #   include	"tedApp.h"
13 #   include	"tedAppResources.h"
14 #   include	"tedAppFront.h"
15 #   include	"tedDocFront.h"
16 #   include	"tedRuler.h"
17 #   include	"tedDocument.h"
18 
19 #   include	<appUnit.h>
20 #   include	<psBuildConfigFiles.h>
21 #   include	<sioGeneral.h>
22 #   include	<sioStdout.h>
23 #   include	"tedFileConvert.h"
24 
25 #   include	<appDebugon.h>
26 
27 /************************************************************************/
28 
29 static AppConfigurableResource TEDApplicationResourceTable[]=
30 {
31     /********************************************************************/
32     /*  Application defaults.						*/
33     /*  2)  "magnification" is duplicate. It exists for the		*/
34     /*	application and for the font chooser tool.			*/
35     /********************************************************************/
36     APP_RESOURCE( "fileFileNotRtf",
37 		offsetof(TedAppResources,tarFileNotRtf),
38 		"File is not in Rich Text Format. Open anyway?" ),
39     APP_RESOURCE( "headFootNotReachable",
40 	    offsetof(TedAppResources,tarHeadFootNotReachable),
41 	    "There are not enough pages in the section to edit "
42 	    "this Header/Footer." ),
43 
44     APP_RESOURCE( "cannotRecover",
45 	    offsetof(TedAppResources,tarCannotRecover),
46 	    "Can not recover from this trace file. "
47 	    "Try to unlock." ),
48 
49     /********************************/
50     /*  Application file menu.	*/
51     /*  Application windows menu.	*/
52     /********************************/
53     APP_RESOURCE( "appFileMenuText",
54 		offsetof(TedAppResources,tarAppFileMenuText),
55 		"File" ),
56     APP_RESOURCE( "appWinMenuText",
57 		offsetof(TedAppResources,tarAppWinMenuText),
58 		"Window" ),
59 
60     /********************************/
61     /*  Document file menu.		*/
62     /*  Document edit menu.		*/
63     /*  Document windows menu.	*/
64     /*  Document Font menu.		*/
65     /*  Document Format menu.	*/
66     /*  Document Table menu.	*/
67     /*  Document Tool menu.		*/
68     /*  Document Help menu.		*/
69     /********************************/
70     APP_RESOURCE( "docFileMenuText",
71 		offsetof(TedAppResources,tarDocFileMenuText),
72 		"File" ),
73     APP_RESOURCE( "docEditMenuText",
74 		offsetof(TedAppResources,tarDocEditMenuText),
75 		"Edit" ),
76     APP_RESOURCE( "docInsertMenuText",
77 		offsetof(TedAppResources,tarDocInsertMenuText),
78 		"Insert" ),
79     APP_RESOURCE( "docWinMenuText",
80 		offsetof(TedAppResources,tarDocWinMenuText),
81 		"Window" ),
82     APP_RESOURCE( "docFontMenuText",
83 		offsetof(TedAppResources,tarDocFontMenuText),
84 		"Font" ),
85     APP_RESOURCE( "docFormatMenuText",
86 		offsetof(TedAppResources,tarDocFormatMenuText),
87 		"Format" ),
88     APP_RESOURCE( "docTableMenuText",
89 		offsetof(TedAppResources,tarDocTableMenuText),
90 		"Table" ),
91     APP_RESOURCE( "docToolsMenuText",
92 		offsetof(TedAppResources,tarDocToolMenuText),
93 		"Tools" ),
94     APP_RESOURCE( "helpMenuText",
95 		offsetof(TedAppResources,tarHelpMenuText),
96 		"Help" ),
97 
98     /**/
99 #   ifdef __VMS
100     APP_RESOURCE( "documentFileName",
101 		offsetof(TedAppResources,tarAppHelpFileName),
102 		"TED$ROOT:[Ted]TedDocument-en_US.rtf" ),
103 #   else
104     APP_RESOURCE( "documentFileName",
105 		offsetof(TedAppResources,tarAppHelpFileName),
106 		DOCUMENT_DIR "/TedDocument-en_US.rtf" ),
107 #   endif
108 
109     /**/
110     APP_RESOURCE( "pageNumberFormat",
111 	    offsetof(TedAppResources,tarPageNumberFormat),
112 	    "Page %p/%P, Section %s/%S" ),
113 
114     /**/
115     APP_RESOURCE( "selectionColor",
116 		offsetof(TedAppResources,tarSelectionColor),
117 		"LightSteelBlue" ),
118     APP_RESOURCE( "copiedSelectionColor",
119 		offsetof(TedAppResources,tarCopiedSelectionColor),
120 		"gray70" ),
121 
122     /**/
123     APP_RESOURCE( "showTableGrid",
124 		offsetof(TedAppResources,tarShowTableGridString),
125 		"1" ),
126 
127     /**/
128     APP_RESOURCE( "autoHyphenate",
129 		offsetof(TedAppResources,tarAutoHyphenateString),
130 		"0" ),
131 
132     /**/
133     APP_RESOURCE( "shadingMeshTwips",
134 		offsetof(TedAppResources,tarShadingMeshTwipsString),
135 		(char *)0 ),
136 
137     /**/
138     APP_RESOURCE( "pageGapMM",
139 		offsetof(TedAppResources,tarPageGapMMString),
140 		(char *)0 ),
141     /**/
142     APP_RESOURCE( "lenientRtf",
143 		offsetof(TedAppResources,tarLenientRtfString),
144 		"0" ),
145     APP_RESOURCE( "traceEdits",
146 		offsetof(TedAppResources,tarTraceEditsString),
147 		"1" ),
148     APP_RESOURCE( "pdfOutline",
149 		offsetof(TedAppResources,tarPdfOutlineString),
150 		"1" ),
151     APP_RESOURCE( "overridePaperSize",
152 		offsetof(TedAppResources,tarOverridePaperSizeString),
153 		"0" ),
154 };
155 
156 
157 static AppConfigurableResource TEDFileMessageResourceTable[]=
158     {
159 	/********************************/
160 	/*  Format for 'New' title	*/
161 	/********************************/
162 	APP_RESOURCE( "namelessFormat",
163 		    offsetof(AppFileMessageResources,afmrNamelessTitleFormat),
164 		    "Nameless %d" ),
165 
166 	/********************************/
167 	/*  Really Close? Dialog.	*/
168 	/********************************/
169 	APP_RESOURCE( "reallyCloseQuestion",
170 		    offsetof(AppFileMessageResources,afmrReallyCloseQuestion),
171 		    "Do you want to save the changes you made to this text?" ),
172 	APP_RESOURCE( "reallyCloseSave",
173 		    offsetof(AppFileMessageResources,afmrReallyCloseSaveIt),
174 		    "Yes" ),
175 	APP_RESOURCE( "reallyCloseDontSave",
176 		    offsetof(AppFileMessageResources,afmrReallyCloseDontSave),
177 		    "No" ),
178 	APP_RESOURCE( "reallyCloseCancel",
179 		    offsetof(AppFileMessageResources,afmrReallyCloseCancel),
180 		    "Cancel" ),
181 
182 	/********************************/
183 	/*  Really Quit? Dialog.	*/
184 	/********************************/
185 	APP_RESOURCE( "reallyQuitQuestion",
186 		    offsetof(AppFileMessageResources,afmrReallyQuitQuestion),
187 		    "Do you want to save changes to texts?" ),
188 	APP_RESOURCE( "reallyQuitReview",
189 		    offsetof(AppFileMessageResources,afmrReallyQuitReview),
190 		    "Yes" ),
191 	APP_RESOURCE( "reallyQuitQuitAnyway",
192 		    offsetof(AppFileMessageResources,afmrReallyQuitAnyway),
193 		    "No" ),
194 	APP_RESOURCE( "reallyQuitCancel",
195 		    offsetof(AppFileMessageResources,afmrReallyQuitCancel),
196 		    "Cancel" ),
197 
198 	/********************************/
199 	/*  Messages about  a file.	*/
200 	/********************************/
201 	APP_RESOURCE( "fileFileNoAccess",
202 		    offsetof(AppFileMessageResources,afmrFileNoAccess),
203 		    "Cannot open file." ),
204 	APP_RESOURCE( "fileFileReadOnly",
205 		    offsetof(AppFileMessageResources,afmrFileReadOnly),
206 		    "File is Readonly." ),
207 	APP_RESOURCE( "fileNoSuchFile",
208 		    offsetof(AppFileMessageResources,afmrNoSuchFileMessage),
209 		    "This file does not exist." ),
210 	APP_RESOURCE( "fileNotWritable",
211 		    offsetof(AppFileMessageResources,afmrFileNotWritable),
212 		    "You cannot write to this file." ),
213 	APP_RESOURCE( "fileMakeIt",
214 		    offsetof(AppFileMessageResources,afmrMakeItQuestion),
215 		    "There is no such file. Make it?" ),
216 
217     };
218 
219 static TedAppResources			TEDResources;
220 
221 /************************************************************************/
222 /*									*/
223 /*  Display the online manual.						*/
224 /*									*/
225 /************************************************************************/
226 
APP_MENU_CALLBACK_H(tedDocManual,option,voided,e)227 static APP_MENU_CALLBACK_H( tedDocManual, option, voided, e )
228     {
229     EditDocument *	ed= (EditDocument *)voided;
230     EditApplication *	ea= ed->edApplication;
231 
232     tedManual( option, ea, ed->edToplevel.atTopWidget );
233     }
234 
APP_MENU_CALLBACK_H(tedAppManual,option,voidea,e)235 static APP_MENU_CALLBACK_H( tedAppManual, option, voidea, e )
236     {
237     EditApplication *	ea= (EditApplication *)voidea;
238 
239     tedManual( option, ea, ea->eaToplevel.atTopWidget );
240     }
241 
242 /************************************************************************/
243 /*									*/
244 /*  Application file menu.						*/
245 /*									*/
246 /************************************************************************/
247 
248 static AppMenuItem TED_AppFileMenuItems[]=
249 {
250     {
251     "appFileMenuNewText",	"New",
252     "appFileMenuNewKey",	"Ctrl <Key>n",
253     "appFileMenuNewKeyText",	"^N",		ITEMtyOPTION, appAppFileNew,
254     },
255     {
256     "appFileMenuOpenText",	"Open",
257     "appFileMenuOpenKey",	"Ctrl <Key>o",
258     "appFileMenuOpenKeyText",	"^O",		ITEMtyOPTION, appAppFileOpen,
259     },
260     {
261     "appFileMenuQuitText",	"Quit",
262     "appFileMenuQuitKey",	(char *)0,
263     "appFileMenuQuitKeyText",	(char *)0,	ITEMtyOPTION, appAppFileQuit,
264     },
265 };
266 
267 /************************************************************************/
268 /*									*/
269 /*  Application windows menu.						*/
270 /*									*/
271 /************************************************************************/
272 
273 static AppMenuItem TED_AppWinMenuItems[]=
274 {
275     {
276     "appFileMenuNewText",	"New",
277     "appFileMenuNewKey",	"Ctrl <Key>n",
278     "appFileMenuNewKeyText",	"^N",		ITEMtyOPTION, appAppFileNew,
279     },
280 };
281 
282 /************************************************************************/
283 /*									*/
284 /*  Document file menu.							*/
285 /*									*/
286 /************************************************************************/
287 
288 static AppMenuItem TED_DocFileMenuItems[]=
289 {
290 #   define	TEDmiDocFileNew			0
291     {
292     "docFileMenuNewText",	"New",
293     "docFileMenuNewKey",	"Ctrl <Key>n",
294     "docFileMenuNewKeyText",	"^N",		ITEMtyOPTION, appDocFileNew,
295     },
296 #   define	TEDmiDocFileOpen		1
297     {
298     "docFileMenuOpenText",	"Open",
299     "docFileMenuOpenKey",	"Ctrl <Key>o",
300     "docFileMenuOpenKeyText",	"^O",		ITEMtyOPTION, appDocFileOpen,
301     },
302 #   define	TEDmiDocFileSave		2
303     {
304     "docFileMenuSaveText",	"Save",
305     "docFileMenuSaveKey",	"Ctrl <Key>s",
306     "docFileMenuSaveKeyText",	"^S",		ITEMtyOPTION, appDocFileSave,
307     },
308 #   define	TEDmiDocFileSaveAs		3
309     {
310     "docFileMenuSaveAsText",	"Save As ...",
311     "docFileMenuSaveAsKey",	(char *)0,
312     "docFileMenuSaveAsKeyText",	(char *)0,	ITEMtyOPTION, appDocFileSaveAs,
313     },
314 #   define	TEDmiDocFilePrint		4
315     {
316     "docFileMenuPrintText",	"Print ...",
317     "docFileMenuPrintKey",	"Ctrl <Key>p",
318     "docFileMenuPrintKeyText",	"^P",		ITEMtyOPTION, tedDocFilePrint,
319     },
320 #   define	TEDmiDocFileProperties		5
321     {
322     "docFileMenuPropsText",	"Properties ...",
323     "docFileMenuPropsKey",	(char *)0,
324     "docFileMenuPropsKeyText",	(char *)0,	ITEMtyOPTION, tedDocFileProps,
325     },
326 #   define	TEDmiDocFileUnlock		6
327     {
328     "docFileMenuUnlockText",	"Unlock",
329     "docFileMenuUnlockKey",	(char *)0,
330     "docFileMenuUnlockKeyText",	(char *)0,	ITEMtyOPTION, tedDocFileUnlock,
331     },
332 #   define	TEDmiDocFileRecover		7
333     {
334     "docFileMenuRecoverText",	"Recover",
335     "docFileMenuRecoverKey",	(char *)0,
336     "docFileMenuRecoverKeyText",(char *)0,	ITEMtyOPTION, tedDocFileRecover,
337     },
338 #   define	TEDmiDocFileClose		8
339     {
340     "docFileMenuCloseText",	"Close",
341     "docFileMenuCloseKey",	(char *)0,
342     "docFileMenuCloseKeyText",	(char *)0,	ITEMtyOPTION, appDocFileClose,
343     },
344 
345 #   define	TEDmiDocFileQuitSeparator	9
346     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
347 
348 #   define	TEDmiDocFileQuit		10
349     {
350     "docFileMenuQuitText",	"Quit",
351     "docFileMenuQuitKey",	(char *)0,
352     "docFileMenuQuitKeyText",	(char *)0,	ITEMtyOPTION, appDocFileQuit,
353     },
354 };
355 
356 /************************************************************************/
357 /*									*/
358 /*  Document edit menu.							*/
359 /*									*/
360 /************************************************************************/
361 
362 static AppMenuItem TED_DocEditMenuItems[]=
363 {
364 #   define	TEDmiDocEditUndo	0
365     {
366     "docEditMenuUndoText",	"Undo",
367     "docEditMenuUndoKey",	"Ctrl <Key>z",
368     "docEditMenuUndoKeyText",	"^C",		ITEMtyOPTION, tedDocEditUndo,
369     },
370 #   define	TEDmiDocEditRepeat	1
371     {
372     "docEditMenuRepeatText",	"Repeat",
373     "docEditMenuRepeatKey",	"Ctrl <Key>y",
374     "docEditMenuRepeatKeyText",	"^Y",		ITEMtyOPTION, tedDocEditRepeat,
375     },
376 #   define	TEDmiDocEditCopy	2
377     {
378     "docEditMenuCopyText",	"Copy",
379     "docEditMenuCopyKey",	"Ctrl <Key>c",
380     "docEditMenuCopyKeyText",	"^C",		ITEMtyOPTION, appDocEditCopy,
381     },
382 #   define	TEDmiDocEditCut		3
383     {
384     "docEditMenuCutText",	"Cut",
385     "docEditMenuCutKey",	"Ctrl <Key>x",
386     "docEditMenuCutKeyText",	"^X",		ITEMtyOPTION, appDocEditCut,
387     },
388 #   define	TEDmiDocEditPaste	4
389     {
390     "docEditMenuPasteText",	"Paste",
391     "docEditMenuPasteKey",	"Ctrl <Key>v",
392     "docEditMenuPasteKeyText",	"^V",		ITEMtyOPTION, tedDocEditPaste,
393     },
394 #   define	TEDmiDocEditSelectAll	5
395     {
396     "docEditMenuSelAllText",	"Select All",
397     "docEditMenuSelAllKey",	"Ctrl <Key>a",
398     "docEditMenuSelAllKeyText",	"^A",	ITEMtyOPTION, appDocEditSelAll,
399     },
400 
401 				    /*  6  */
402     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
403 
404 #   define	TEDmiDocEditFind	7
405     {
406     "docToolMenuFindText",		"Find",
407     "docToolMenuFindKey",		"Ctrl <Key>f",
408     "docToolMenuFindKeyText",		"^F",
409 					ITEMtyOPTION, tedDocToolFind,
410     },
411 #   define	TEDmiDocEditFindNext	8
412     {
413     "docToolMenuFindNextText",		"Find Next",
414     "docToolMenuFindNextKey",		"<Key>F3",
415     "docToolMenuFindNextKeyText",	"F3",
416 					ITEMtyOPTION, tedDocToolFindNext,
417     },
418 };
419 
420 /************************************************************************/
421 /*									*/
422 /*  Document edit menu.							*/
423 /*									*/
424 /************************************************************************/
425 
426 static AppMenuItem TED_DocInsertMenuItems[]=
427 {
428 #   define	TEDmiDocInsertInsPict		0
429     {
430     "docInsertMenuInsPictText",		"Image ...",
431     "docInsertMenuInsPictKey",		(char *)0,
432     "docInsertMenuInsPictKeyText",	(char *)0,
433 					ITEMtyOPTION, tedDocInsertImage,
434     },
435 #   define	TEDmiDocInsertInsSymbol		1
436     {
437     "docInsertMenuInsertSymbolText",	"Symbol",
438     "docInsertMenuInsertSymbolKey",	(char *)0,
439     "docInsertMenuInsertSymbolKeyText",	(char *)0,
440 					ITEMtyOPTION, tedDocToolInsertSymbol,
441     },
442 #   define	TEDmiDocInsertInsHyperlink	2
443     {
444     "docInsertMenuHyperlinkText",	"Hyperlink",
445     "docInsertMenuHyperlinkKey",	"Ctrl <Key>k",
446     "docInsertMenuHyperlinkKeyText",	"^K",
447 					ITEMtyOPTION, tedDocInsertLink,
448     },
449 #   define	TEDmiDocInsertInsBookmark	3
450     {
451     "docInsertMenuBookmarkText",	"Bookmark",
452     "docInsertMenuBookmarkKey",		(char *)0,
453     "docInsertMenuBookmarkKeyText",	(char *)0,
454 					ITEMtyOPTION, tedDocInsertBookmark,
455     },
456 #   define	TEDmiDocInsertInsFootnote	4
457     {
458     "docInsertMenuFootnoteText",	"Footnote",
459     "docInsertMenuFootnoteKey",		(char *)0,
460     "docInsertMenuFootnoteKeyText",	(char *)0,
461 					ITEMtyOPTION, tedDocInsertFootnote,
462     },
463 #   define	TEDmiDocInsertInsEndnote	5
464     {
465     "docInsertMenuEndnoteText",		"Endnote",
466     "docInsertMenuEndnoteKey",		(char *)0,
467     "docInsertMenuEndnoteKeyText",	(char *)0,
468 					ITEMtyOPTION, tedDocInsertEndnote,
469     },
470 #   define	TEDmiDocInsertInsChftnsep	6
471     {
472     "docInsertMenuChftnsepText",	"Footnote Separator",
473     "docInsertMenuChftnsepKey",		(char *)0,
474     "docInsertMenuChftnsepKeyText",	(char *)0,
475 					ITEMtyOPTION, tedDocInsertChftnsep,
476     },
477 #   define	TEDmiDocInsertInsFile		7
478     {
479     "docInsertMenuInsertFileText",	"File ...",
480     "docInsertMenuInsertFileKey",	(char *)0,
481     "docInsertMenuInsertFileKeyText",	(char *)0,
482 					ITEMtyOPTION, tedDocInsertFile,
483     },
484 #   define	TEDmiDocInsertInsTable		8
485     {
486     "docInsertMenuInsertTableText",	"Table",
487     "docInsertMenuInsertTableKey",	(char *)0,
488     "docInsertMenuInsertTableKeyText",	(char *)0,
489 					ITEMtyOPTION, tedDocTableInsertTable,
490     },
491 #   define	TEDmiDocInsertInsPageNumber	9
492     {
493     "docInsertMenuInsertPageNumberText",	"Page Number",
494     "docInsertMenuInsertPageNumberKey",		(char *)0,
495     "docInsertMenuInsertPageNumberKeyText",	(char *)0,
496 				    ITEMtyOPTION, tedDocInsertPageNumber,
497     },
498 
499     /*  10  */
500     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
501 
502 #   define	TEDmiDocInsertInsLineBreak	11
503     {
504     "docInsertMenuInsertLineBreakText",	"Line Break",
505     "docInsertMenuInsertLineBreakKey",		(char *)0,
506     "docInsertMenuInsertLineBreakKeyText",	(char *)0,
507 				    ITEMtyOPTION, tedDocInsertLineBreak,
508     },
509 #   define	TEDmiDocInsertInsPageBreak	12
510     {
511     "docInsertMenuInsertPageBreakText",	"Page Break",
512     "docInsertMenuInsertPageBreakKey",		(char *)0,
513     "docInsertMenuInsertPageBreakKeyText",	(char *)0,
514 				    ITEMtyOPTION, tedDocInsertPageBreak,
515     },
516 #   define	TEDmiDocInsertInsColumnBreak	13
517     {
518     "docInsertMenuInsertColumnBreakText",	"Column Break",
519     "docInsertMenuInsertColumnBreakKey",	(char *)0,
520     "docInsertMenuInsertColumnBreakKeyText",	(char *)0,
521 				    ITEMtyOPTION, tedDocInsertColumnBreak,
522     },
523 #   define	TEDmiDocInsertInsSectBreak	14
524     {
525     "docInsertMenuInsertSectBreakText",	"Section Break",
526     "docInsertMenuInsertSectBreakKey",		(char *)0,
527     "docInsertMenuInsertSectBreakKeyText",	(char *)0,
528 				    ITEMtyOPTION, tedDocMenuInsertSectBreak,
529     },
530 
531 };
532 
533 /************************************************************************/
534 /*									*/
535 /*  Document windows menu.						*/
536 /*									*/
537 /************************************************************************/
538 
539 static AppMenuItem TED_DocWinMenuItems[]=
540 {
541     {
542     "docWinMenuCloseText",	"Close",
543     "docWinMenuCloseKey",	(char *)0,
544     "docWinMenuCloseKeyText",	(char *)0,	ITEMtyOPTION, appDocFileClose,
545     },
546 };
547 
548 /************************************************************************/
549 /*									*/
550 /*  Document font menu.							*/
551 /*									*/
552 /************************************************************************/
553 
554 static AppMenuItem TED_DocFontMenuItems[]=
555 {
556 #   define	TEDmiDocFontBold	0
557     {
558     "docFontMenuBoldText",	"Bold",
559     "docFontMenuBoldKey",	"Ctrl <Key>b",
560     "docFontMenuBoldKeyText",	"^B",
561 				ITEMtyTOGGLE_OFF, tedDocFontBold,
562     },
563 #   define	TEDmiDocFontItalic	1
564     {
565     "docFontMenuItalicText",	"Italic",
566     "docFontMenuItalicKey",	"Ctrl <Key>i",
567     "docFontMenuItalicKeyText",	"^I",
568 				ITEMtyTOGGLE_OFF, tedDocFontItalic,
569     },
570 #   define	TEDmiDocFontUnderlined	2
571     {
572     "docFontMenuUnderlText",	"Underlined",
573     "docFontMenuUnderlKey",	"Ctrl <Key>u",
574     "docFontMenuUnderlKeyText",	"^U",
575 				ITEMtyTOGGLE_OFF, tedDocFontUnderlined,
576     },
577 #   define	TEDmiDocFontSuperscript	3
578     {
579     "docFontMenuSuperscriptText",	"Superscript",
580     "docFontMenuSuperscriptKey",	(char *)0,
581     "docFontMenuSuperscriptKeyText",	(char *)0,
582 				ITEMtyTOGGLE_OFF, tedDocFontSupersub,
583     },
584 #   define	TEDmiDocFontSubscript	4
585     {
586     "docFontMenuSubscriptText",		"Subscript",
587     "docFontMenuSubscriptKey",		(char *)0,
588     "docFontMenuSubscriptKeyText",	(char *)0,
589 				ITEMtyTOGGLE_OFF, tedDocFontSupersub,
590     },
591 
592 #   define	TEDmiDocFontToggleSeparator	5
593     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
594 
595     /*  6  */
596     {
597     "docFontMenuCopyText",	"Copy Font",
598     "docFontMenuCopyKey",	(char *)0,
599     "docFontMenuCopyKeyText",	(char *)0,	ITEMtyOPTION, tedDocFontCopy,
600     },
601 #   define	TEDmiDocFontPaste	7
602     {
603     "docFontMenuPasteText",	"Paste Font",
604     "docFontMenuPasteKey",	(char *)0,
605     "docFontMenuPasteKeyText",	(char *)0,	ITEMtyOPTION, tedDocFontPaste,
606     },
607 
608     /*  8  */
609     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
610 
611     /*  9  */
612     {
613     "docFontMenuToolText",	"Font Tool",
614     "docFontMenuToolKey",	(char *)0,
615     "docFontMenuToolKeyText",	(char *)0,	ITEMtyOPTION, tedDocToolFont,
616     },
617 };
618 
619 /************************************************************************/
620 /*									*/
621 /*  Document 'Table' menu.						*/
622 /*									*/
623 /************************************************************************/
624 
625 static AppMenuItem TED_DocTableMenuItems[]=
626 {
627 #   define	TEDmiDocTableInsertTable	0
628     {
629     "docTableInsertTableText",		"Insert Table",
630     "docTableInsertTableKey",		(char *)0,
631     "docTableInsertTableKeyText",	(char *)0,
632 					ITEMtyOPTION, tedDocTableInsertTable,
633     },
634 #   define	TEDmiDocTableAddRow		1
635     {
636     "docTableAddRowText",		"Add Row",
637     "docTableAddRowKey",		(char *)0,
638     "docTableAddRowKeyText",		(char *)0,
639 					ITEMtyOPTION, tedDocTableAddRow,
640     },
641 #   define	TEDmiDocTableAddColumn		2
642     {
643     "docTableAddColumnText",		"Add Column",
644     "docTableAddColumnKey",		(char *)0,
645     "docTableAddColumnKeyText",	(char *)0,
646 					ITEMtyOPTION, tedDocTableAddColumn,
647     },
648 
649 #   define	TEDmiDocTableInsertSeparator	3
650     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
651 
652 #   define	TEDmiDocTableSelectTable	4
653     {
654     "docTableSelectTableText",		"Select Table",
655     "docTableSelectTableKey",		(char *)0,
656     "docTableSelectTableKeyText",	(char *)0,
657 					ITEMtyOPTION, tedDocTableSelectTable,
658     },
659 #   define	TEDmiDocTableSelectRow		5
660     {
661     "docTableSelectRowText",		"Select Row",
662     "docTableSelectRowKey",		(char *)0,
663     "docTableSelectRowKeyText",	(char *)0,
664 					ITEMtyOPTION, tedDocTableSelectRow,
665     },
666 #   define	TEDmiDocTableSelectColumn	6
667     {
668     "docTableSelectColumnText",		"Select Column",
669     "docTableSelectColumnKey",		(char *)0,
670     "docTableSelectColumnKeyText",	(char *)0,
671 					ITEMtyOPTION, tedDocTableSelectColumn,
672     },
673 
674 #   define	TEDmiDocTableSelectSeparator	7
675     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
676 
677 #   define	TEDmiDocTableDeleteTable	8
678     {
679     "docTableDeleteTableText",		"Delete Table",
680     "docTableDeleteTableKey",		(char *)0,
681     "docTableDeleteTableKeyText",	(char *)0,
682 					ITEMtyOPTION, tedDocTableDeleteTable,
683     },
684 #   define	TEDmiDocTableDeleteRow		9
685     {
686     "docTableDeleteRowText",		"Delete Row",
687     "docTableDeleteRowKey",		(char *)0,
688     "docTableDeleteRowKeyText",	(char *)0,
689 					ITEMtyOPTION, tedDocTableDeleteRow,
690     },
691 #   define	TEDmiDocTableDeleteColumn	10
692     {
693     "docTableDeleteColumnText",		"Delete Column",
694     "docTableDeleteColumnKey",		(char *)0,
695     "docTableDeleteColumnKeyText",	(char *)0,
696 					ITEMtyOPTION, tedDocTableDeleteColumn,
697     },
698 
699 #   define	TEDmiDocTableDeleteSeparator	11
700     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
701 
702 #   define	TEDmiDocTableDrawGrid		12
703     {
704     "docTableDrawGridText",		"Draw Table Grid",
705     "docTableDrawGridKey",		(char *)0,
706     "docTableDrawGridKeyText",		(char *)0,
707 					ITEMtyTOGGLE_ON, tedDocTableDrawGrid,
708     },
709 };
710 
711 /************************************************************************/
712 /*									*/
713 /*  Document format menu.						*/
714 /*									*/
715 /************************************************************************/
716 
717 static AppMenuItem TED_DocFormatMenuItems[]=
718 {
719 #   define	TEDmiDocFormatOnePara			0
720     {
721     "docFormatMenuOneParaText",		"Make One Paragraph",
722     "docFormatMenuOneParaKey",		(char *)0,
723     "docFormatMenuOneParaKeyText",	(char *)0,
724 					ITEMtyOPTION, tedDocFormatOnePara,
725     },
726 
727     /*  1  */
728 #   define	TEDmiDocFormatOneParaSep		1
729     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
730 
731     /*  2  */
732     {
733     "docFormatMenuCopyRulText",		"Copy Ruler",
734     "docFormatMenuCopyRulKey",		(char *)0,
735     "docFormatMenuCopyRulKeyText",	(char *)0,
736 					ITEMtyOPTION, tedDocFormatCopyRul,
737     },
738 
739 #   define	TEDmiDocFormatPasteRuler		3
740     {
741     "docFormatMenuPasteRulText",	"Paste Ruler",
742     "docFormatMenuPasteRulKey",		(char *)0,
743     "docFormatMenuPasteRulKeyText",	(char *)0,
744 					ITEMtyOPTION, tedDocFormatPasteRul,
745     },
746 
747 #   define	TEDmiDocFormatIncIndent		4
748     {
749     "docFormatMenuIncreaseIndentText",	"Increase Indent",
750     "docFormatMenuIncreaseIndentKey",		(char *)0,
751     "docFormatMenuIncreaseIndentKeyText",	(char *)0,
752 				    ITEMtyOPTION, tedDocFormatIncreaseIndent,
753     },
754 
755 #   define	TEDmiDocFormatDecIndent		5
756     {
757     "docFormatMenuDecreaseIndentText",	"Decrease Indent",
758     "docFormatMenuDecreaseIndentKey",		(char *)0,
759     "docFormatMenuDecreaseIndentKeyText",	(char *)0,
760 				    ITEMtyOPTION, tedDocFormatDecreaseIndent,
761     },
762 
763 #   define	TEDmiDocFormatRulerSep		6
764     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
765 
766 #   define	TEDmiDocFormatAlignLeft			7
767     {
768     "docFormatMenuAlignLeftText",	"Align Left",
769     "docFormatMenuAlignLeftKey",	"Ctrl <Key>l",
770     "docFormatMenuAlignLeftKeyText",	"^L",
771 				    ITEMtyOPTION, tedDocFormatAlignLeft,
772     },
773 
774 #   define	TEDmiDocFormatAlignRight		8
775     {
776     "docFormatMenuAlignRightText",	"Align Right",
777     "docFormatMenuAlignRightKey",	"Ctrl <Key>r",
778     "docFormatMenuAlignRightKeyText",	"^R",
779 				    ITEMtyOPTION, tedDocFormatAlignRight,
780     },
781 
782 #   define	TEDmiDocFormatAlignCenter		9
783     {
784     "docFormatMenuAlignCenterText",	"Center Text",
785     "docFormatMenuAlignCenterKey",	"Ctrl <Key>e",
786     "docFormatMenuAlignCenterKeyText",	"^E",
787 				    ITEMtyOPTION, tedDocFormatAlignCenter,
788     },
789 
790 #   define	TEDmiDocFormatAlignJustify		10
791     {
792     "docFormatMenuAlignJustifyText",	"Justify Text",
793     "docFormatMenuAlignJustifyKey",	"Ctrl <Key>j",
794     "docFormatMenuAlignJustifyKeyText",	"^J",
795 				    ITEMtyOPTION, tedDocFormatAlignJustify,
796     },
797 
798 #   define	TEDmiDocFormatAlignSep			11
799     { "",	"", "", (char *)0, "", (char *)0, ITEMtySEPARATOR, },
800 
801 #   define	TEDmiDocFormatTool			12
802     {
803     "docToolMenuFormatText",		"Format Tool",
804     "docToolMenuFormatKey",		(char *)0,
805     "docToolMenuFormatKeyText",		(char *)0,
806 					ITEMtyOPTION, tedDocFormatTool,
807     }
808 
809 };
810 
811 /************************************************************************/
812 /*									*/
813 /*  Document tools menu.						*/
814 /*									*/
815 /************************************************************************/
816 
817 static AppMenuItem TED_DocToolMenuItems[]=
818 {
819 #   define	TEDmiDocToolsFont		0
820     {
821     "docToolMenuFontText",		"Font Tool",
822     "docToolMenuFontKey",		(char *)0,
823     "docToolMenuFontKeyText",		(char *)0,
824 					ITEMtyOPTION, tedDocToolFont,
825     },
826 #   define	TEDmiDocToolsFind		1
827     {
828     "docToolMenuFindText",		"Find",
829     "docToolMenuFindKey",		"Ctrl <Key>f",
830     "docToolMenuFindKeyText",		"^F",
831 					ITEMtyOPTION, tedDocToolFind,
832     },
833 #   define	TEDmiDocToolsSpelling		2
834     {
835     "docToolMenuSpellText",		"Spelling",
836     "docToolMenuSpellKey",		"<Key>F7",
837     "docToolMenuSpellKeyText",		"F7",
838 					ITEMtyOPTION, tedDocToolSpell,
839     },
840 #   define	TEDmiDocToolsPageLayout		3
841     {
842     "docToolMenuPageLayoutText",	"Page Layout",
843     "docToolMenuPageLayoutKey",		(char *)0,
844     "docToolMenuPageLayoutKeyText",	(char *)0,
845 					ITEMtyOPTION, tedDocShowPageTool,
846     },
847 #   define	TEDmiDocToolsInsertSymbol	4
848     {
849     "docToolMenuInsertSymbolText",	"Insert Symbol",
850     "docToolMenuInsertSymbolKey",	(char *)0,
851     "docToolMenuInsertSymbolKeyText",	(char *)0,
852 					ITEMtyOPTION, tedDocToolInsertSymbol,
853     },
854 #   define	TEDmiDocToolsFormatTool		5
855     {
856     "docToolMenuFormatText",		"Format Tool",
857     "docToolMenuFormatKey",		(char *)0,
858     "docToolMenuFormatKeyText",		(char *)0,
859 					ITEMtyOPTION, tedDocFormatTool,
860     },
861 };
862 
863 /************************************************************************/
864 /*									*/
865 /*  Document, Application help menu.					*/
866 /*									*/
867 /************************************************************************/
868 
869 static AppMenuItem TED_DocHelpMenuItems[]=
870 {
871     {
872     "docWinMenuAboutText",	"About Ted",
873     "docWinMenuAboutKey",	(char *)0,
874     "docWinMenuAboutKeyText",	(char *)0,
875 				ITEMtyOPTION, appDocAbout,
876     },
877     {
878     "docHelpMenuDocumentText",	"Document",
879     "docHelpMenuDocumentKey",	(char *)0,
880     "docHelpMenuDocumentKeyText", (char *)0,
881 				ITEMtyOPTION, tedDocManual,
882     },
883 };
884 
885 static AppMenuItem TED_AppHelpMenuItems[]=
886 {
887     {
888     "docHelpMenuDocumentText",	"Document",
889     "docHelpMenuDocumentKey",	(char *)0,
890     "docHelpMenuDocumentKeyText", (char *)0,
891 				ITEMtyOPTION, tedAppManual,
892     },
893 };
894 
895 /************************************************************************/
896 /*									*/
897 /*  Make private menus per document.					*/
898 /*									*/
899 /*  Remember Widget pointers of the menu options to be able to turn	*/
900 /*  on and off when appropriate.					*/
901 /*									*/
902 /*  In this files because it uses the TEDmiDocFileNew &c defines.	*/
903 /*									*/
904 /************************************************************************/
905 
tedMakePrivateDocumentMenus(EditApplication * ea,EditDocument * ed,APP_WIDGET menubar)906 static void tedMakePrivateDocumentMenus( EditApplication *	ea,
907 					EditDocument *		ed,
908 					APP_WIDGET		menubar )
909     {
910     TedDocument *	td= (TedDocument *)ed->edPrivateData;
911 
912     td->tdFileOpenOption=
913 	    TED_DocFileMenuItems[TEDmiDocFileOpen].amiOptionWidget;
914     td->tdFileSaveOption=
915 	    TED_DocFileMenuItems[TEDmiDocFileSave].amiOptionWidget;
916     td->tdFileSaveAsOption=
917 	    TED_DocFileMenuItems[TEDmiDocFileSaveAs].amiOptionWidget;
918     td->tdFileUnlockOption=
919 	    TED_DocFileMenuItems[TEDmiDocFileUnlock].amiOptionWidget;
920     td->tdFileRecoverOption=
921 	    TED_DocFileMenuItems[TEDmiDocFileRecover].amiOptionWidget;
922     td->tdFilePropertiesOption=
923 	    TED_DocFileMenuItems[TEDmiDocFileProperties].amiOptionWidget;
924     td->tdFileCloseOption=
925 	    TED_DocFileMenuItems[TEDmiDocFileClose].amiOptionWidget;
926     td->tdFileQuitSeparator=
927 	    TED_DocFileMenuItems[TEDmiDocFileQuitSeparator].amiOptionWidget;
928     td->tdFileQuitOption=
929 	    TED_DocFileMenuItems[TEDmiDocFileQuit].amiOptionWidget;
930 
931     td->tdUndoOption=
932 	    TED_DocEditMenuItems[TEDmiDocEditUndo].amiOptionWidget;
933     td->tdRepeatOption=
934 	    TED_DocEditMenuItems[TEDmiDocEditRepeat].amiOptionWidget;
935 
936     td->tdCopyOption=
937 	    TED_DocEditMenuItems[TEDmiDocEditCopy].amiOptionWidget;
938     td->tdCutOption=
939 	    TED_DocEditMenuItems[TEDmiDocEditCut].amiOptionWidget;
940     td->tdPasteOption=
941 	    TED_DocEditMenuItems[TEDmiDocEditPaste].amiOptionWidget;
942 
943     td->tdInsertMenu= appMakeMenu( &(td->tdInsertMenuButton),
944 			&(ed->edToplevel), ea, menubar,
945 			TEDResources.tarDocInsertMenuText, 0,
946 			TED_DocInsertMenuItems,
947 			sizeof(TED_DocInsertMenuItems)/sizeof(AppMenuItem),
948 			(void *)ed );
949 
950     td->tdInsPictOption=
951 	    TED_DocInsertMenuItems[TEDmiDocInsertInsPict].amiOptionWidget;
952     td->tdInsFileOption=
953 	    TED_DocInsertMenuItems[TEDmiDocInsertInsFile].amiOptionWidget;
954     td->tdInsSymbolOption=
955 	    TED_DocInsertMenuItems[TEDmiDocInsertInsSymbol].amiOptionWidget;
956     td->tdInsHyperlinkOption=
957 	    TED_DocInsertMenuItems[TEDmiDocInsertInsHyperlink].amiOptionWidget;
958     td->tdInsBookmarkOption=
959 	    TED_DocInsertMenuItems[TEDmiDocInsertInsBookmark].amiOptionWidget;
960     td->tdInsInsertFootnoteOption=
961 	    TED_DocInsertMenuItems[TEDmiDocInsertInsFootnote].amiOptionWidget;
962     td->tdInsInsertEndnoteOption=
963 	    TED_DocInsertMenuItems[TEDmiDocInsertInsEndnote].amiOptionWidget;
964     td->tdInsInsertChftnsepOption=
965 	    TED_DocInsertMenuItems[TEDmiDocInsertInsChftnsep].amiOptionWidget;
966     td->tdInsInsertTableOption=
967 	    TED_DocInsertMenuItems[TEDmiDocInsertInsTable].amiOptionWidget;
968     td->tdInsInsertPageNumberOption=
969 	    TED_DocInsertMenuItems[TEDmiDocInsertInsPageNumber].amiOptionWidget;
970     td->tdInsInsertLineBreakOption=
971 	    TED_DocInsertMenuItems[TEDmiDocInsertInsLineBreak].amiOptionWidget;
972     td->tdInsInsertPageBreakOption=
973 	    TED_DocInsertMenuItems[TEDmiDocInsertInsPageBreak].amiOptionWidget;
974     td->tdInsInsertColumnBreakOption=
975 	    TED_DocInsertMenuItems[TEDmiDocInsertInsColumnBreak].amiOptionWidget;
976     td->tdInsInsertSectBreakOption=
977 	    TED_DocInsertMenuItems[TEDmiDocInsertInsSectBreak].amiOptionWidget;
978 
979     td->tdFontMenu= appMakeMenu( &(td->tdFontMenuButton),
980 			&(ed->edToplevel), ea, menubar,
981 			TEDResources.tarDocFontMenuText, 0,
982 			TED_DocFontMenuItems,
983 			sizeof(TED_DocFontMenuItems)/sizeof(AppMenuItem),
984 			(void *)ed );
985 
986     td->tdFontBoldOption=
987 	    TED_DocFontMenuItems[TEDmiDocFontBold].amiOptionWidget;
988     td->tdFontItalicOption=
989 	    TED_DocFontMenuItems[TEDmiDocFontItalic].amiOptionWidget;
990     td->tdFontUnderlinedOption=
991 	    TED_DocFontMenuItems[TEDmiDocFontUnderlined].amiOptionWidget;
992     td->tdFontSuperscriptOption=
993 	    TED_DocFontMenuItems[TEDmiDocFontSuperscript].amiOptionWidget;
994     td->tdFontSubscriptOption=
995 	    TED_DocFontMenuItems[TEDmiDocFontSubscript].amiOptionWidget;
996     td->tdFontToggleSeparator=
997 	    TED_DocFontMenuItems[TEDmiDocFontToggleSeparator].amiOptionWidget;
998     td->tdFontPasteOption=
999 	    TED_DocFontMenuItems[TEDmiDocFontPaste].amiOptionWidget;
1000 
1001     td->tdTableMenu= appMakeMenu( &(td->tdTableMenuButton),
1002 			&(ed->edToplevel), ea, menubar,
1003 			TEDResources.tarDocTableMenuText, 0,
1004 			TED_DocTableMenuItems,
1005 			sizeof(TED_DocTableMenuItems)/sizeof(AppMenuItem),
1006 			(void *)ed );
1007 
1008     td->tdTabInsertTableOption=
1009 	    TED_DocTableMenuItems[TEDmiDocTableInsertTable].amiOptionWidget;
1010     td->tdTabAddRowOption=
1011 	    TED_DocTableMenuItems[TEDmiDocTableAddRow].amiOptionWidget;
1012     td->tdTabAddColumnOption=
1013 	    TED_DocTableMenuItems[TEDmiDocTableAddColumn].amiOptionWidget;
1014     td->tdTabInsertSeparator=
1015 	    TED_DocTableMenuItems[TEDmiDocTableInsertSeparator].amiOptionWidget;
1016 
1017     td->tdTabSelectTableOption=
1018 	    TED_DocTableMenuItems[TEDmiDocTableSelectTable].amiOptionWidget;
1019     td->tdTabSelectRowOption=
1020 	    TED_DocTableMenuItems[TEDmiDocTableSelectRow].amiOptionWidget;
1021     td->tdTabSelectColumnOption=
1022 	    TED_DocTableMenuItems[TEDmiDocTableSelectColumn].amiOptionWidget;
1023     td->tdTabSelectSeparator=
1024 	    TED_DocTableMenuItems[TEDmiDocTableSelectSeparator].amiOptionWidget;
1025 
1026     td->tdTabDeleteTableOption=
1027 	    TED_DocTableMenuItems[TEDmiDocTableDeleteTable].amiOptionWidget;
1028     td->tdTabDeleteRowOption=
1029 	    TED_DocTableMenuItems[TEDmiDocTableDeleteRow].amiOptionWidget;
1030     td->tdTabDeleteColumnOption=
1031 	    TED_DocTableMenuItems[TEDmiDocTableDeleteColumn].amiOptionWidget;
1032     td->tdTabDeleteSeparator=
1033 	    TED_DocTableMenuItems[TEDmiDocTableDeleteSeparator].amiOptionWidget;
1034 
1035     td->tdDrawTableGridOption=
1036 	    TED_DocTableMenuItems[TEDmiDocTableDrawGrid].amiOptionWidget;
1037 
1038     td->tdFormatMenu= appMakeMenu( &(td->tdFormatMenuButton),
1039 			&(ed->edToplevel), ea, menubar,
1040 			TEDResources.tarDocFormatMenuText, 0,
1041 			TED_DocFormatMenuItems,
1042 			sizeof(TED_DocFormatMenuItems)/sizeof(AppMenuItem),
1043 			(void *)ed );
1044 
1045     td->tdFormatOneParaOption=
1046 	    TED_DocFormatMenuItems[TEDmiDocFormatOnePara].amiOptionWidget;
1047     td->tdFormatOneParaSeparator=
1048 	    TED_DocFormatMenuItems[TEDmiDocFormatOneParaSep].amiOptionWidget;
1049     td->tdFormatPasteRulerOption=
1050 	    TED_DocFormatMenuItems[TEDmiDocFormatPasteRuler].amiOptionWidget;
1051     td->tdFormatIncreaseIndentOption=
1052 	    TED_DocFormatMenuItems[TEDmiDocFormatIncIndent].amiOptionWidget;
1053     td->tdFormatDecreaseIndentOption=
1054 	    TED_DocFormatMenuItems[TEDmiDocFormatDecIndent].amiOptionWidget;
1055     td->tdFormatRulerSeparator=
1056 	    TED_DocFormatMenuItems[TEDmiDocFormatRulerSep].amiOptionWidget;
1057 
1058     td->tdFormatAlignLeftOption=
1059 	    TED_DocFormatMenuItems[TEDmiDocFormatAlignLeft].amiOptionWidget;
1060     td->tdFormatAlignRightOption=
1061 	    TED_DocFormatMenuItems[TEDmiDocFormatAlignRight].amiOptionWidget;
1062     td->tdFormatAlignCenterOption=
1063 	    TED_DocFormatMenuItems[TEDmiDocFormatAlignCenter].amiOptionWidget;
1064     td->tdFormatAlignJustifyOption=
1065 	    TED_DocFormatMenuItems[TEDmiDocFormatAlignJustify].amiOptionWidget;
1066     td->tdFormatAlignSeparator=
1067 	    TED_DocFormatMenuItems[TEDmiDocFormatAlignSep].amiOptionWidget;
1068 
1069     td->tdToolsMenu= appMakeMenu( &(td->tdToolsMenuButton),
1070 			&(ed->edToplevel), ea, menubar,
1071 			TEDResources.tarDocToolMenuText, 0,
1072 			TED_DocToolMenuItems,
1073 			sizeof(TED_DocToolMenuItems)/sizeof(AppMenuItem),
1074 			(void *)ed );
1075 
1076     td->tdToolsFontOption=
1077 	    TED_DocToolMenuItems[TEDmiDocToolsFont].amiOptionWidget;
1078     td->tdToolsFindOption=
1079 	    TED_DocToolMenuItems[TEDmiDocToolsFind].amiOptionWidget;
1080     td->tdToolsFormatToolOption=
1081 	    TED_DocToolMenuItems[TEDmiDocToolsFormatTool].amiOptionWidget;
1082     td->tdToolsSpellingOption=
1083 	    TED_DocToolMenuItems[TEDmiDocToolsSpelling].amiOptionWidget;
1084     td->tdToolsPageLayoutOption=
1085 	    TED_DocToolMenuItems[TEDmiDocToolsPageLayout].amiOptionWidget;
1086     td->tdToolsSymbolOption=
1087 	    TED_DocToolMenuItems[TEDmiDocToolsInsertSymbol].amiOptionWidget;
1088 
1089     ed->edFileCloseOption= td->tdFileCloseOption;
1090 
1091     return;
1092     }
1093 
1094 /************************************************************************/
1095 /*									*/
1096 /*  Ted, description of the application.				*/
1097 /*									*/
1098 /************************************************************************/
1099 
1100 static AppFileExtension	TedFileExtensions[TEDdockind_COUNT]=
1101 {
1102     { "rtfFiles",	"*.rtf",
1103 			"Rich Text Files ( *.rtf )",
1104 			"rtf"	 ,
1105 			( APPFILE_CAN_OPEN|APPFILE_CAN_SAVE ),
1106 			},
1107     { "txtFiles",	"*.txt",
1108 			"Text Files ( *.txt )",
1109 			"txt"	 ,
1110 			( APPFILE_CAN_OPEN ),
1111 			},
1112     { "txtFilesWide",	"*.txt",
1113 			"Wide Text Files ( *.txt )",
1114 			"txt"	 ,
1115 			( APPFILE_CAN_SAVE|APPFILE_CAN_OPEN|APPFILE_HIDE_OPEN ),
1116 			},
1117     { "txtFilesFolded",	"*.txt",
1118 			"Folded Text Files ( *.txt )",
1119 			"txt"	 ,
1120 			( APPFILE_CAN_SAVE|APPFILE_CAN_OPEN|APPFILE_HIDE_OPEN ),
1121 			},
1122     { "htmlFiles",	"*.html",
1123 			"HTML Files ( *.html )",
1124 			"html",
1125 			( APPFILE_CAN_SAVE ),
1126     },
1127     { "emlFiles",	"*.eml",
1128 			"HTML Mail message (rfc 2557) ( *.eml )",
1129 			"eml",
1130 			( APPFILE_CAN_SAVE ),
1131     },
1132     { "epubFiles",	"*.epub",
1133 			"EPUB e-book ( *.epub )",
1134 			"epub",
1135 			( APPFILE_CAN_SAVE ),
1136     },
1137     { "psFiles",	"*.ps",
1138 			"PostScript ( *.ps )",
1139 			"ps",
1140 			( APPFILE_CAN_SAVE ),
1141     },
1142     { "svgFiles",	"*.svg",
1143 			"Scalable Vector Graphics ( *.svg )",
1144 			"svg",
1145 			( APPFILE_CAN_SAVE ),
1146     },
1147     { "pdfFiles",	"*.pdf",
1148 			"Portable Document Format ( *.pdf )",
1149 			"pdf",
1150 			( APPFILE_CAN_SAVE ),
1151     },
1152     { "traceFiles",	"*.Ted",
1153 			"Ted Recovery File ( *.Ted )",
1154 			"Ted",
1155 			( APPFILE_CAN_OPEN ),
1156     },
1157     { "allFiles",	"*",
1158 			"All Files ( *.* )",
1159 			(char *)0,
1160 			( APPFILE_CAN_OPEN ),
1161     },
1162 };
1163 
1164 static AppSelectionTargetType TedClipboardTargets[]=
1165 {
1166     { "application/rtf", (APP_ATOM)0,	tedPasteClipboardRtf,
1167 					tedCopyClipboardRtf		},
1168     { "UTF8_STRING", (APP_ATOM)0,	tedPasteClipboardString,
1169 					tedCopyClipboardString		},
1170     { "STRING",	(APP_ATOM)0,		tedPasteClipboardString,
1171 					tedCopyClipboardString		},
1172     { "image/png", (APP_ATOM)0,		tedPasteClipboardPng,
1173 					tedCopyClipboardPng		},
1174     { "image/jpeg", (APP_ATOM)0,	tedPasteClipboardJfif,
1175 					tedCopyClipboardJfif		},
1176 };
1177 
1178 AppSelectionTargetType TedPrimaryTargets[]=
1179 {
1180     { "UTF8_STRING", (APP_ATOM)0,	tedPastePrimaryString,
1181 					tedCopyPrimaryString		},
1182     { "STRING",	(APP_ATOM)0,		tedPastePrimaryString,
1183 					tedCopyPrimaryString		},
1184 };
1185 
1186 const int TedPrimaryTargetCount=
1187 	    sizeof(TedPrimaryTargets)/sizeof(AppSelectionTargetType);
1188 
1189 AppSelectionTargetType TedClipboardTextTargets[]=
1190 {
1191     { "application/rtf", (APP_ATOM)0,	tedPasteClipboardRtf,
1192 					tedCopyClipboardRtf		},
1193     { "UTF8_STRING", (APP_ATOM)0,	tedPasteClipboardString,
1194 					tedCopyClipboardString		},
1195     { "STRING",	(APP_ATOM)0,		tedPasteClipboardString,
1196 					tedCopyClipboardString		},
1197 };
1198 
1199 const int TedClipboardTextTargetCount=
1200 	    sizeof(TedClipboardTextTargets)/sizeof(AppSelectionTargetType);
1201 
1202 AppSelectionTargetType TedRulerTargets[]=
1203 {
1204     { "application/rtf",	(APP_ATOM)0,	tedPasteRulerTed,
1205 						tedCopyRulerTed		},
1206 };
1207 
1208 const int TedRulerTargetCount=
1209 	    sizeof(TedRulerTargets)/sizeof(AppSelectionTargetType);
1210 
1211 AppSelectionTargetType TedFontTargets[]=
1212 {
1213     { "application/rtf",	(APP_ATOM)0,	tedPasteFontTed,
1214 						tedCopyFontTed		},
1215 };
1216 
1217 const int TedFontTargetCount=
1218 	    sizeof(TedFontTargets)/sizeof(AppSelectionTargetType);
1219 
1220 static AppSelectionType TedDocSelectionTypes[]=
1221 {
1222     { "CLIPBOARD", (APP_ATOM)0,
1223 	    TedClipboardTargets,
1224 	    sizeof(TedClipboardTargets)/sizeof(AppSelectionTargetType),
1225 	    tedClipboardLost },
1226     { "RTFFONT", (APP_ATOM)0,
1227 	    TedFontTargets,
1228 	    sizeof(TedFontTargets)/sizeof(AppSelectionTargetType), },
1229     { "RTFRULER", (APP_ATOM)0,
1230 	    TedRulerTargets,
1231 	    sizeof(TedRulerTargets)/sizeof(AppSelectionTargetType), },
1232     { "PRIMARY", (APP_ATOM)0,
1233 	    TedPrimaryTargets,
1234 	    sizeof(TedPrimaryTargets)/sizeof(AppSelectionTargetType),
1235 	    tedPrimaryLost	},
1236 };
1237 
1238 /************************************************************************/
1239 
tedMainSetPageLayout(EditDocument * ed,const PropertyMask * dgSetMask,const DocumentGeometry * dgSet,int wholeDocument)1240 static void tedMainSetPageLayout( EditDocument *		ed,
1241 				const PropertyMask *		dgSetMask,
1242 				const DocumentGeometry *	dgSet,
1243 				int				wholeDocument )
1244     {
1245 
1246     tedDocSetPageLayout( ed, dgSetMask, dgSet, wholeDocument, ((TedDocument *)ed->edPrivateData)->tdTraced );
1247     }
1248 
1249 /************************************************************************/
1250 
tedFind(EditApplication * ea,const char * prog,const char * call,int argc,char ** argv)1251 static int tedFind(		EditApplication *		ea,
1252 				const char *			prog,
1253 				const char *			call,
1254 				int				argc,
1255 				char **				argv )
1256     {
1257     if  ( argc < 1 )
1258 	{ SLDEB(call,argc); return -1;	}
1259 
1260     TEDResources.tarFindPattern= (const char *)argv[0];
1261     TEDResources.tarFindRegex= 0;
1262 
1263     return 1;
1264     }
1265 
tedRegFind(EditApplication * ea,const char * prog,const char * call,int argc,char ** argv)1266 static int tedRegFind(		EditApplication *		ea,
1267 				const char *			prog,
1268 				const char *			call,
1269 				int				argc,
1270 				char **				argv )
1271     {
1272     if  ( argc < 1 )
1273 	{ SLDEB(call,argc); return -1;	}
1274 
1275     TEDResources.tarFindPattern= (const char *)argv[0];
1276     TEDResources.tarFindRegex= 1;
1277 
1278     return 1;
1279     }
1280 
tedGSFontmapForFiles(EditApplication * ea,const char * prog,const char * call,int argc,char ** argv)1281 static int tedGSFontmapForFiles(EditApplication *		ea,
1282 				const char *			prog,
1283 				const char *			call,
1284 				int				argc,
1285 				char **				argv )
1286     {
1287     int		ret= argc;
1288 
1289     SimpleOutputStream *	sosOut= sioOutStdoutOpen();
1290     if  ( ! sosOut )
1291 	{ XDEB(sosOut); return -1;	}
1292 
1293     if  ( psFontmapForFiles( sosOut, argc, (const char * const *)argv ) )
1294 	{ SLDEB(call,argc); ret= -1;	}
1295 
1296     sioOutClose( sosOut );
1297 
1298     return ret;
1299     }
1300 
tedRtfToPs(EditApplication * ea,const char * prog,const char * call,int argc,char ** argv)1301 static int tedRtfToPs(		EditApplication *		ea,
1302 				const char *			prog,
1303 				const char *			call,
1304 				int				argc,
1305 				char **				argv )
1306     {
1307     fprintf( stderr, "Use Ted --printToFile -rtf- -ps-\n" );
1308     return -1;
1309     }
1310 
tedRtfToPsPaper(EditApplication * ea,const char * prog,const char * call,int argc,char ** argv)1311 static int tedRtfToPsPaper(	EditApplication *		ea,
1312 				const char *			prog,
1313 				const char *			call,
1314 				int				argc,
1315 				char **				argv )
1316     {
1317     fprintf( stderr, "Use Ted --printToFilePaper -rtf- -ps- %s\n", argv[0] );
1318     return 1;
1319     }
1320 
1321 static SpecialCall TedSpecialCalls[]=
1322 {
1323     { "TtfToAfm",		tedTtfToAfm,			},
1324     { "AfmToGSFontmap",		tedAfmToGSFontmap,		},
1325     { "GSFontmapForFiles",	tedGSFontmapForFiles,		},
1326     { "AfmForFontFiles",	tedAfmForFontFiles,		},
1327     { "RtfToPs",		tedRtfToPs,			},
1328     { "RtfToPsPaper",		tedRtfToPsPaper,		},
1329     { "Find",			tedFind,			},
1330     { "RegFind",		tedRegFind,			},
1331     { "FontsDocuments",		tedFontsDocuments,		},
1332 };
1333 
1334 /************************************************************************/
1335 
1336 #   ifdef USE_FONTCONFIG
1337 #	include	<fontconfig/fontconfig.h> /* keep for version */
1338 #	include	<ft2build.h> /* keep for version */
1339 #   endif
1340 
1341 #   ifdef USE_XFT
1342 #	include	FT_FREETYPE_H /* keep for version */
1343 #   endif
1344 
1345 # define VSS(x) #x
1346 # define VSSS(x) VSS(x)
1347 
1348 #   ifdef XmVERSION_STRING
1349     # define MOTIF_VSS "\"" XmVERSION_STRING "\" "
1350 #   else
1351     # define MOTIF_VSS "Motif "
1352 #   endif
1353 
1354 # define GTK_VSS \
1355 	"GTK " VSSS(GTK_MAJOR_VERSION) "." \
1356 	VSSS(GTK_MINOR_VERSION) "." \
1357 	VSSS(GTK_MICRO_VERSION) " "
1358 
1359 # define FT2_VSS \
1360     "FT2 " VSSS(FREETYPE_MAJOR) "." VSSS(FREETYPE_MINOR) " "
1361 
1362 # define XFT_VSS \
1363     "XFT " VSSS(XFT_MAJOR) "." VSSS(XFT_MINOR) "." VSSS(XFT_REVISION) " "
1364 
1365 # define FC_VSS \
1366     "FONTCONFIG " VSSS(FC_MAJOR) "." VSSS(FC_MINOR) "." VSSS(FC_REVISION) " "
1367 
1368 static const char TED_ConfigString[]=
1369 
1370 #   ifdef USE_MOTIF
1371     MOTIF_VSS
1372 #   endif
1373 
1374 #   ifdef USE_GTK
1375     GTK_VSS
1376 #   endif
1377 
1378 #   ifdef USE_FONTCONFIG
1379     FC_VSS
1380 #   endif
1381 
1382 #   ifdef USE_XFT
1383     FT2_VSS
1384 #   endif
1385 
1386     "";
1387 
1388 /************************************************************************/
1389 
1390 static EditApplication	TedApplication=
1391     {
1392 		    /****************************************************/
1393 		    /*  Ted Application name for Xt.			*/
1394 		    /*  Version information for application window.	*/
1395 		    /*  Reference to site for application window.	*/
1396 		    /*  Document shell name for Xt.			*/
1397 		    /*  Page Tool shell name for Xt.			*/
1398 		    /*  Print Dialog shell name for Xt.			*/
1399 		    /*  Mail Dialog shell name for Xt.			*/
1400 		    /*  Message Dialog shell name for Xt.		*/
1401 		    /*  Name of the icon for the application window.	*/
1402 		    /*  Name of the picture for the application window.	*/
1403 		    /****************************************************/
1404     "Ted",
1405     TED_ConfigString,
1406     "Ted 2.23, Feb 4, 2013",
1407     "http://www.nllgg.nl/Ted",
1408     MY_PLATFORM " " MY_RELEASE,
1409     "\"" MY_HOST_DATE "\"",
1410 
1411     "tedmain",
1412     "tedabout",
1413 		    /****************************************************/
1414 		    /*  File extensions, count.				*/
1415 		    /****************************************************/
1416     TedFileExtensions, sizeof(TedFileExtensions)/sizeof(AppFileExtension),
1417 		    /****************************************************/
1418 		    /*  Default filter for file choosers.		*/
1419 		    /****************************************************/
1420     "*.rtf",
1421     (void *)&TEDResources,
1422     TEDApplicationResourceTable,
1423     sizeof(TEDApplicationResourceTable)/sizeof(AppConfigurableResource),
1424     TEDFileMessageResourceTable,
1425     sizeof(TEDFileMessageResourceTable)/sizeof(AppConfigurableResource),
1426     TedSpecialCalls, sizeof(TedSpecialCalls)/sizeof(SpecialCall),
1427 		    /****************************************************/
1428 		    /*  Create new document from command line?		*/
1429 		    /****************************************************/
1430     1,
1431 
1432     1.0,
1433 
1434 		    /****************************************************/
1435 		    /*  Ruler Geometry.					*/
1436 		    /****************************************************/
1437     4, 8, 4, 4,
1438     6, 6, 6, 6,
1439 		    /****************************************************/
1440 		    /*  Default Geometry resources.			*/
1441 		    /****************************************************/
1442     "inch",
1443     "letter",
1444     "90pt",
1445     "72pt",
1446     "90pt",
1447     "72pt",
1448     UNITtyINCH,
1449 	{ 12240, 15840, },
1450 		    /****************************************************/
1451 		    /*  Application File Menu.				*/
1452 		    /****************************************************/
1453     &(TEDResources.tarAppFileMenuText),
1454     TED_AppFileMenuItems,
1455     sizeof(TED_AppFileMenuItems)/sizeof(AppMenuItem),
1456 		    /****************************************************/
1457 		    /*  Application Window Menu.			*/
1458 		    /****************************************************/
1459     &(TEDResources.tarAppWinMenuText),
1460     TED_AppWinMenuItems,
1461     sizeof(TED_AppWinMenuItems)/sizeof(AppMenuItem),
1462 		    /****************************************************/
1463 		    /*  Document File Menu.				*/
1464 		    /****************************************************/
1465     &(TEDResources.tarDocFileMenuText),
1466     TED_DocFileMenuItems,
1467     sizeof(TED_DocFileMenuItems)/sizeof(AppMenuItem),
1468 		    /****************************************************/
1469 		    /*  Document Edit Menu.				*/
1470 		    /****************************************************/
1471     &(TEDResources.tarDocEditMenuText),
1472     TED_DocEditMenuItems,
1473     sizeof(TED_DocEditMenuItems)/sizeof(AppMenuItem),
1474 		    /****************************************************/
1475 		    /*  Document Window Menu.				*/
1476 		    /****************************************************/
1477     &(TEDResources.tarDocWinMenuText),
1478     TED_DocWinMenuItems,
1479     sizeof(TED_DocWinMenuItems)/sizeof(AppMenuItem),
1480 		    /****************************************************/
1481 		    /*  Document, Application Help Menu.		*/
1482 		    /****************************************************/
1483     &(TEDResources.tarHelpMenuText),
1484     TED_DocHelpMenuItems,
1485     sizeof(TED_DocHelpMenuItems)/sizeof(AppMenuItem),
1486 
1487     &(TEDResources.tarHelpMenuText),
1488     TED_AppHelpMenuItems,
1489     sizeof(TED_AppHelpMenuItems)/sizeof(AppMenuItem),
1490 		    /****************************************************/
1491 		    /*  Document Widgets.				*/
1492 		    /*  Their initialisation.				*/
1493 		    /*  How to save them.				*/
1494 		    /****************************************************/
1495     tedMakePrivateData,
1496     tedMakeDocumentWidget,
1497     tedOpenDocument,
1498     tedNewDocument,
1499     tedLayoutDocument,
1500     tedFinishDocumentSetup,
1501     tedDocumentFirstVisible,
1502     NULL,					/*  CanSave		*/
1503     tedSaveDocument,				/*  Save		*/
1504     tedFreeDocument,				/*  Free		*/
1505     tedSuggestPageSetup,			/*  SuggestPageSetup	*/
1506     tedPrintDocument,				/*  PrintDocument	*/
1507     tedDrawRectangle,
1508 		    /****************************************************/
1509 		    /*  Track document count.				*/
1510 		    /****************************************************/
1511     tedVisibleDocumentCountChanged,
1512 		    /****************************************************/
1513 		    /*  Private application,document menus.		*/
1514 		    /****************************************************/
1515     NULL,
1516     tedMakePrivateDocumentMenus,
1517 		    /****************************************************/
1518 		    /*  Cut and paste functions. (Document Edit Menu)	*/
1519 		    /****************************************************/
1520     tedDocCopy,
1521     tedDocCut,
1522     tedDocSelAll,
1523 		    /****************************************************/
1524 		    /*							*/
1525 		    /*  Set page layout.				*/
1526 		    /*							*/
1527 		    /****************************************************/
1528     tedMainSetPageLayout,
1529 		    /****************************************************/
1530 		    /*  User input on the document widget:		*/
1531 		    /****************************************************/
1532     tedMouseButtonPressed,
1533     tedScrollEventHandler,
1534     tedDocGotString,
1535     tedDocGotKey,
1536     tedDocObserveFocus,
1537 
1538     tedDocHorizontalScrollbarCallback,
1539     tedDocVerticalScrollbarCallback,
1540 
1541     tedScrollTopRuler,
1542     tedSetTopRulerRange,
1543     NULL,				/*  ScrollLeftRuler		*/
1544     NULL,				/*  SetLeftRulerRange		*/
1545     NULL,				/*  ScrollRightRuler		*/
1546     NULL,				/*  SetRightRulerRange		*/
1547     NULL,				/*  ScrollBottomRuler		*/
1548     NULL,				/*  SetBottomRulerRange		*/
1549 
1550     tedDocSetTopRuler,			/*  eaSetTopRuler		*/
1551     tedDocSetLeftRuler,			/*  eaSetLeftRuler		*/
1552     tedDocSetRightRuler,		/*  eaSetRightRuler		*/
1553     tedDocSetBottomRuler,		/*  eaSetBottomRuler		*/
1554 
1555     tedFreeTopRuler,			/*  eaFreeTopRuler		*/
1556     tedFreeVerticalRuler,		/*  eaFreeLeftRuler		*/
1557     tedFreeVerticalRuler,		/*  eaFreeRightRuler		*/
1558     tedFreeBottomRuler,			/*  eaFreeBottomRuler		*/
1559 
1560     TedDocSelectionTypes,
1561     sizeof(TedDocSelectionTypes)/ sizeof(AppSelectionType),
1562 
1563     (AppSelectionType *)0,
1564     0/ sizeof(AppSelectionType),
1565 
1566     0,0,0,0,
1567     };
1568 
1569 /************************************************************************/
1570 /*									*/
1571 /*  Main() of the 'Ted' Application.					*/
1572 /*									*/
1573 /*  1)  Sanity checks							*/
1574 /*  2)  Initialisation of the application wide data.			*/
1575 /*									*/
1576 /************************************************************************/
1577 
main(int argc,char * argv[])1578 int main(	int		argc,
1579 		char *		argv[]	)
1580     {
1581     EditApplication *	ea= &TedApplication;
1582 
1583     /*  1  */
1584     if  ( RPprop_FULL_COUNT > PROPmaskMAXPROPS )
1585 	{ LLDEB(RPprop_FULL_COUNT,PROPmaskMAXPROPS); return 1;	}
1586     if  ( PPprop_FULL_COUNT > PROPmaskMAXPROPS )
1587 	{ LLDEB(PPprop_FULL_COUNT,PROPmaskMAXPROPS); return 1;	}
1588     if  ( CLprop_COUNT > PROPmaskMAXPROPS )
1589 	{ LLDEB(CLprop_COUNT,PROPmaskMAXPROPS); return 1;	}
1590     if  ( DPprop_COUNT > PROPmaskMAXPROPS )
1591 	{ LLDEB(DPprop_COUNT,PROPmaskMAXPROPS); return 1;	}
1592     if  ( TFPprop_FULL_COUNT > PROPmaskMAXPROPS )
1593 	{ LLDEB(TFPprop_FULL_COUNT,PROPmaskMAXPROPS); return 1;	}
1594 
1595     /*  2  */
1596     TEDResources.tarShowTableGridInt= 0;
1597     TEDResources.tarShadingMeshPointsDouble= -1;
1598 
1599     TEDResources.tarFindPattern= (const char *)0;
1600     TEDResources.tarFindRegex= 0;
1601 
1602     tedGetNamedPictures( ea );
1603 
1604     return appMain( ea, argc, argv );
1605     }
1606 
1607