EditToolExtraImpl.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Doug Wyatt on January 13, 1984 2:45 pm
Russ Atkinson (RRA) June 18, 1985 4:54:03 pm PDT
Alison Lee June 11, 1986 5:54:30 pm PDT
Swinehart, November 14, 1986 10:00:27 am PST
DIRECTORY
Buttons USING [ButtonProc],
EditToolBuilder USING [BuildButton, Layout, ToNext],
EditToolPrivate USING [BuildExtraOverflow, BuildRealExtraOverflow, ButtonCommandRec, CheckPSel, Info],
Rope USING [ROPE],
TEditDocument USING [Selection],
TEditOps USING [GetSelData];
EditToolExtraImpl:
CEDAR PROGRAM
IMPORTS EditToolPrivate, EditToolBuilder, TEditOps
EXPORTS EditToolPrivate =
{ OPEN EditToolBuilder, EditToolPrivate;
----------------------------
BuildOne:
PROC [info: Layout, name: Rope.
ROPE, proc: Buttons.ButtonProc, clientData:
REF
ANY ¬
NIL] = {
[] ¬ BuildButton[info: info, name: name, proc: proc, gapAfter: FALSE, clientData: clientData] };
BuildExtraButtons:
PUBLIC
PROC [info: Info] = {
{
OPEN info;
BuildOne[layout, "CaretBefore", CaretBefore];
BuildOne[layout, "CaretAfter", CaretAfter];
BuildOne[layout, "CaretOnly", MakePointSelection];
BuildOne[layout, "Grow", GrowSelection];
BuildOne[layout, "Document", Everything];
ToNext[layout,TRUE];
BuildOne[layout, "PendingDelete", MakePendingDelete];
BuildOne[layout, "NotPendingDelete", MakeNotPendingDelete];
ToNext[layout,TRUE];
BuildOne[layout, "MakeSecondary", MakeSecondary];
BuildOne[layout, "MakePrimary", MakePrimary];
BuildOne[layout, "CancelSecondary", CancelSecondary];
BuildOne[layout, "CancelPrimary", CancelPrimary];
ToNext[layout,TRUE];
BuildOne[layout, "ToPrimary", ToPrimary];
BuildOne[layout, "ToSecondary", ToSecondary];
BuildOne[layout, "Transpose", Transpose];
ToNext[layout,TRUE];
BuildOne[layout, "GoToNextChar", GoToNextChar];
BuildOne[layout, "GoToNextWord", GoToNextWord];
BuildOne[layout, "GoToNextNode", GoToNextNode];
ToNext[layout,TRUE];
BuildOne[layout, "SaveSel-A", SaveSelectionA];
BuildOne[layout, "RestoreSel-A", RestoreSelectionA];
BuildOne[layout, "SaveSel-B", SaveSelectionB];
BuildOne[layout, "RestoreSel-B", RestoreSelectionB];
ToNext[layout,TRUE];
BuildOne[layout, "(...)", SelectMatchingParens];
BuildOne[layout, "<...>", SelectMatchingAngleBrackets];
BuildOne[layout, "{...}", SelectMatchingCurlyBrackets];
BuildOne[layout, "[...]", SelectMatchingSquareBrackets];
BuildOne[layout, "\"...\"", SelectMatchingDoubleQuotes];
BuildOne[layout, "'...'", SelectMatchingSingleQuotes];
BuildOne[layout, "-...-", SelectMatchingDashBrackets];
BuildOne[layout, "...", SelectMatchingPlaceholderBrackets];
BuildOne[layout, "Next...", NextPlaceholder];
BuildOne[layout, "Prev...", PreviousPlaceholder];
ToNext[layout,TRUE];
BuildOne[layout, "Delete", Delete];
BuildOne[layout, "Paste", Paste];
BuildOne[layout, "SaveForPaste", SaveForPaste];
BuildOne[layout, "Repeat", Repeat];
BuildOne[layout, "Undo", Undo];
ToNext[layout,TRUE];
BuildExtraOverflow[info] }};
BuildRealExtraButtons:
PUBLIC
PROC [info: Info] = {
{
OPEN info;
BuildOne[layout, "CaretBefore", CaretBefore];
BuildOne[layout, "CaretAfter", CaretAfter];
BuildOne[layout, "MakePointSelection", MakePointSelection];
BuildOne[layout, "GrowSelection", GrowSelection];
BuildOne[layout, "Everything", Everything];
ToNext[layout,TRUE];
BuildOne[layout, "MakePendingDelete", MakePendingDelete];
BuildOne[layout, "MakeNotPendingDelete", MakeNotPendingDelete];
ToNext[layout,TRUE];
BuildOne[layout, "MakeSecondary", MakeSecondary];
BuildOne[layout, "MakePrimary", MakePrimary];
BuildOne[layout, "CancelSecondary", CancelSecondary];
BuildOne[layout, "CancelPrimary", CancelPrimary];
ToNext[layout,TRUE];
BuildOne[layout, "ToPrimary", ToPrimary];
BuildOne[layout, "ToSecondary", ToSecondary];
BuildOne[layout, "Transpose", Transpose];
ToNext[layout,TRUE];
BuildOne[layout, "GoToNextChar", GoToNextChar];
BuildOne[layout, "GoToNextWord", GoToNextWord];
BuildOne[layout, "GoToNextNode", GoToNextNode];
ToNext[layout,TRUE];
BuildOne[layout, "SaveSelectionA", SaveSelectionA];
BuildOne[layout, "RestoreSelectionA", RestoreSelectionA];
BuildOne[layout, "SaveSelectionB", SaveSelectionB];
BuildOne[layout, "RestoreSelectionB", RestoreSelectionB];
ToNext[layout,TRUE];
BuildOne[layout, "SelectMatchingParens", SelectMatchingParens];
BuildOne[layout, "SelectMatchingAngleBrackets", SelectMatchingAngleBrackets];
ToNext[layout,TRUE];
BuildOne[layout, "SelectMatchingCurlyBrackets", SelectMatchingCurlyBrackets];
BuildOne[layout, "SelectMatchingSquareBrackets", SelectMatchingSquareBrackets];
ToNext[layout,TRUE];
BuildOne[layout, "SelectMatchingDoubleQuotes", SelectMatchingDoubleQuotes];
BuildOne[layout, "SelectMatchingSingleQuotes", SelectMatchingSingleQuotes];
ToNext[layout,TRUE];
BuildOne[layout, "SelectMatchingDashBrackets", SelectMatchingDashBrackets];
BuildOne[layout, "SelectMatchingPlaceholderBrackets", SelectMatchingPlaceholderBrackets];
ToNext[layout,TRUE];
BuildOne[layout, "NextPlaceholder", NextPlaceholder];
BuildOne[layout, "PreviousPlaceholder", PreviousPlaceholder];
ToNext[layout,TRUE];
BuildOne[layout, "Delete", Delete];
BuildOne[layout, "Paste", Paste];
BuildOne[layout, "SaveForPaste", SaveForPaste];
BuildOne[layout, "Repeat", Repeat];
BuildOne[layout, "Undo", Undo];
ToNext[layout,TRUE];
EditToolPrivate.BuildRealExtraOverflow[info] }};
----------------------------
DoList:
PUBLIC
PROC [list:
LIST
OF
REF
ANY, typescriptOK:
BOOL ¬
TRUE] = {
pSel: TEditDocument.Selection = TEditOps.GetSelData[primary: TRUE];
IF ~CheckPSel[pSel, typescriptOK] THEN RETURN;
pSel.viewer.class.notify[pSel.viewer, list]};
DoList2:
PUBLIC
PROC [list:
LIST
OF
REF
ANY, typescriptOK:
BOOL ¬
TRUE] = {
sSel: TEditDocument.Selection = TEditOps.GetSelData[primary: FALSE];
IF ~CheckPSel[sSel, typescriptOK] THEN RETURN;
sSel.viewer.class.notify[sSel.viewer, list]};
----------------------------
RegisterButtonProc: Buttons.ButtonProc = {DoList[NARROW[clientData]]};
BuildRegisterButtons:
PUBLIC
PROC [info: Info, listComm:
LIST
OF ButtonCommandRec] = {
IF listComm #
NIL
THEN {
IF listComm.rest # NIL THEN BuildRegisterButtons[ info, listComm.rest];
IF listComm.first.startNextLine THEN ToNext[info.layout, TRUE];
listComm.first.viewer ¬ BuildButton[info: info.layout, name: listComm.first.name, proc: RegisterButtonProc, gapAfter: FALSE, clientData: listComm.first.atomComList];
};
};
----------------------------
toprimary: LIST OF REF ANY = LIST[$ToPrimary,$DoEdit];
ToPrimary: Buttons.ButtonProc = {DoList[toprimary]};
tosecondary: LIST OF REF ANY = LIST[$ToSecondary,$DoEdit];
ToSecondary: Buttons.ButtonProc = {DoList[tosecondary]};
transpose: LIST OF REF ANY = LIST[$ToBoth,$DoEdit];
Transpose: Buttons.ButtonProc = {DoList[transpose]};
pdel: LIST OF REF ANY = LIST[$MakePendingDelete];
MakePendingDelete: Buttons.ButtonProc = {DoList[pdel]};
makesecondary: LIST OF REF ANY = LIST[$MakeSecondary];
MakeSecondary: Buttons.ButtonProc = {DoList[makesecondary]};
makeprimary: LIST OF REF ANY = LIST[$MakePrimary];
MakePrimary: Buttons.ButtonProc = {DoList2[makeprimary]};
cancelsecondary: LIST OF REF ANY = LIST[$CancelSecondary];
CancelSecondary: Buttons.ButtonProc = {DoList2[cancelsecondary]};
cancelprimary: LIST OF REF ANY = LIST[$CancelPrimary];
CancelPrimary: Buttons.ButtonProc = {DoList[cancelprimary]};
notpdel: LIST OF REF ANY = LIST[$MakeNotPendingDelete];
MakeNotPendingDelete: Buttons.ButtonProc = {DoList[notpdel]};
caretbefore: LIST OF REF ANY = LIST[$CaretBefore];
CaretBefore: Buttons.ButtonProc = {DoList[caretbefore]};
caretafter: LIST OF REF ANY = LIST[$CaretAfter];
CaretAfter: Buttons.ButtonProc = {DoList[caretafter]};
makepointselection: LIST OF REF ANY = LIST[$MakePointSelection];
MakePointSelection: Buttons.ButtonProc = {DoList[makepointselection]};
growselection: LIST OF REF ANY = LIST[$GrowSelection];
GrowSelection: Buttons.ButtonProc = {DoList[growselection]};
everything: LIST OF REF ANY = LIST[$Everything];
Everything: Buttons.ButtonProc = {DoList[everything]};
int: PROC [i: INT] RETURNS [REF] = { RETURN [NEW[INT ¬ i]] };
gotonextchar: LIST OF REF ANY = LIST[int[1],$GoToNextChar];
gotopreviouschar: LIST OF REF ANY = LIST[int[1],$GoToPreviousChar];
GoToNextChar: Buttons.ButtonProc = {
DoList[IF mouseButton=red THEN gotonextchar ELSE gotopreviouschar,TRUE]};
gotonextword: LIST OF REF ANY = LIST[int[1],$GoToNextWord];
gotopreviousword: LIST OF REF ANY = LIST[int[1],$GoToPreviousWord];
GoToNextWord: Buttons.ButtonProc = {
DoList[IF mouseButton=red THEN gotonextword ELSE gotopreviousword,TRUE]};
gotonextnode: LIST OF REF ANY = LIST[int[1],$GoToNextNode];
gotopreviousnode: LIST OF REF ANY = LIST[int[1],$GoToPreviousNode];
GoToNextNode: Buttons.ButtonProc = {
DoList[IF mouseButton=red THEN gotonextnode ELSE gotopreviousnode]};
saveselectionA: LIST OF REF ANY = LIST[$SaveSelectionA];
SaveSelectionA: Buttons.ButtonProc = {DoList[saveselectionA]};
restoreselectionA: LIST OF REF ANY = LIST[$RestoreSelectionA];
RestoreSelectionA: Buttons.ButtonProc = {DoList[restoreselectionA]};
saveselectionB: LIST OF REF ANY = LIST[$SaveSelectionB];
SaveSelectionB: Buttons.ButtonProc = {DoList[saveselectionB]};
restoreselectionB: LIST OF REF ANY = LIST[$RestoreSelectionB];
RestoreSelectionB: Buttons.ButtonProc = {DoList[restoreselectionB]};
selectmatchingparens: LIST OF REF ANY = LIST[$SelectMatchingParens];
SelectMatchingParens: Buttons.ButtonProc = {DoList[selectmatchingparens]};
selectmatchingdashbrackets: LIST OF REF ANY = LIST[$SelectMatchingDashBrackets];
SelectMatchingDashBrackets: Buttons.ButtonProc = {DoList[selectmatchingdashbrackets]};
selectmatchinganglebrackets: LIST OF REF ANY = LIST[$SelectMatchingAngleBrackets];
SelectMatchingAngleBrackets: Buttons.ButtonProc = {DoList[selectmatchinganglebrackets]};
selectmatchingcurlybrackets: LIST OF REF ANY = LIST[$SelectMatchingCurlyBrackets];
SelectMatchingCurlyBrackets: Buttons.ButtonProc = {DoList[selectmatchingcurlybrackets]};
selectmatchingsquarebrackets: LIST OF REF ANY = LIST[$SelectMatchingSquareBrackets];
SelectMatchingSquareBrackets: Buttons.ButtonProc = {DoList[selectmatchingsquarebrackets]};
selectmatchingplaceholderbrackets: LIST OF REF ANY = LIST[$SelectMatchingPlaceholderBrackets];
SelectMatchingPlaceholderBrackets: Buttons.ButtonProc =
{DoList[selectmatchingplaceholderbrackets]};
selectmatchingdoublequotes: LIST OF REF ANY = LIST[$SelectMatchingDoubleQuotes];
SelectMatchingDoubleQuotes: Buttons.ButtonProc = {DoList[selectmatchingdoublequotes]};
selectmatchingsinglequotes: LIST OF REF ANY = LIST[$SelectMatchingSingleQuotes];
SelectMatchingSingleQuotes: Buttons.ButtonProc = {DoList[selectmatchingsinglequotes]};
nextplaceholder: LIST OF REF ANY = LIST[$NextPlaceholder];
NextPlaceholder: Buttons.ButtonProc = {DoList[nextplaceholder]};
previousplaceholder: LIST OF REF ANY = LIST[$PreviousPlaceholder];
PreviousPlaceholder: Buttons.ButtonProc = {DoList[previousplaceholder]};
delete: LIST OF REF ANY = LIST[$Delete];
Delete: Buttons.ButtonProc = {DoList[delete]};
paste: LIST OF REF ANY = LIST[$Paste];
Paste: Buttons.ButtonProc = {DoList[paste]};
saveforpaste: LIST OF REF ANY = LIST[$SaveForPaste];
SaveForPaste: Buttons.ButtonProc = {DoList[saveforpaste]};
repeat: LIST OF REF ANY = LIST[$Repeat];
Repeat: Buttons.ButtonProc = {DoList[repeat]};
undo: LIST OF REF ANY = LIST[$Undo];
Undo: Buttons.ButtonProc = {DoList[undo]};
}.
..
Selection related:
MakePendingDelete MakeNotPendingDelete
CaretBefore CaretAfter
MakePointSelection
GrowSelection
Everything
GoToNextChar GoToPreviousChar
GoToNextWord GoToPreviousWord
GoToNextNode GoToPreviousNode
PushSelection PopSelection
SelectMatchingParens SelectMatchingAngleBrackets SelectMatchingCurlyBrackets SelectMatchingSquareBrackets SelectMatchingPlaceholderBrackets
NextPlaceholder PreviousPlaceholder
NextViewer PreviousViewer
Editing:
Delete Paste
Repeat Cancel
BackSpace BackWord
DeleteNextChar DeleteNextWord
ParenBrackets DashBrackets AngleBrackets DoubleQuoteBrackets SingleQuoteBrackets CurlyBrackets SquareBrackets PlaceholderBrackets
AllCaps AllLower InitialCaps FirstCap
MakeOctalCharacter MakeControlCharacter
ExpandAbbrev
SetMesaLooks
SetComment SetNotComment
Break Join
Nest UnNest
here is the EditTool program I used to create all the button procs:
PushSelection EditToolMatchCase EditToolMatchLiterally EditToolClearSearchFor "Everything" PopSelection EditToolSearchForward EditToolDoIt EditToolSearchForward EditToolDoIt EditToolIgnoreCase EditToolSearchForward EditToolDoIt AllLower PushSelection EditToolClearSearchFor "{everything}: LIST" PopSelection EditToolMatchPattern EditToolSearchBackwards EditToolDoIt AllLower
just put the name, such as "MakeControlCharacter", in the "Replace by:" field,
select just before a copy of the Everything stuff, the do the command.