3 (* THIS IS TEXT COPY OF BlackBox Text/Mod/Cmds.odc *)
6 (* could eliminate ReplList/ReplOp and use Models.Begin/EndScript instead (as already done for shifting) *)
7 (* move ListAlienViews to StdCmds and generalize accordingly? *)
11 Strings, Ports, Stores, Models, Views, Controllers, Properties, Dialog, Containers,
12 TextModels, TextMappers, TextRulers, TextSetters, TextViews, TextControllers;
16 left = TRUE; right = FALSE;
18 (* PreparePat, FindPat *)
19 leftTerm = 3X; rightTerm = 4X;
22 replace = 0; replaceAndFind = 1; replaceAll = 2;
25 first = TRUE; again = FALSE;
27 mm = Ports.mm; point = Ports.point; maxPat = 256;
28 viewcode = TextModels.viewcode;
29 tab = TextModels.tab; line = TextModels.line; para = TextModels.para;
30 nbspace = TextModels.nbspace; digitspace = TextModels.digitspace;
31 hyphen = TextModels.hyphen;
32 nbhyphen = TextModels.nbhyphen; softhyphen = TextModels.softhyphen;
34 posKey = "#Text:Position";
35 searchAliensKey = "#Text:SearchForAlienViews"; (* dormant code option *)
36 alienTypeKey = "#Text:AlienViewType";
37 noAliensKey = "#Text:NoAlienViewsFound";
38 noRulerKey = "#Text:NoRulerSelected";
39 noMatchKey = "#Text:SelectionDoesNotMatch";
40 noTargetKey = "#Text:NoTargetFound";
41 noSelectionKey = "#Text:NoSelectionFound";
42 noPatternKey = "#Text:PatternNotSpecified";
43 notFoundKey = "#Text:PatternNotFound"; (* not used *)
44 replacingKey = "#System:Replacing";
45 shiftingKey = "#Text:Shifting";
46 showMarksKey = "#Text:ShowMarks";
47 hideMarksKey = "#Text:HideMarks";
48 replaceSelectionKey = "#Text:ReplaceAllInSelection";
49 replaceAllKey = "#Text:ReplaceAll";
54 valid, ignoreCase, wordBeginsWith, wordEndsWith, reverse: BOOLEAN;
56 find: ARRAY maxPat OF CHAR
59 ReplList = POINTER TO RECORD
65 ReplOp = POINTER TO RECORD (Stores.Operation)
66 text: TextModels.Model;
74 find*: ARRAY maxPat OF CHAR;
75 replace*: ARRAY maxPat OF CHAR;
76 ignoreCase*, wordBeginsWith*, wordEndsWith*: BOOLEAN;
77 reverseOrientation*: BOOLEAN
82 notInside*, joinPara*: BOOLEAN
87 PROCEDURE Show (t: TextModels.Model; beg, end: INTEGER);
89 TextViews.ShowRange(t, beg, end, TextViews.focusOnly);
91 TextControllers.SetCaret(t, beg)
93 TextControllers.SetSelection(t, beg, end)
97 PROCEDURE NoShow (t: TextModels.Model; pos: INTEGER);
99 TextControllers.SetSelection(t, pos, pos);
100 TextControllers.SetCaret(t, pos)
103 PROCEDURE Ruler (): TextRulers.Ruler;
104 VAR r: TextRulers.Ruler;
106 r := TextRulers.dir.New(NIL);
107 TextRulers.AddTab(r, 4*mm); TextRulers.AddTab(r, 20*mm);
112 (* search & replace *)
114 PROCEDURE LeftTerminator (ch: CHAR): BOOLEAN;
118 viewcode, tab, line, para, " ",
120 hyphen, softhyphen: RETURN TRUE
127 PROCEDURE RightTerminator (ch: CHAR): BOOLEAN;
131 0X, viewcode, tab, line, para, " ",
132 "!", "(", ")", ",", ".", ":", ";", "?", "[", "]", "{", "}",
133 hyphen, softhyphen: RETURN TRUE
140 PROCEDURE PreparePat (spec: FindSpec;
141 VAR pat: ARRAY OF CHAR; VAR n: INTEGER;
142 VAR wordBeg, wordEnd: BOOLEAN);
143 VAR i: INTEGER; ch: CHAR;
145 i := 0; ch := spec.find[0];
146 wordBeg := spec.wordBeginsWith & ~LeftTerminator(ch);
147 IF wordBeg THEN pat[0] := leftTerm; n := 1 ELSE n := 0 END;
149 IF ch # softhyphen THEN
150 IF spec.ignoreCase THEN pat[n] := Strings.Upper(ch) ELSE pat[n] := ch END;
153 INC(i); ch := spec.find[i]
155 wordEnd := spec.wordEndsWith & ~RightTerminator(pat[n - 1]);
156 IF wordEnd THEN pat[n] := rightTerm; INC(n) END
159 PROCEDURE FindPat (t: TextModels.Model; spec: FindSpec; VAR beg, end: INTEGER);
160 (* post: beg < end => t[beg, end) = spec.find, start <= beg; else beg = end *)
161 VAR r: TextModels.Reader; start: INTEGER;
162 i, j, b, e, n: INTEGER; ch0, ch, ch1: CHAR; wordBeg, wordEnd, icase: BOOLEAN;
163 pat, ref: ARRAY maxPat OF CHAR; (* ref [b..e) is readback buffer *)
164 pos0, pos1, absStart: INTEGER;
165 orientation: INTEGER;
168 orientation := -1; absStart := t.Length();
169 PreparePat(spec, ref, n, wordEnd, wordBeg);
170 i := n; j := 0; REPEAT DEC(i); pat[j] := ref[i]; INC(j) UNTIL i = 0 (* Just reverse the pattern... *)
172 orientation := 1; absStart := 0;
173 PreparePat(spec, pat, n, wordBeg, wordEnd)
175 start := spec.start; icase := spec.ignoreCase;
176 r := t.NewReader(NIL); i := 0;
178 IF start # absStart THEN
179 DEC(start, orientation)
182 IF spec.reverse THEN r.ReadPrevChar(ch) ELSE r.ReadChar(ch) END;
183 IF ~LeftTerminator(ch) THEN i := 1 END
186 r.SetPos(start); IF spec.reverse THEN r.ReadPrevChar(ch) ELSE r.ReadChar(ch) END;
187 pos0 := start; pos1 := start;
188 IF icase THEN ch := Strings.Upper(ch) END;
189 ref[0] := ch; ch0 := ch; j := 0; b := 0; e := 1;
190 WHILE ~r.eot & (i < n) DO
193 OR (ch1 = leftTerm) & LeftTerminator(ch)
194 OR (ch1 = rightTerm) & RightTerminator(ch) THEN
195 INC(i); j := (j + 1) MOD maxPat
196 ELSIF ch = softhyphen THEN
197 j := (j + 1) MOD maxPat
199 i := 0; INC(pos0, orientation); b := (b + 1) MOD maxPat; j := b
204 INC(pos1, orientation);
205 IF spec.reverse THEN r.ReadPrevChar(ch) ELSE r.ReadChar(ch) END;
206 IF icase THEN ch := Strings.Upper(ch) END;
207 ref[j] := ch; e := (e + 1) MOD maxPat
210 IF wordEnd & ~((i + 1 = n) & r.eot) THEN DEC(pos1, orientation) END;
211 IF (n > 0) & ((i = n) OR wordEnd & (i + 1 = n) & r.eot) THEN
212 IF wordBeg & ((pos0 # absStart) OR LeftTerminator(ch0)) THEN INC(pos0, orientation) END
217 beg := pos1; end := pos0
219 beg := pos0; end := pos1
223 PROCEDURE OverrideSpecWithOption (VAR spec: FindSpec; option: ARRAY OF CHAR);
224 VAR i: INTEGER; choice: BOOLEAN; ch: CHAR;
226 choice := TRUE; i := 0; ch := option[i];
229 '~': choice := ~choice
230 | 'I', 'i': spec.ignoreCase := choice; choice := TRUE
231 | 'B', 'b': spec.wordBeginsWith := choice; choice := TRUE
232 | 'E', 'e': spec.wordEndsWith := choice; choice := TRUE
233 | 'R', 'r': spec.reverse := choice; choice := TRUE
236 INC(i); ch := option[i]
238 END OverrideSpecWithOption;
240 PROCEDURE SetSpec (VAR spec: FindSpec; pos0, pos1: INTEGER; option: ARRAY OF CHAR);
242 ASSERT(find.find # "", 20);
244 spec.ignoreCase := find.ignoreCase;
245 spec.wordBeginsWith := find.wordBeginsWith;
246 spec.wordEndsWith := find.wordEndsWith;
247 spec.reverse := find.reverseOrientation;
248 OverrideSpecWithOption(spec, option);
249 IF spec.reverse THEN spec.start := pos1
250 ELSE spec.start := pos0
252 spec.find := find.find$
255 PROCEDURE SetFindSpec (c: TextControllers.Controller; first: BOOLEAN; option: ARRAY OF CHAR;
258 VAR (*start,*) pos0, pos1, beg, end: INTEGER;
260 IF first THEN pos0 := 0; pos1 := pos0
261 ELSIF c.HasCaret() THEN pos0 := c.CaretPos(); pos1 := pos0
262 ELSIF c.HasSelection() THEN c.GetSelection(beg, end); pos0 := beg + 1; pos1 := end - 1
263 ELSE pos0 := 0; pos1 := pos0
265 SetSpec(spec, pos0, pos1, option);
267 IF spec.start = 0 THEN spec.start := c.text.Length() END
269 IF spec.start = c.text.Length() THEN spec.start := 0 END
274 PROCEDURE ReplBuf (target: TextModels.Model; pos: INTEGER): TextModels.Model;
275 VAR buf: TextModels.Model; attr: TextModels.Attributes; rd: TextModels.Reader;
276 out: TextModels.Writer; i: INTEGER;
278 rd := target.NewReader(NIL); rd.SetPos(pos); rd.ReadRun(attr);
279 buf := TextModels.CloneOf(target); out := buf.NewWriter(NIL); out.SetPos(0);
280 IF attr # NIL THEN out.SetAttr(attr) END;
281 i := 0; WHILE find.replace[i] # 0X DO out.WriteChar(find.replace[i]); INC(i) END;
288 PROCEDURE (op: ReplOp) Do;
289 VAR u, v: ReplList; text, save: TextModels.Model; beg, end, delta, len: INTEGER;
292 u := op.list; v := NIL; delta := 0;
294 INC(u.beg, delta); INC(u.end, delta);
295 IF u.end > u.beg THEN
296 save := TextModels.CloneOf(text); save.Insert(0, text, u.beg, u.end);
297 DEC(delta, u.end - u.beg)
302 len := u.buf.Length();
303 text.Insert(u.beg, u.buf, 0, len);
304 u.end := u.beg + len;
312 IF op.find.valid THEN
313 FindPat(text, op.find, beg, end); op.find.valid := FALSE;
314 IF beg = end THEN Dialog.Beep END
316 beg := v.beg; end := v.end
320 IF end > beg THEN Show(text, beg, end) ELSE NoShow(text, beg) END
323 PROCEDURE AddRepl (op: ReplOp; beg, end: INTEGER; reverse: BOOLEAN);
326 NEW(u); u.beg := beg; u.end := end; u.buf := ReplBuf(op.text, beg);
327 IF reverse THEN (* append *)
328 u.next := op.list; op.list := u
330 IF op.list = NIL THEN op.list := u ELSE op.last.next := u END;
335 PROCEDURE DoReplaceThis (
336 t: TextModels.Model; mode: INTEGER;
337 firstBeg, firstEnd: INTEGER;
338 rngBeg, rngEnd: INTEGER;
339 option: ARRAY OF CHAR
341 VAR op: ReplOp; spec: FindSpec; beg, end, len: INTEGER;
343 NEW(op); op.text := t; op.list := NIL;
344 beg := firstBeg; end := firstEnd;
345 IF mode IN {replace, replaceAndFind} THEN
346 AddRepl(op, firstBeg, firstEnd, spec.reverse)
348 IF mode = replaceAndFind THEN
349 SetSpec(op.find, firstBeg + (* LEN(find.replace$) *) ReplBuf(t, 0).Length(), firstBeg, option)
351 op.find.valid := FALSE
353 IF mode = replaceAll THEN
354 len := LEN(find.find$);
355 SetSpec(spec, 0, t.Length(), option);
356 WHILE (rngBeg <= beg) & (beg < end) & (end <= rngEnd) DO
357 AddRepl(op, beg, end, spec.reverse);
358 IF spec.reverse THEN spec.start := beg ELSE spec.start := beg + len END;
359 FindPat(t, spec, beg, end)
362 Models.Do(t, replacingKey, op)
365 PROCEDURE DoReplace (c: TextControllers.Controller; mode: INTEGER; option: ARRAY OF CHAR);
366 VAR t: TextModels.Model; spec: FindSpec;
367 selBeg, selEnd, beg, end, len0: INTEGER; hasSel0: BOOLEAN;
370 t := c.text; len0 := t.Length(); hasSel0 := c.HasSelection();
372 c.GetSelection(selBeg, selEnd);
373 IF selEnd < len0 THEN
374 SetSpec(spec, selBeg, selEnd + 1, option)
375 ELSE SetSpec(spec, selBeg, selEnd, option)
378 selBeg := 0; selEnd := len0;
379 SetFindSpec(c, (* again *) mode = replaceAll, option, spec)
381 FindPat(t, spec, beg, end);
382 IF mode = replaceAll THEN
383 IF (selBeg <= beg) & (beg < end) & (end <= selEnd) THEN
384 DoReplaceThis(t, mode, beg, end, selBeg, selEnd, option);
385 IF hasSel0 THEN Show(c.text, selBeg, selEnd + t.Length() - len0) END
386 ELSE NoShow(c.text, 0); Dialog.Beep
389 IF (beg = selBeg) & (end = selEnd) THEN
390 DoReplaceThis(t, mode, selBeg, selEnd, 0, len0, option)
391 ELSE Dialog.ShowParamMsg(noMatchKey, spec.find, "", "")
393 ELSE Dialog.ShowMsg(noSelectionKey)
395 ELSE Dialog.ShowMsg(noTargetKey)
399 PROCEDURE DoShift (c: TextControllers.Controller; left: BOOLEAN);
400 VAR script: Stores.Operation;
401 t: TextModels.Model; st: TextSetters.Setter;
402 rd: TextModels.Reader; wr: TextModels.Writer;
403 box: TextSetters.LineBox; beg, pos, end: INTEGER; ch: CHAR;
405 IF (c # NIL) & (c.HasSelection() OR c.HasCaret()) THEN
407 IF c.HasSelection() THEN c.GetSelection(beg, end) ELSE beg := c.CaretPos(); end := beg END;
408 st := c.view.ThisSetter(); beg := st.ThisSequence(beg); pos := beg;
409 rd := t.NewReader(NIL); rd.SetPos(pos);
410 IF ~left THEN wr := t.NewWriter(NIL) END;
411 Models.BeginScript(t, shiftingKey, script);
414 IF rd.view # NIL THEN
415 st.GetLine(pos, box);
416 IF box.rbox THEN ch := para END
418 IF left & ((ch = tab) OR (ch = " ") OR (ch = digitspace) OR (ch = nbspace)) THEN
419 t.Delete(pos, pos + 1); rd.SetPos(pos); DEC(end)
420 ELSIF ~left & (ch # line) & (ch # para) THEN
422 IF (ch = " ") OR (ch = digitspace) OR (ch = nbspace) THEN
424 ELSE wr.WriteChar(tab)
429 WHILE ~rd.eot & (ch # line) & (ch # para) DO
430 INC(pos); rd.ReadChar(ch)
432 UNTIL rd.eot OR (pos >= end);
433 Models.EndScript(t, script);
434 IF end > beg THEN TextControllers.SetSelection(t, beg, end) END
440 PROCEDURE ListAlienViews*;
441 VAR t: TextModels.Model; v: TextViews.View; wr: TextMappers.Formatter;
442 rd: TextModels.Reader; view: Views.View;
443 type: Stores.TypeName; none: BOOLEAN;
445 t := TextViews.FocusText();
447 wr.ConnectTo(TextModels.dir.New());
448 rd := t.NewReader(NIL); rd.ReadView(view); none := TRUE;
450 IF view IS Views.Alien THEN
452 wr.WriteTab; wr.WriteMsg(posKey);
453 wr.WriteTab; wr.WriteMsg(alienTypeKey); wr.WriteLn
456 type := view(Views.Alien).store.path[0]$;
458 wr.WriteIntForm(rd.Pos() - 1,
459 TextMappers.decimal, 5, nbspace, TextMappers.hideBase);
460 wr.WriteTab; wr.WriteString(type); wr.WriteLn
464 IF none THEN wr.WriteString(noAliensKey); wr.WriteLn END;
465 v := TextViews.dir.New(wr.rider.Base());
466 v.SetDefaults(Ruler(), TextViews.dir.defAttr);
472 PROCEDURE ToggleMarksGuard* (VAR par: Dialog.Par);
473 VAR v: TextViews.View;
475 v := TextViews.Focus();
476 IF (v # NIL) & v.HidesMarks() THEN par.label := showMarksKey
477 ELSE par.label := hideMarksKey
479 END ToggleMarksGuard;
481 PROCEDURE ToggleMarks*;
482 VAR v: TextViews.View;
484 v := TextViews.Focus();
485 IF v # NIL THEN v.DisplayMarks(~v.HidesMarks()) END
488 PROCEDURE ShowMarks*;
489 VAR v: TextViews.View;
491 v := TextViews.Focus();
492 IF (v # NIL) & v.HidesMarks() THEN v.DisplayMarks(TextViews.show) END
495 PROCEDURE HideMarks*;
496 VAR v: TextViews.View;
498 v := TextViews.Focus();
499 IF (v # NIL) & ~v.HidesMarks() THEN v.DisplayMarks(TextViews.hide) END
502 PROCEDURE MakeDefaultRulerGuard* (VAR par: Dialog.Par);
503 VAR c: TextControllers.Controller; v: Views.View;
505 c := TextControllers.Focus();
508 IF (v = NIL) OR ~(v IS TextRulers.Ruler) THEN par.disabled := TRUE END
509 ELSE par.disabled := TRUE
511 END MakeDefaultRulerGuard;
513 PROCEDURE MakeDefaultRuler*;
514 VAR c: TextControllers.Controller; rd: TextModels.Reader;
515 r: TextRulers.Ruler; a: TextModels.Attributes;
518 c := TextControllers.Focus();
520 IF c.HasSelection() THEN
521 c.GetSelection(beg, end);
522 rd := c.text.NewReader(NIL); rd.SetPos(beg); rd.Read;
523 IF (rd.view # NIL) & (rd.view IS TextRulers.Ruler) THEN
524 c.view.PollDefaults(r, a);
525 c.view.SetDefaults(rd.view(TextRulers.Ruler), a)
526 ELSE Dialog.ShowMsg(noRulerKey)
528 ELSE Dialog.ShowMsg(noSelectionKey)
530 ELSE Dialog.ShowMsg(noTargetKey)
532 END MakeDefaultRuler;
534 PROCEDURE MakeDefaultAttributes*;
535 VAR c: TextControllers.Controller; rd: TextModels.Reader;
536 r: TextRulers.Ruler; a: TextModels.Attributes;
539 c := TextControllers.Focus();
541 IF c.HasSelection() THEN
542 c.GetSelection(beg, end);
543 rd := c.text.NewReader(NIL); rd.SetPos(beg); rd.Read;
544 c.view.PollDefaults(r, a);
545 c.view.SetDefaults(r, rd.attr)
546 ELSE Dialog.ShowMsg(noSelectionKey)
548 ELSE Dialog.ShowMsg(noTargetKey)
550 END MakeDefaultAttributes;
552 PROCEDURE ShiftLeft*;
554 DoShift(TextControllers.Focus(), left)
557 PROCEDURE ShiftRight*;
559 DoShift(TextControllers.Focus(), right)
563 PROCEDURE Subscript*;
564 VAR q, p0: Properties.Property; p: TextModels.Prop;
566 Properties.CollectProp(q);
567 p0 := q; WHILE (p0 # NIL) & ~(p0 IS TextModels.Prop) DO p0 := p0.next END;
568 NEW(p); p.valid := {TextModels.offset};
569 IF (p0 # NIL) & (TextModels.offset IN p0.valid) THEN
570 p.offset := p0(TextModels.Prop).offset - point
571 ELSE p.offset := -point
573 Properties.EmitProp(NIL, p)
576 PROCEDURE Superscript*;
577 VAR q, p0: Properties.Property; p: TextModels.Prop;
579 Properties.CollectProp(q);
580 p0 := q; WHILE (p0 # NIL) & ~(p0 IS TextModels.Prop) DO p0 := p0.next END;
581 NEW(p); p.valid := {TextModels.offset};
582 IF (p0 # NIL) & (TextModels.offset IN p0.valid) THEN
583 p.offset := p0(TextModels.Prop).offset + point
584 ELSE p.offset := point
586 Properties.EmitProp(NIL, p)
590 PROCEDURE ForceToNewLine (c: TextControllers.Controller);
591 VAR st: TextSetters.Setter; pos, start: INTEGER; msg: Controllers.EditMsg;
595 st := c.view.ThisSetter(); start := st.ThisLine(pos);
597 msg.op := Controllers.pasteChar; msg.char := line;
598 Controllers.Forward(msg)
603 PROCEDURE InsertParagraph*;
604 VAR c: TextControllers.Controller; script: Stores.Operation; msg: Controllers.EditMsg;
606 c := TextControllers.Focus();
608 Models.BeginScript(c.text, "#Text:InsertParagraph", script);
610 msg.op := Controllers.pasteChar; msg.char := para;
611 Controllers.Forward(msg);
612 Models.EndScript(c.text, script)
616 PROCEDURE InsertRuler*;
617 VAR c: TextControllers.Controller; script: Stores.Operation;
618 rd: TextModels.Reader; r: TextRulers.Ruler;
621 c := TextControllers.Focus();
624 IF c.HasSelection() THEN
625 c.GetSelection(pos, end);
626 rd := c.text.NewReader(NIL); rd.SetPos(pos); rd.Read;
627 IF (rd.view # NIL) & (rd.view IS TextRulers.Ruler) THEN
628 r := rd.view(TextRulers.Ruler)
630 ELSE pos := c.CaretPos()
632 IF r = NIL THEN r := TextViews.ThisRuler(c.view, pos) END;
633 r := TextRulers.CopyOf(r, Views.deep);
634 Models.BeginScript(c.text, "#Text:InsertRuler", script);
636 c.view.DisplayMarks(TextViews.show);
637 Controllers.PasteView(r, Views.undefined, Views.undefined, FALSE);
638 Models.EndScript(c.text, script)
642 PROCEDURE InsertSoftHyphen*;
643 VAR msg: Controllers.EditMsg;
645 msg.op := Controllers.pasteChar; msg.char := softhyphen;
646 Controllers.Forward(msg)
647 END InsertSoftHyphen;
649 PROCEDURE InsertNBHyphen*;
650 VAR msg: Controllers.EditMsg;
652 msg.op := Controllers.pasteChar; msg.char := nbhyphen;
653 Controllers.Forward(msg)
656 PROCEDURE InsertNBSpace*;
657 VAR msg: Controllers.EditMsg;
659 msg.op := Controllers.pasteChar; msg.char := nbspace;
660 Controllers.Forward(msg)
663 PROCEDURE InsertDigitSpace*;
664 VAR msg: Controllers.EditMsg;
666 msg.op := Controllers.pasteChar; msg.char := digitspace;
667 Controllers.Forward(msg)
668 END InsertDigitSpace;
671 PROCEDURE GetFindPattern (c: TextControllers.Controller);
672 VAR r: TextModels.Reader; beg, end: INTEGER; i: INTEGER; ch: CHAR;
673 new: ARRAY maxPat OF CHAR;
675 IF (c # NIL) & c.HasSelection() THEN
676 c.GetSelection(beg, end);
677 r := c.text.NewReader(NIL); r.SetPos(beg); r.ReadChar(ch); i := 0;
678 WHILE (r.Pos() <= end) & (i < maxPat - 1) DO
679 new[i] := ch; INC(i); r.ReadChar(ch)
682 IF (new # "") & (new # find.find) THEN
684 find.ignoreCase := FALSE;
685 find.wordBeginsWith := FALSE; find.wordEndsWith := FALSE;
691 PROCEDURE FindIn (c: TextControllers.Controller; first: BOOLEAN; option: ARRAY OF CHAR);
692 VAR spec: FindSpec; beg, end: INTEGER;
695 IF find.find # "" THEN
696 SetFindSpec(c, first, option, spec);
697 FindPat(c.text, spec, beg, end);
698 IF end > beg THEN Show(c.text, beg, end) ELSE NoShow(c.text, 0); Dialog.Beep END
699 ELSE Dialog.ShowMsg(noPatternKey)
701 ELSE Dialog.ShowMsg(noTargetKey)
706 PROCEDURE FindGuard* (VAR par: Dialog.Par);
707 VAR c: TextControllers.Controller;
709 c := TextControllers.Focus();
710 IF (c = NIL) OR (find.find = "") THEN par.disabled := TRUE END
713 PROCEDURE FindFirst* (option: ARRAY OF CHAR);
715 FindIn(TextControllers.Focus(), first, option)
718 PROCEDURE FindAgainGuard* (VAR par: Dialog.Par);
719 VAR c: TextControllers.Controller;
721 c := TextControllers.Focus();
722 IF (c = NIL) OR (~c.HasSelection() & (find.find = "")) THEN par.disabled := TRUE END
725 PROCEDURE FindAgain* (option: ARRAY OF CHAR);
727 FindIn(TextControllers.Focus(), again, option)
731 PROCEDURE ReplaceGuard* (VAR par: Dialog.Par);
732 VAR c: TextControllers.Controller;
734 c := TextControllers.Focus();
735 IF (c = NIL) OR (Containers.noCaret IN c.opts) OR ~c.HasSelection() OR (find.find = "") THEN
740 PROCEDURE Replace* (option: ARRAY OF CHAR);
742 DoReplace(TextControllers.Focus(), replace, option)
745 PROCEDURE ReplaceAndFindNext* (option: ARRAY OF CHAR);
747 DoReplace(TextControllers.Focus(), replaceAndFind, option)
748 END ReplaceAndFindNext;
751 PROCEDURE ReplaceAllGuard* (VAR par: Dialog.Par);
752 VAR c: TextControllers.Controller;
754 c := TextControllers.Focus();
755 IF (c = NIL) OR (Containers.noCaret IN c.opts) OR (find.find = "") THEN
758 IF c.HasSelection() THEN par.label := replaceSelectionKey ELSE par.label := replaceAllKey END
762 PROCEDURE ReplaceAll* (option: ARRAY OF CHAR);
764 DoReplace(TextControllers.Focus(), replaceAll, option)
768 PROCEDURE SetNormalOrientation*;
770 find.reverseOrientation := FALSE;
772 END SetNormalOrientation;
774 PROCEDURE SetReverseOrientation*;
776 find.reverseOrientation := TRUE;
778 END SetReverseOrientation;
780 PROCEDURE InitFindDialog*;
782 GetFindPattern(TextControllers.Focus())
788 PROCEDURE InitRulerDialog*;
789 VAR v: Views.View; ra: TextRulers.Attributes;
791 v := Controllers.FocusView();
793 WITH v: TextRulers.Ruler DO
795 ruler.pageBreaks.notInside := TextRulers.noBreakInside IN ra.opts;
796 ruler.pageBreaks.joinPara := TextRulers.parJoin IN ra.opts
803 VAR v: Views.View; p: TextRulers.Prop;
805 v := Controllers.FocusView();
807 WITH v: TextRulers.Ruler DO
808 NEW(p); p.valid := {TextRulers.opts};
809 p.opts.mask := {TextRulers.noBreakInside, TextRulers.parJoin};
811 IF ruler.pageBreaks.notInside THEN INCL(p.opts.val, TextRulers.noBreakInside) END;
812 IF ruler.pageBreaks.joinPara THEN INCL(p.opts.val, TextRulers.parJoin) END;
813 Properties.EmitProp(NIL, p)
820 (** standard text-related guards **)
822 PROCEDURE FocusGuard* (VAR par: Dialog.Par);
823 (** in non-TextView menus; otherwise implied by menu type **)
825 IF TextViews.Focus() = NIL THEN par.disabled := TRUE END
828 PROCEDURE EditGuard* (VAR par: Dialog.Par);
829 (** in non-TextView menus; otherwise use "StdCmds.EditGuard" **)
830 VAR c: TextControllers.Controller;
832 c := TextControllers.Focus();
833 IF (c = NIL) OR (Containers.noCaret IN c.opts) THEN par.disabled := TRUE END
836 PROCEDURE SelectionGuard* (VAR par: Dialog.Par);
837 (** in non-TextView menus; otherwise use "StdCmds.SelectionGuard" **)
838 VAR c: TextControllers.Controller;
840 c := TextControllers.Focus();
841 IF (c = NIL) OR ~c.HasSelection() THEN par.disabled := TRUE END
844 PROCEDURE EditSelectionGuard* (VAR par: Dialog.Par);
845 (** in non-TextView menus; otherwise use "StdCmds.SelectionGuard" **)
846 VAR c: TextControllers.Controller;
848 c := TextControllers.Focus();
849 IF (c = NIL) OR (Containers.noCaret IN c.opts) OR ~c.HasSelection() THEN par.disabled := TRUE END
850 END EditSelectionGuard;
852 PROCEDURE SingletonGuard* (VAR par: Dialog.Par);
853 (** in non-TextView menus; otherwise use "StdCmds.SingletonGuard" **)
854 VAR c: TextControllers.Controller;
856 c := TextControllers.Focus();
857 IF (c = NIL) OR (c.Singleton() = NIL) THEN par.disabled := TRUE END