4ae2d5de4755e84416706dd7bbb2526dc7ba03e5
[reactos.git] / rosapps / dflat32 / edit.c
1 /* --------------- edit.c ----------- */
2
3 #include "dflat.h"
4
5 extern DBOX PrintSetup;
6
7 char DFlatApplication[] = "Edit";
8
9 static char Untitled[] = "Untitled";
10
11 static int wndpos;
12
13 static int MemoPadProc(DFWINDOW, DFMESSAGE, PARAM, PARAM);
14 static void NewFile(DFWINDOW,char *);
15 static void SelectFile(DFWINDOW);
16 static void PadWindow(DFWINDOW, char *);
17 static void OpenPadWindow(DFWINDOW, char *,char *);
18 static void LoadFile(DFWINDOW);
19 static void PrintPad(DFWINDOW);
20 static void SaveFile(DFWINDOW, int);
21 static void EditDeleteFile(DFWINDOW);
22 static int EditorProc(DFWINDOW, DFMESSAGE, PARAM, PARAM);
23 static char *NameComponent(char *);
24 static int PrintSetupProc(DFWINDOW, DFMESSAGE, PARAM, PARAM);
25 static void FixTabMenu(void);
26 #ifndef TURBOC
27 void Calendar(DFWINDOW);
28 #endif
29 //void BarChart(DFWINDOW);
30 char **Argv;
31
32 #define CHARSLINE 80
33 #define LINESPAGE 66
34
35 int main (int argc, char *argv[])
36 {
37 DFWINDOW wnd;
38 FILE *fp;
39 if (!init_messages())
40 return 1;
41 Argv = argv;
42 LoadConfig ();
43 // if (!LoadConfig())
44 // cfg.ScreenLines = SCREENHEIGHT;
45 wnd = DfCreateWindow (APPLICATION,
46 "FreeDos Edit " VERSION,
47 0, 0, -1, -1,
48 &MainMenu,
49 NULL,
50 MemoPadProc,
51 // MOVEABLE |
52 // SIZEABLE |
53 // HASBORDER |
54 // MINMAXBOX |
55 HASSTATUSBAR);
56
57 LoadHelpFile ();
58 DfSendMessage (wnd, SETFOCUS, TRUE, 0);
59
60 // Load the files from args - if the file does not exist, open a new window....
61 while (argc > 1)
62 {
63 // check if the file exists....
64 if (( fp = fopen(argv[1],"r")) == NULL )
65 {
66 // file does not exist - create new window
67 NewFile(wnd,argv[1]);
68 }
69 else
70 PadWindow(wnd, argv[1]);
71 --argc;
72 argv++;
73 }
74
75 while (DfDispatchMessage ())
76 ;
77
78 return 0;
79 }
80
81 /* ------ open text files and put them into editboxes ----- */
82 static void PadWindow(DFWINDOW wnd, char *FileName)
83 {
84 int ax;
85 struct _finddata_t ff;
86 char path[MAX_PATH];
87 char *cp;
88
89 CreatePath(path, FileName, FALSE, FALSE);
90 cp = path+strlen(path);
91 CreatePath(path, FileName, TRUE, FALSE);
92 ax = _findfirst(path, &ff);
93 if (ax == -1)
94 return;
95 do
96 {
97 strcpy(cp, ff.name);
98 OpenPadWindow(wnd, path,NULL);
99 }
100 while (_findnext(ax, &ff) == 0);
101 _findclose (ax);
102 }
103
104 /* ------- window processing module for the
105 Edit application window ----- */
106 static int MemoPadProc(DFWINDOW wnd,DFMESSAGE msg,PARAM p1,PARAM p2)
107 {
108 int rtn;
109 switch (msg)
110 {
111 case CREATE_WINDOW:
112 rtn = DefaultWndProc(wnd, msg, p1, p2);
113 if (cfg.InsertMode)
114 SetCommandToggle(&MainMenu, ID_INSERT);
115 if (cfg.WordWrap)
116 SetCommandToggle(&MainMenu, ID_WRAP);
117 FixTabMenu();
118 return rtn;
119 case DFM_COMMAND:
120 switch ((int)p1)
121 {
122 case ID_NEW:
123 NewFile(wnd,NULL);
124 return TRUE;
125
126 case ID_OPEN:
127 SelectFile(wnd);
128 return TRUE;
129
130 case ID_SAVE:
131 SaveFile(inFocus, FALSE);
132 return TRUE;
133
134 case ID_SAVEAS:
135 SaveFile(inFocus, TRUE);
136 return TRUE;
137
138 case ID_DELETEFILE:
139 EditDeleteFile(inFocus);
140 return TRUE;
141
142 case ID_PRINTSETUP:
143 DfDialogBox(wnd, &PrintSetup, TRUE, PrintSetupProc);
144 return TRUE;
145
146 case ID_PRINT:
147 PrintPad(inFocus);
148 return TRUE;
149
150 case ID_EXIT:
151 if (!DfYesNoBox("Exit FreeDos Edit?"))
152 return FALSE;
153 break;
154
155 case ID_WRAP:
156 cfg.WordWrap = GetCommandToggle(&MainMenu, ID_WRAP);
157 return TRUE;
158
159 case ID_INSERT:
160 cfg.InsertMode = GetCommandToggle(&MainMenu, ID_INSERT);
161 return TRUE;
162
163 case ID_TAB2:
164 cfg.Tabs = 2;
165 FixTabMenu();
166 return TRUE;
167
168 case ID_TAB4:
169 cfg.Tabs = 4;
170 FixTabMenu();
171 return TRUE;
172
173 case ID_TAB6:
174 cfg.Tabs = 6;
175 FixTabMenu();
176 return TRUE;
177
178 case ID_TAB8:
179 cfg.Tabs = 8;
180 FixTabMenu();
181 return TRUE;
182
183 case ID_CALENDAR:
184 Calendar(wnd);
185 return TRUE;
186
187 // case ID_BARCHART:
188 // BarChart(wnd);
189 // return TRUE;
190
191 case ID_ABOUT:
192 DfMessageBox(
193 "About D-Flat and FreeDos Edit",
194 " ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n"
195 " ³ ÜÜÜ ÜÜÜ Ü ³\n"
196 " ³ Û Û Û Û Û ³\n"
197 " ³ Û Û Û Û Û ³\n"
198 " ³ Û Û Û Û Û Û ³\n"
199 " ³ ßßß ßßß ßß ³\n"
200 " RÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄU\n"
201 "D-Flat implements the SAA/CUA\n"
202 "interface in a public domain\n"
203 "C language library originally\n"
204 "published in Dr. Dobb's Journal\n"
205 " ------------------------ \n"
206 "FreeDos Edit is a clone of MSDOS\n"
207 "editor for the FREEDOS Project");
208 return TRUE;
209
210 default:
211 break;
212 }
213 break;
214
215 default:
216 break;
217 }
218
219 return DefaultWndProc(wnd, msg, p1, p2);
220 }
221
222 /* --- The New command. Open an empty editor window --- */
223 static void NewFile(DFWINDOW wnd, char *FileName)
224 {
225 OpenPadWindow(wnd, Untitled,FileName);
226 }
227
228 /* --- The Open... command. Select a file --- */
229 static void SelectFile(DFWINDOW wnd)
230 {
231 char FileName[MAX_PATH];
232
233 if (OpenFileDialogBox("*.*", FileName))
234 {
235 /* see if the document is already in a window */
236 DFWINDOW wnd1 = FirstWindow(wnd);
237 while (wnd1 != NULL)
238 {
239 if (wnd1->extension &&
240 stricmp(FileName, wnd1->extension) == 0)
241 {
242 DfSendMessage(wnd1, SETFOCUS, TRUE, 0);
243 DfSendMessage(wnd1, RESTORE, 0, 0);
244 return;
245 }
246 wnd1 = NextWindow(wnd1);
247 }
248 OpenPadWindow(wnd, FileName, NULL);
249 }
250 }
251
252 /* --- open a document window and load a file --- */
253 static void OpenPadWindow(DFWINDOW wnd, char *FileName,char *NewFileName)
254 {
255 static DFWINDOW wnd1 = NULL;
256 DFWINDOW wwnd;
257 struct stat sb;
258 char *Fname = FileName;
259 char *Fnewname = NewFileName;
260 char *ermsg;
261
262 if (strcmp(FileName, Untitled))
263 {
264 if (stat(FileName, &sb))
265 {
266 ermsg = DFmalloc(strlen(FileName)+20);
267 strcpy(ermsg, "No such file as\n");
268 strcat(ermsg, FileName);
269 DfErrorMessage(ermsg);
270 free(ermsg);
271 return;
272 }
273
274 Fname = NameComponent(FileName);
275
276 // check file size
277 if (sb.st_size > 64000)
278 {
279 ermsg = DFmalloc(strlen(FileName)+20);
280 strcpy(ermsg, "File too large for this version of Edit\n");
281 DfErrorMessage(ermsg);
282 free(ermsg);
283 return;
284 }
285 }
286
287 wwnd = WatchIcon();
288 wndpos += 2;
289
290 if (NewFileName != NULL)
291 Fname = NameComponent(NewFileName);
292
293 if (wndpos == 20)
294 wndpos = 2;
295
296 wnd1 = DfCreateWindow(EDITBOX,
297 Fname,
298 (wndpos-1)*2, wndpos, 10, 40,
299 NULL, wnd, EditorProc,
300 SHADOW |
301 MINMAXBOX |
302 CONTROLBOX |
303 VSCROLLBAR |
304 HSCROLLBAR |
305 MOVEABLE |
306 HASBORDER |
307 SIZEABLE |
308 MULTILINE);
309
310 if (strcmp(FileName, Untitled))
311 {
312 wnd1->extension = DFmalloc(strlen(FileName)+1);
313 strcpy(wnd1->extension, FileName);
314 LoadFile(wnd1);
315 }
316 DfSendMessage(wwnd, CLOSE_WINDOW, 0, 0);
317 DfSendMessage(wnd1, SETFOCUS, TRUE, 0);
318 DfSendMessage(wnd1, MAXIMIZE, 0, 0);
319 }
320
321 /* --- Load the notepad file into the editor text buffer --- */
322 static void LoadFile(DFWINDOW wnd)
323 {
324 char *Buf = NULL;
325 int recptr = 0;
326 FILE *fp;
327
328 if ((fp = fopen(wnd->extension, "rt")) != NULL)
329 {
330 while (!feof(fp))
331 {
332 handshake();
333 Buf = DFrealloc(Buf, recptr+150);
334 memset(Buf+recptr, 0, 150);
335 fgets(Buf+recptr, 150, fp);
336 recptr += strlen(Buf+recptr);
337 }
338 fclose(fp);
339 if (Buf != NULL)
340 {
341 DfSendMessage(wnd, SETTEXT, (PARAM) Buf, 0);
342 free(Buf);
343 }
344 }
345 }
346
347 static int LineCtr;
348 static int CharCtr;
349
350 /* ------- print a character -------- */
351 static void PrintChar(FILE *prn, int c)
352 {
353 int i;
354
355 if (c == '\n' || CharCtr == cfg.RightMargin)
356 {
357 fputs("\r\n", prn);
358 LineCtr++;
359 if (LineCtr == cfg.BottomMargin)
360 {
361 fputc('\f', prn);
362 for (i = 0; i < cfg.TopMargin; i++)
363 fputc('\n', prn);
364 LineCtr = cfg.TopMargin;
365 }
366 CharCtr = 0;
367 if (c == '\n')
368 return;
369 }
370 if (CharCtr == 0)
371 {
372 for (i = 0; i < cfg.LeftMargin; i++)
373 {
374 fputc(' ', prn);
375 CharCtr++;
376 }
377 }
378 CharCtr++;
379 fputc(c, prn);
380 }
381
382 /* --- print the current notepad --- */
383 static void PrintPad(DFWINDOW wnd)
384 {
385 if (*cfg.PrinterPort)
386 {
387 FILE *prn;
388 if ((prn = fopen(cfg.PrinterPort, "wt")) != NULL)
389 {
390 long percent;
391 BOOL KeepPrinting = TRUE;
392 unsigned char *text = GetText(wnd);
393 unsigned oldpct = 100, cct = 0, len = strlen(text);
394 DFWINDOW swnd = SliderBox(20, GetTitle(wnd), "Printing");
395 /* ------- print the notepad text --------- */
396 LineCtr = CharCtr = 0;
397 while (KeepPrinting && *text)
398 {
399 PrintChar(prn, *text++);
400 percent = ((long) ++cct * 100) / len;
401 if ((int)percent != (int)oldpct)
402 {
403 oldpct = (int) percent;
404 KeepPrinting = DfSendMessage(swnd, PAINT, 0, oldpct);
405 }
406 }
407 if (KeepPrinting)
408 /* ---- user did not cancel ---- */
409 if (oldpct < 100)
410 DfSendMessage(swnd, PAINT, 0, 100);
411 /* ------- follow with a form feed? --------- */
412 if (DfYesNoBox("Form Feed?"))
413 fputc('\f', prn);
414 fclose(prn);
415 }
416 else
417 DfErrorMessage("Cannot open printer file");
418 }
419 else
420 DfErrorMessage("No printer selected");
421 }
422
423 /* ---------- save a file to disk ------------ */
424 static void SaveFile(DFWINDOW wnd, int Saveas)
425 {
426 FILE *fp;
427 if (wnd->extension == NULL || Saveas) {
428 char FileName[MAX_PATH];
429 if (SaveAsDialogBox(FileName)) {
430 if (wnd->extension != NULL)
431 free(wnd->extension);
432 wnd->extension = DFmalloc(strlen(FileName)+1);
433 strcpy(wnd->extension, FileName);
434 AddTitle(wnd, NameComponent(FileName));
435 DfSendMessage(wnd, BORDER, 0, 0);
436 }
437 else
438 return;
439 }
440 if (wnd->extension != NULL)
441 {
442 DFWINDOW mwnd = MomentaryMessage("Saving the file");
443 if ((fp = fopen(wnd->extension, "wt")) != NULL)
444 {
445 fwrite(GetText(wnd), strlen(GetText(wnd)), 1, fp);
446 fclose(fp);
447 wnd->TextChanged = FALSE;
448 }
449 DfSendMessage(mwnd, CLOSE_WINDOW, 0, 0);
450 }
451 }
452 /* -------- delete a file ------------ */
453 static void EditDeleteFile(DFWINDOW wnd)
454 {
455 if (wnd->extension != NULL) {
456 if (strcmp(wnd->extension, Untitled)) {
457 char *fn = NameComponent(wnd->extension);
458 if (fn != NULL) {
459 char msg[30];
460 sprintf(msg, "Delete %s?", fn);
461 if (DfYesNoBox(msg)) {
462 unlink(wnd->extension);
463 DfSendMessage(wnd, CLOSE_WINDOW, 0, 0);
464 }
465 }
466 }
467 }
468 }
469 /* ------ display the row and column in the statusbar ------ */
470 static void ShowPosition(DFWINDOW wnd)
471 {
472 char status[30];
473 sprintf(status, "Line:%4d Column: %2d",
474 wnd->CurrLine, wnd->CurrCol);
475 DfSendMessage(GetParent(wnd), ADDSTATUS, (PARAM) status, 0);
476 }
477
478 /* window processing module for the editboxes */
479 static int EditorProc(DFWINDOW wnd,DFMESSAGE msg,PARAM p1,PARAM p2)
480 {
481 int rtn;
482
483 switch (msg)
484 {
485 case SETFOCUS:
486 if ((int)p1)
487 {
488 wnd->InsertMode = GetCommandToggle(&MainMenu, ID_INSERT);
489 wnd->WordWrapMode = GetCommandToggle(&MainMenu, ID_WRAP);
490 }
491 rtn = DefaultWndProc(wnd, msg, p1, p2);
492 if ((int)p1 == FALSE)
493 DfSendMessage(GetParent(wnd), ADDSTATUS, 0, 0);
494 else
495 ShowPosition(wnd);
496 return rtn;
497
498 case KEYBOARD_CURSOR:
499 rtn = DefaultWndProc(wnd, msg, p1, p2);
500 ShowPosition(wnd);
501 return rtn;
502
503 case DFM_COMMAND:
504 switch ((int) p1)
505 {
506 case ID_SEARCH:
507 DfSearchText(wnd);
508 return TRUE;
509 case ID_REPLACE:
510 DfReplaceText(wnd);
511 return TRUE;
512 case ID_SEARCHNEXT:
513 DfSearchNext(wnd);
514 return TRUE;
515 case ID_CUT:
516 CopyToClipboard(wnd);
517 DfSendMessage(wnd, DFM_COMMAND, ID_DELETETEXT, 0);
518 DfSendMessage(wnd, PAINT, 0, 0);
519 return TRUE;
520 case ID_COPY:
521 CopyToClipboard(wnd);
522 ClearTextBlock(wnd);
523 DfSendMessage(wnd, PAINT, 0, 0);
524 return TRUE;
525 case ID_PASTE:
526 PasteFromClipboard(wnd);
527 DfSendMessage(wnd, PAINT, 0, 0);
528 return TRUE;
529 case ID_DELETETEXT:
530 case ID_CLEAR:
531 rtn = DefaultWndProc(wnd, msg, p1, p2);
532 DfSendMessage(wnd, PAINT, 0, 0);
533 return rtn;
534 case ID_HELP:
535 DisplayHelp(wnd, "MEMOPADDOC");
536 return TRUE;
537 case ID_WRAP:
538 DfSendMessage(GetParent(wnd), DFM_COMMAND, ID_WRAP, 0);
539 wnd->WordWrapMode = cfg.WordWrap;
540 return TRUE;
541 case ID_INSERT:
542 DfSendMessage(GetParent(wnd), DFM_COMMAND, ID_INSERT, 0);
543 wnd->InsertMode = cfg.InsertMode;
544 DfSendMessage(NULL, SHOW_CURSOR, wnd->InsertMode, 0);
545 return TRUE;
546 default:
547 break;
548 }
549 break;
550
551 case CLOSE_WINDOW:
552 if (wnd->TextChanged)
553 {
554 char *cp = DFmalloc(25+strlen(GetTitle(wnd)));
555 DfSendMessage(wnd, SETFOCUS, TRUE, 0);
556 strcpy(cp, GetTitle(wnd));
557 strcat(cp, "\nText changed. Save it?");
558 if (DfYesNoBox(cp))
559 DfSendMessage(GetParent(wnd), DFM_COMMAND, ID_SAVE, 0);
560 free(cp);
561 }
562 wndpos = 0;
563 if (wnd->extension != NULL)
564 {
565 free(wnd->extension);
566 wnd->extension = NULL;
567 }
568 break;
569
570 default:
571 break;
572 }
573
574 return DefaultWndProc(wnd, msg, p1, p2);
575 }
576
577 /* -- point to the name component of a file specification -- */
578 static char *NameComponent(char *FileName)
579 {
580 char *Fname;
581 if ((Fname = strrchr(FileName, '\\')) == NULL)
582 if ((Fname = strrchr(FileName, ':')) == NULL)
583 Fname = FileName-1;
584 return Fname + 1;
585 }
586
587 static char *ports[] = {
588 "Lpt1", "Lpt2", "Lpt3",
589 "Com1", "Com2", "Com3", "Com4",
590 NULL
591 };
592
593 static int PrintSetupProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
594 {
595 int rtn, i = 0, mar;
596 char marg[10];
597 DFWINDOW cwnd;
598
599 switch (msg)
600 {
601 case CREATE_WINDOW:
602 rtn = DefaultWndProc(wnd, msg, p1, p2);
603 PutItemText(wnd, ID_PRINTERPORT, cfg.PrinterPort);
604 while (ports[i] != NULL)
605 PutComboListText(wnd, ID_PRINTERPORT, ports[i++]);
606 for (mar = CHARSLINE; mar >= 0; --mar)
607 {
608 sprintf(marg, "%3d", mar);
609 PutItemText(wnd, ID_LEFTMARGIN, marg);
610 PutItemText(wnd, ID_RIGHTMARGIN, marg);
611 }
612 for (mar = LINESPAGE; mar >= 0; --mar)
613 {
614 sprintf(marg, "%3d", mar);
615 PutItemText(wnd, ID_TOPMARGIN, marg);
616 PutItemText(wnd, ID_BOTTOMMARGIN, marg);
617 }
618 cwnd = ControlWindow(&PrintSetup, ID_LEFTMARGIN);
619 DfSendMessage(cwnd, LB_SETSELECTION,
620 CHARSLINE-cfg.LeftMargin, 0);
621 cwnd = ControlWindow(&PrintSetup, ID_RIGHTMARGIN);
622 DfSendMessage(cwnd, LB_SETSELECTION,
623 CHARSLINE-cfg.RightMargin, 0);
624 cwnd = ControlWindow(&PrintSetup, ID_TOPMARGIN);
625 DfSendMessage(cwnd, LB_SETSELECTION,
626 LINESPAGE-cfg.TopMargin, 0);
627 cwnd = ControlWindow(&PrintSetup, ID_BOTTOMMARGIN);
628 DfSendMessage(cwnd, LB_SETSELECTION,
629 LINESPAGE-cfg.BottomMargin, 0);
630 return rtn;
631 case DFM_COMMAND:
632 if ((int) p1 == ID_OK && (int) p2 == 0)
633 {
634 GetItemText(wnd, ID_PRINTERPORT, cfg.PrinterPort, 4);
635 cwnd = ControlWindow(&PrintSetup, ID_LEFTMARGIN);
636 cfg.LeftMargin = CHARSLINE -
637 DfSendMessage(cwnd, LB_CURRENTSELECTION, 0, 0);
638 cwnd = ControlWindow(&PrintSetup, ID_RIGHTMARGIN);
639 cfg.RightMargin = CHARSLINE -
640 DfSendMessage(cwnd, LB_CURRENTSELECTION, 0, 0);
641 cwnd = ControlWindow(&PrintSetup, ID_TOPMARGIN);
642 cfg.TopMargin = LINESPAGE -
643 DfSendMessage(cwnd, LB_CURRENTSELECTION, 0, 0);
644 cwnd = ControlWindow(&PrintSetup, ID_BOTTOMMARGIN);
645 cfg.BottomMargin = LINESPAGE -
646 DfSendMessage(cwnd, LB_CURRENTSELECTION, 0, 0);
647 }
648 break;
649 default:
650 break;
651 }
652 return DefaultWndProc(wnd, msg, p1, p2);
653 }
654
655 static void FixTabMenu(void)
656 {
657 char *cp = GetCommandText(&MainMenu, ID_TABS);
658 char *p;
659
660 if (cp != NULL)
661 {
662 p = strchr(cp, '(');
663 if (p != NULL)
664 {
665 // *(p+1) = (char)(cfg.Tabs + '0');
666 // if (GetClass(inFocus) == POPDOWNMENU)
667 // DfSendMessage(inFocus, PAINT, 0, 0);
668 }
669 }
670 }
671
672 void PrepFileMenu(void *w, struct Menu *mnu)
673 {
674 DFWINDOW wnd = w;
675 DeactivateCommand(&MainMenu, ID_SAVE);
676 DeactivateCommand(&MainMenu, ID_SAVEAS);
677 DeactivateCommand(&MainMenu, ID_DELETEFILE);
678 DeactivateCommand(&MainMenu, ID_PRINT);
679 if (wnd != NULL && GetClass(wnd) == EDITBOX)
680 {
681 if (isMultiLine(wnd))
682 {
683 ActivateCommand(&MainMenu, ID_SAVE);
684 ActivateCommand(&MainMenu, ID_SAVEAS);
685 ActivateCommand(&MainMenu, ID_DELETEFILE);
686 ActivateCommand(&MainMenu, ID_PRINT);
687 }
688 }
689 }
690
691 void PrepSearchMenu(void *w, struct Menu *mnu)
692 {
693 DFWINDOW wnd = w;
694 DeactivateCommand(&MainMenu, ID_SEARCH);
695 DeactivateCommand(&MainMenu, ID_REPLACE);
696 DeactivateCommand(&MainMenu, ID_SEARCHNEXT);
697 if (wnd != NULL && GetClass(wnd) == EDITBOX)
698 {
699 if (isMultiLine(wnd))
700 {
701 ActivateCommand(&MainMenu, ID_SEARCH);
702 ActivateCommand(&MainMenu, ID_REPLACE);
703 ActivateCommand(&MainMenu, ID_SEARCHNEXT);
704 }
705 }
706 }
707
708 void PrepEditMenu(void *w, struct Menu *mnu)
709 {
710 DFWINDOW wnd = w;
711 DeactivateCommand(&MainMenu, ID_CUT);
712 DeactivateCommand(&MainMenu, ID_COPY);
713 DeactivateCommand(&MainMenu, ID_CLEAR);
714 DeactivateCommand(&MainMenu, ID_DELETETEXT);
715 DeactivateCommand(&MainMenu, ID_PARAGRAPH);
716 DeactivateCommand(&MainMenu, ID_PASTE);
717 DeactivateCommand(&MainMenu, ID_UNDO);
718 if (wnd != NULL && GetClass(wnd) == EDITBOX)
719 {
720 if (isMultiLine(wnd))
721 {
722 if (TextBlockMarked(wnd))
723 {
724 ActivateCommand(&MainMenu, ID_CUT);
725 ActivateCommand(&MainMenu, ID_COPY);
726 ActivateCommand(&MainMenu, ID_CLEAR);
727 ActivateCommand(&MainMenu, ID_DELETETEXT);
728 }
729 ActivateCommand(&MainMenu, ID_PARAGRAPH);
730 if (!TestAttribute(wnd, READONLY) && Clipboard != NULL)
731 ActivateCommand(&MainMenu, ID_PASTE);
732 if (wnd->DeletedText != NULL)
733 ActivateCommand(&MainMenu, ID_UNDO);
734 }
735 }
736 }
737
738 /* EOF */