(FILECREATED "20-Nov-87 15:27:14" {QV}<NOTECARDS>1.3KNEXT>RGPATCH062.;13 52996 changes to: (VARS RGPATCH062COMS) (FNS NC.ShowLinks NC.PropListEditorOpenP NC.EditPropList NC.AddTextCard NC.MakeTextCardReadOnly NC.MakeTextCardReadWrite NC.ClosePropListEditor) previous date: " 6-Nov-87 17:20:15" {QV}<NOTECARDS>1.3KNEXT>RGPATCH062.;10) (* Copyright (c) 1987 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT RGPATCH062COMS) (RPAQQ RGPATCH062COMS ((* * rg 11/20/87 changes for read-only text cards, plus some stuff that will have to be generalized for all card types - I'll get to that on the next round of changes) (* * changes to NCTEXTCARD) (FNS NC.AddTextCard NC.BringUpTEditCard) (* * new for NCTEXTCARD) (FNS NC.MakeTextCardReadOnly NC.MakeTextCardReadWrite NC.RevertTextCard NC.LastPieceOffset) (* * don't integrate the following) [P (NC.RecomputeCardType (QUOTE Text) (BQUOTE ((MakeReadOnlyFn , (FUNCTION NC.MakeTextCardReadOnly)) (MakeReadWriteFn , (FUNCTION NC.MakeTextCardReadWrite] (* * new for NCINTERFACE) (FNS NC.PrintReadOnlyMsg NC.CopyMenu NC.ReadOnlyTEditSelFn NC.MakeTEditReadOnly NC.MakeTEditReadWrite NC.NoteFileIconButtonEventFn NC.ChooseTopLevelCard) (GLOBALVARS NC.ShowPropListMenu NC.EditPropListMenu) [VARS (NC.ShowPropListMenu (create MENU ITEMS ← (QUOTE (("Quit" (NC.ClosePropListEditor W (QUOTE NoSave)) "Quit from pointer list display."))) CENTERFLG ← T MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1))) (NC.EditPropListMenu (create MENU ITEMS ← (QUOTE (("Add New Property" ( NC.AddPropToPropList W) "Add a new property to this card's property list.") ("Delete Selected Property" (NC.DelPropFromList W) "Delete selected property from this card's property list.") ("Quit w/o Saving Changes" (NC.ClosePropListEditor W (QUOTE NoSave)) "Quit from property list edit. Changes are not saved.") ("Quit - Saving Changes" (NC.ClosePropListEditor W (QUOTE Save)) "Quit from property list editor. Save changes."))) CENTERFLG ← T MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1] (* * changes to NCINTERFACE) (FNS NC.NoteFileIconButtonEventFn NC.ChooseTopLevelCard) (* * changes to NCCARDS) (FNS NC.EditProperties NC.EditPropList NC.ShowLinks NC.PropListEditorOpenP NC.ClosePropListEditor))) (* * rg 11/20/87 changes for read-only text cards, plus some stuff that will have to be generalized for all card types - I'll get to that on the next round of changes) (* * changes to NCTEXTCARD) (DEFINEQ (NC.AddTextCard [LAMBDA NIL (* Randy.Gobbel "20-Nov-87 15:10") (* * fgh 2/17/86 Added attached bit map field.) (* * rht 4/7/86: Now you get all TEdit menu items on middle button as well as Restart% Editor.) (* * rg 11/20/87 added MakeReadOnlyFn & MakeReadWriteFn) (NC.AddCardType (QUOTE Text) (QUOTE NoteCard) [BQUOTE ((MakeFn , (FUNCTION NC.MakeTEditCard)) (EditFn , (FUNCTION NC.BringUpTEditCard)) (QuitFn , (FUNCTION NC.TEditCloseFn)) (MakeReadOnlyFn , (FUNCTION NC.MakeTextCardReadOnly)) (MakeReadWriteFn , (FUNCTION NC.MakeTextCardReadWrite)) (GetFn , (FUNCTION NC.GetTextSubstance)) (PutFn , (FUNCTION NC.PutTextSubstance)) (CopyFn , (FUNCTION NC.TextCopySubstance)) (MarkDirtyFn , (FUNCTION NC.MarkTextDirty)) (DirtyPFn , (FUNCTION NC.TextDirtyP)) (CollectLinksFn , (FUNCTION NC.CollectReferencesInText)) (DeleteLinksFn , (FUNCTION NC.DelReferencesToCardFromText)) (UpdateLinkIconsFn , (FUNCTION NC.UpdateLinkImagesInText)) (InsertLinkFn , (FUNCTION NC.InsertLinkInTextWindow)) (TranslateWindowPositionFn , (FUNCTION NC.TranslateWindowPositionToTEditPosition] (BQUOTE ((LinkDisplayMode Title) (DisplayedInMenuFlg T) (DefaultWidth 300) (DefaultHeight 200) (LinkAnchorModesSupported T) (LinkIconAttachedBitMap , NC.TextCardIcon) (MiddleButtonMenuItems , (NC.ComputeTextCardMiddleButtonMenuItems]) (NC.BringUpTEditCard [LAMBDA (Card TextStream RegionOrPosition) (* Randy.Gobbel " 6-Nov-87 13:12") (* Bring up a TEdit window for Card ID whose text stream is TextStream in Region specified by RegionOrPosition or by the user.) (* * rht 9/10/85: Fixed call to NC.MakeTEditPropsList so prompt window gets fixed up before card is brought up.) (* * fgh 11/13/85 Updated to handle Card objects.) (* * kirk 2Dec85 Removed illegal RETURN) (* * rht 4/11/86: Added Type arg to call to NC.MakeTEditMiddleMenu and changed names of menu windowprops.) (* * rht 5/5/86: Now calls NC.InstallTitleBarLeftMenu and NC.InstallTextTitleBarMiddleMenu.) (* * rht 8/2/86: Now doesn't throw in any extra tedit props if card is a filebox.) (* * rht 11/16/86: Now moves window to RegionOrPosition if already up.) (* * rht&pmi 11/19/86: Now passes NoteFile arg to NC.MakeTEditPropsList.) (* * rht & pmi 12/16/86: Changed the way we get TEditWindow.) (* * rht 1/30/87: Now calls RESTART-PROCESS-OF-TEDIT-WINDOW from Bagley's TEDIT-PROCESS-KILLER package.) (* * rht 4/17/87: Now makes a prompt window before opening the window.) (* * rg 11/6/87 now waits for TEdit process to get going after TEDIT call) (LET (Region TEditWindow TEditProcess Title TextStreamDirtyFlg Type TEditProcess) (if (SETQ TEditWindow (NC.FetchWindow Card)) then (TOTOPW TEditWindow) (if RegionOrPosition then (SHAPEW TEditWindow (NC.DetermineDisplayRegion Card RegionOrPosition))) (RPTQ 2 (FLASHW TEditWindow)) (if (SETQ TEditProcess (WINDOWPROP TEditWindow (QUOTE PROCESS))) then (TTY.PROCESS TEditProcess) else (* Process may have been turned off. Try to restart.) (SETQ TEditProcess (RESTART-PROCESS-OF-TEDIT-WINDOW TEditWindow))) TEditWindow else (SETQ Region (NC.DetermineDisplayRegion Card RegionOrPosition)) (SETQ Title (NC.RetrieveTitle Card)) (SETQ Type (NC.RetrieveType Card)) (SETQ TEditWindow (CREATEW Region Title NIL T)) (* Make a prompt window "invisibly" so it gets hooked in.) (NC.AttachPromptWindowOffScreen TEditWindow) (WINDOWADDPROP TEditWindow (QUOTE SHRINKFN) (FUNCTION NC.TextCardShrinkFn)) (NC.InstallTitleBarLeftMenu TEditWindow Type) (NC.InstallTextTitleBarMiddleMenu TEditWindow Type) (SETQ TextStreamDirtyFlg (NC.CardDirtyP Card)) [SETQ TEditProcess (TEDIT TextStream TEditWindow NIL (NC.MakeTEditPropsList TEditWindow (NC.FileBoxP Card T) (fetch (Card NoteFile) of Card] (* wait for process to get established. Otherwise, the TEdit killer, called by MakeReadOnly, may fail) (until (TEDIT-PROCESS-P TEditProcess) do (BLOCK)) (AND TextStreamDirtyFlg (NC.MarkCardDirty Card))) TEditWindow]) ) (* * new for NCTEXTCARD) (DEFINEQ (NC.MakeTextCardReadOnly [LAMBDA (Card) (* Randy.Gobbel "20-Nov-87 11:44") (DECLARE (GLOBALVARS NC.ShowPropListMenu)) (LET ((Window (NC.FetchWindow Card)) PropListEditor) (NC.ProtectedCardOperation Card "Make Read-Only" Window (if (NC.CardSomehowDirtyP Card) then (ALLOW.BUTTON.EVENTS) (if (MENU (create MENU TITLE ← "Card has been edited" ITEMS ← (QUOTE (("Save Changes" T "Save edited version of card in NoteFile") ("Revert" NIL "Discard edits, refetch card contents from NoteFile"))) CENTERFLG ← T)) then (NC.CardSaveFn Card NIL Window) else (NC.RevertTextCard Card))) (NC.SetUserDataProp Card (QUOTE ReadOnly) T) (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window))) then (NC.MakeTEditReadOnly PropListEditor) (WINDOWPROP PropListEditor (QUOTE TEDIT.MENU) NC.ShowPropListMenu)) (NC.MakeTEditReadOnly Window (QUOTE (Assign% Title Title/FileBoxes Add% Global% Link Insert% Links Put% Cards% Here Restart% Editor)) (QUOTE (Delete% Card]) (NC.MakeTextCardReadWrite [LAMBDA (Card) (* Randy.Gobbel "20-Nov-87 11:44") (DECLARE (GLOBALVARS NC.EditPropListMenu)) (LET ((Window (NC.FetchWindow Card)) PropListEditor) (NC.ProtectedCardOperation Card "Make Read-Write" Window (if (WINDOWP (SETQ PropListEditor ( NC.PropListEditorOpenP Window))) then (NC.MakeTEditReadWrite PropListEditor) (WINDOWPROP PropListEditor (QUOTE TEDIT.MENU) NC.EditPropListMenu)) (NC.MakeTEditReadWrite Window) (NC.SetUserDataProp Card (QUOTE ReadOnly) NIL]) (NC.RevertTextCard [LAMBDA (Card) (* Randy.Gobbel "30-Oct-87 11:29") (NC.GetNoteCard Card) (LET (TEditProcess) (UNINTERRUPTABLY (KILL-PROCESS-OF-TEDIT-WINDOW Window) (UNMARK-AS-WITHOUT-PROCESS Window)) [SETQ TEditProcess (TEDIT (NC.FetchSubstance Card) (NC.FetchWindow Card) NIL (NC.MakeTEditPropsList (NC.FetchWindow Card) (NC.FileBoxP Card T) (fetch (Card NoteFile) of Card] (until (TEDIT-PROCESS-P TEditProcess) do (BLOCK))) (* wait for process to establish itself so TEdit killer doesn't get confused) (NC.MarkCardDirty Card T]) (NC.LastPieceOffset [LAMBDA (PieceTable) (* Randy.Gobbel "29-Oct-87 15:14") (for I from 0 to (SUB1 (ARRAYSIZE PieceTable)) do (if (EQ (ELT PieceTable I) (QUOTE LASTPIECE)) then (RETURN (SUB1 I]) ) (* * don't integrate the following) [NC.RecomputeCardType (QUOTE Text) (BQUOTE ((MakeReadOnlyFn , (FUNCTION NC.MakeTextCardReadOnly)) (MakeReadWriteFn , (FUNCTION NC.MakeTextCardReadWrite] (* * new for NCINTERFACE) (DEFINEQ (NC.PrintReadOnlyMsg [LAMBDA (Stream) (* Randy.Gobbel "22-Oct-87 14:17") (* * print "not allowed on read-only cards" msg. Code copied from NC.PrintOperationInProgressMsg) (* * rg 10/21/87 First created.) (LET* [(Window (NC.FetchWindow (NC.CoerceToCard Stream))) (MainWindowRegion (WINDOWPROP Window (QUOTE REGION))) (PWinWidth (MAX (WIDTHIFWINDOW (fetch (REGION WIDTH) of MainWindowRegion)) 300)) (PWindow (OR (for WCandidate in (ALLATTACHEDWINDOWS Window) thereis (AND (WINDOWPROP WCandidate (QUOTE NC.ReadOnlyMsgWindow)) (OPENWP WCandidate))) (CREATEW [create REGION LEFT ← 0 BOTTOM ← 0 WIDTH ← PWinWidth HEIGHT ← (SETQ HEIGHT (HEIGHTIFWINDOW (TIMES 2 (FONTPROP (DSPFONT NIL Window) (QUOTE HEIGHT] NIL NIL T] (WINDOWPROP PWindow (QUOTE NC.ReadOnlyMsgWindow) T) [ATTACHWINDOW PWindow Window (QUOTE TOP) (COND ((LEQ (PLUS (fetch (REGION LEFT) of MainWindowRegion) PWinWidth) SCREENWIDTH) (QUOTE LEFT)) ((LEQ (PLUS (fetch (REGION LEFT) of MainWindowRegion) (LRSH (PLUS PWinWidth (fetch (REGION WIDTH) of MainWindowRegion)) 1)) SCREENWIDTH) (QUOTE CENTER)) (T (QUOTE RIGHT] (NC.PrintMsg PWindow T "Operation not allowed: window is read-only") (REPOSITIONATTACHEDWINDOWS Window) (DISMISS 2000) (REMOVEWINDOW PWindow]) (NC.CopyMenu [LAMBDA (Menu) (* Randy.Gobbel "16-Oct-87 15:56") (create MENU ITEMS ← (COPY (fetch (MENU ITEMS) of Menu)) CHANGEOFFSETFLG ← (fetch (MENU CHANGEOFFSETFLG) of Menu) MENUOFFSET ← (fetch (MENU MENUOFFSET) of Menu) CENTERFLG ← (fetch (MENU CENTERFLG) of Menu) TITLE ← (fetch (MENU TITLE) of Menu) MENUTITLEFONT ← (fetch (MENU MENUTITLEFONT) of Menu) MENUFONT ← (fetch (MENU MENUFONT) of Menu) ITEMHEIGHT ← (fetch (MENU ITEMHEIGHT) of Menu) WHENSELECTEDFN ← (fetch (MENU WHENSELECTEDFN) of Menu]) (NC.ReadOnlyTEditSelFn [LAMBDA (TxtObj Sel SelOp SelWhen) (* Randy.Gobbel "29-Oct-87 17:51") (* AND (EQ SelOp (QUOTE COPYLOOKS)) (fetch HASCARET of (fetch SEL of TxtObj))) (if (AND (TEXTPROP TxtObj (QUOTE READONLY)) (EQ SelOp (QUOTE DELETE))) then (\SHOWSEL (fetch SEL of TxtObj) NIL NIL) (replace SET of (fetch SEL of TxtObj) with NIL) (QUOTE DON'T]) (NC.MakeTEditReadOnly [LAMBDA (Window AddDangerousItems AddDangerousSubItems) (* Randy.Gobbel "22-Oct-87 14:39") (LET* [(TxtObj (TEXTOBJ Window)) (LeftButtonMenu (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu))) (NewLeftButtonMenu (if LeftButtonMenu then (NC.CopyMenu LeftButtonMenu))) (MiddleButtonMenu (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu))) (NewMiddleButtonMenu (if MiddleButtonMenu then (NC.CopyMenu MiddleButtonMenu] (LET ([DangerousItems (APPEND AddDangerousItems (QUOTE (Get Include Looks Substitute Expanded% Menu] (DangerousSubItems AddDangerousSubItems) NewItems SubItems NewSubItems) (if (NOT (TEXTPROP TxtObj (QUOTE READONLY))) then (TEXTPROP TxtObj (QUOTE READONLY) T) (TEXTPROP TxtObj (QUOTE SELFN) (FUNCTION NC.ReadOnlyTEditSelFn)) (replace (TEXTOBJ TXTREADONLY) of TxtObj with T) (UNINTERRUPTABLY (KILL-PROCESS-OF-TEDIT-WINDOW Window) (* make sure TEdit killer won't restart process) (UNMARK-AS-WITHOUT-PROCESS Window)) (for Menu in (LIST NewLeftButtonMenu NewMiddleButtonMenu) do (if Menu then (SETQ NewItems (for Item in (fetch (MENU ITEMS) of Menu) bind ItemName collect (SETQ ItemName (if (LISTP Item) then (CAR Item) else Item)) (if (MEMB ItemName DangerousItems) then [SETQ Item (LIST ItemName (QUOTE (FUNCTION NC.PrintReadOnlyMsg)) (if (LISTP Item) then (CADDR Item] else (SETQ SubItems (APPLY* (OR (fetch SUBITEMFN of Menu) (FUNCTION DEFAULTSUBITEMFN)) Menu Item)) (if SubItems then (SETQ NewSubItems (for SubItem in SubItems collect (SETQ ItemName (if (LISTP SubItem) then (CAR SubItem) else SubItem)) [if (MEMB ItemName DangerousSubItems) then (SETQ SubItem (LIST ItemName (QUOTE (FUNCTION NC.PrintReadOnlyMsg)) (if (LISTP SubItem) then (CADDR SubItem] SubItem)) (RPLACD (CAR (NTH Item 4)) NewSubItems))) Item)) (replace (MENU ITEMS) of Menu with NewItems) [for Item in (fetch (MENU ITEMS) of Menu) do (if (MEMB (if (LISTP Item) then (CAR Item) else Item) DangerousItems) then (SHADEITEM Item Menu GRAYSHADE) else (SETQ SubItems (APPLY* (OR (fetch SUBITEMFN of Menu) (FUNCTION DEFAULTSUBITEMFN)) Menu Item)) (if SubItems then (for SubItem in SubItems do (if (MEMB (if (LISTP SubItem) then (CAR SubItem) else SubItem) DangerousSubItems) then (SHADEITEM SubItem Menu GRAYSHADE] (replace (MENU IMAGE) of Menu with NIL))) (WINDOWPROP Window (QUOTE SaveLeftButtonMenu) LeftButtonMenu) (WINDOWPROP Window (QUOTE SaveMiddleButtonMenu) MiddleButtonMenu) (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu) NewLeftButtonMenu) (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu) NewMiddleButtonMenu]) (NC.MakeTEditReadWrite [LAMBDA (Window) (* Randy.Gobbel "22-Oct-87 14:28") (LET* ((TxtObj (TEXTOBJ Window)) (Sel (fetch SEL of TxtObj))) (if (TEXTPROP TxtObj (QUOTE READONLY)) then (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu) (WINDOWPROP Window (QUOTE SaveLeftButtonMenu))) (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu) (WINDOWPROP Window (QUOTE SaveMiddleButtonMenu))) (\SHOWSEL Sel NIL NIL) (replace SET of Sel with NIL) (replace (TEXTOBJ TXTREADONLY) of TxtObj with NIL) (TEXTPROP TxtObj (QUOTE READONLY) NIL) (MARK-AS-WITHOUT-PROCESS Window (QUOTE TEDIT]) (NC.NoteFileIconButtonEventFn [LAMBDA (Window) (* Randy.Gobbel " 4-Nov-87 14:05") (* * Bring up NoteFile Menues) (* * kirk 15Jul86 Adjusted title size check for change in font) (* * rht 11/23/86: Now calls NC.NoteFileIconMiddleButtonFn to put up a menu of middle button options.) (* * pmi 3/20/87: Overhauled to have NewCards and ShowCards middlebutton menus appear when buttoned DOWN, instead of after the button comes back up.) (* * pmi 4/3/87: Now unshades NewCards item during card creation to indicate that multiple cards may be created at the same time.) (* * rg 11/4/87 calls NC.EditNoteCard w/ ReadOnly if NoteFile is read-only) (LET (NoteFile Menu) (if (MOUSESTATE UP) else (TOTOPW Window) (LET [(Menu (CAR (WINDOWPROP Window (QUOTE MENU] (* title bar) (SETQ NoteFile (WINDOWPROP Window (QUOTE NoteFile))) (for Item in (fetch (MENU ITEMS) of Menu) when (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) do (RESETLST (RESETSAVE (SHADEITEM Item Menu GRAYSHADE) (LIST (QUOTE SHADEITEM) Item Menu (if (NULL (NC.NoteFileOpenP NoteFile)) then GRAYSHADE elseif (AND (EQ (CAR Item) (QUOTE NewCards)) (NC.ReadOnlyNoteFileP NoteFile)) then GRAYSHADE else WHITESHADE))) (if (NULL (NC.NoteFileOpenP NoteFile)) then (* * If the NoteFile is not open, just print a message and return) (FLASHW Window) (NC.PrintMsg Window T (fetch (NoteFile FullFileName) of NoteFile) " is not an open notefile.") (DISMISS 1000) (NC.ClearMsg Window T) elseif (PROCESSP (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress))) then (* * This will probably be overhauled with Randy G.'s concurrancy fixes) (NC.PrintOperationInProgressMsg Window (CAR Item) (NC.NoteFileProp NoteFile (QUOTE OperationInProgress))) NIL else (SELECTQ (CAR Item) (NewCards (if (NC.ReadOnlyNoteFileP NoteFile) then (FLASHW Window) (NC.PrintMsg Window T "Can't create a new card in a Read-Only notefile.") (DISMISS 1000) (NC.ClearMsg Window T) elseif (LASTMOUSESTATE LEFT) then (* For the left button, don't do anything until the button comes back up. Otherwise, things happen too soon.) (UNTILMOUSESTATE UP) (if (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) then (SHADEITEM Item Menu WHITESHADE) ( NC.MakeNoteCard NC.DefaultCardType NoteFile)) else (SHADEITEM Item Menu WHITESHADE) (NC.MakeNoteCard NIL NoteFile))) (ShowCards (if (LASTMOUSESTATE LEFT) then (* For the left button, don't do anything until the button comes back up. Otherwise, things happen too soon.) (UNTILMOUSESTATE UP) (if (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) then (NC.EditNoteCard (fetch (NoteFile TableOfContentsCard) of NoteFile) (fetch (NoteFile ReadOnlyFlg) of NoteFile))) else (NC.ChooseTopLevelCard NoteFile))) NIL))) (RETURN) finally (if (LASTMOUSESTATE MIDDLE) then (NC.NoteFileIconMiddleButtonFn Window NoteFile) elseif (NULL (WINDOWPROP Window (QUOTE BusyOperation))) then (RESETLST (RESETSAVE (WINDOWPROP Window (QUOTE BusyOperation) "Operation") (BQUOTE (WINDOWPROP , Window BusyOperation NIL) )) (NC.NoteFileOperations NoteFile)) else (NC.PrintMsg NIL NIL (CHARACTER 13) (WINDOWPROP Window (QUOTE BusyOperation)) " in progress. Please wait."]) (NC.ChooseTopLevelCard [LAMBDA (NoteFile) (* Randy.Gobbel " 4-Nov-87 14:18") (* Let the user choose one of the top level cards. Top level cards are specified by globalvar NC.TopLevelCards which is a list of IDs) (* * fgh 11/14/85 Updated to handle NoteFile object and per NoteFile menus.) (* * kirk 6May86 Deleted SETQ of undeclared Menu var in the last expression) (* * rht 11/20/86: Now looks on "SpecialCards" prop of notefile for other cards to make available from ShowCards menu.) (* * pmi 3/20/87: Changed fields of NC.NoteCardTypeMenu: added 1 to ITEMHEIGHT, added title of "Special Cards") (* * pmi 3/25/87: Added NC.MenuFont to all menus) (* * rg 11/4/87 added ReadOnly to NC.EditNoteCard call) (DECLARE (GLOBALVARS NC.MenuFont)) (LET ((NoteFileMenu (fetch (NoteFile Menu) of NoteFile)) Menu W Z) [SETQ Menu (create MENU ITEMS ← (for Card in (APPEND (NC.FetchTopLevelCards NoteFile) (NC.NoteFileProp NoteFile (QUOTE SpecialCards))) when (NC.ValidCardP Card) collect (LIST (NC.RetrieveTitle Card) Card)) CENTERFLG ← T TITLE ← " Special Cards " MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1) WHENSELECTEDFN ← (FUNCTION (LAMBDA (Item Button Menu) (NC.EditNoteCard (CADR Item) (fetch (NoteFile ReadOnlyFlg) of NoteFile] (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NoteFileMenu) 2)) NoteFileMenu)) (SETQ Z (WINDOWPROP (WFROMMENU NoteFileMenu) (QUOTE REGION))) [replace (MENU MENUPOSITION) of Menu with (create POSITION XCOORD ← (IPLUS (fetch (REGION LEFT) of W) (fetch (REGION LEFT) of Z)) YCOORD ← (IPLUS (fetch (REGION TOP) of W) (fetch (REGION BOTTOM) of Z) (IMINUS (fetch (MENU IMAGEHEIGHT) of Menu] (MENU Menu]) ) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS NC.ShowPropListMenu NC.EditPropListMenu) ) (RPAQ NC.ShowPropListMenu (create MENU ITEMS ← (QUOTE (("Quit" (NC.ClosePropListEditor W (QUOTE NoSave)) "Quit from pointer list display."))) CENTERFLG ← T MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1))) (RPAQ NC.EditPropListMenu (create MENU ITEMS ← (QUOTE (("Add New Property" (NC.AddPropToPropList W) "Add a new property to this card's property list.") ("Delete Selected Property" ( NC.DelPropFromList W) "Delete selected property from this card's property list.") ("Quit w/o Saving Changes" (NC.ClosePropListEditor W (QUOTE NoSave)) "Quit from property list edit. Changes are not saved.") ("Quit - Saving Changes" (NC.ClosePropListEditor W (QUOTE Save)) "Quit from property list editor. Save changes."))) CENTERFLG ← T MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1))) (* * changes to NCINTERFACE) (DEFINEQ (NC.NoteFileIconButtonEventFn [LAMBDA (Window) (* Randy.Gobbel " 4-Nov-87 14:05") (* * Bring up NoteFile Menues) (* * kirk 15Jul86 Adjusted title size check for change in font) (* * rht 11/23/86: Now calls NC.NoteFileIconMiddleButtonFn to put up a menu of middle button options.) (* * pmi 3/20/87: Overhauled to have NewCards and ShowCards middlebutton menus appear when buttoned DOWN, instead of after the button comes back up.) (* * pmi 4/3/87: Now unshades NewCards item during card creation to indicate that multiple cards may be created at the same time.) (* * rg 11/4/87 calls NC.EditNoteCard w/ ReadOnly if NoteFile is read-only) (LET (NoteFile Menu) (if (MOUSESTATE UP) else (TOTOPW Window) (LET [(Menu (CAR (WINDOWPROP Window (QUOTE MENU] (* title bar) (SETQ NoteFile (WINDOWPROP Window (QUOTE NoteFile))) (for Item in (fetch (MENU ITEMS) of Menu) when (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) do (RESETLST (RESETSAVE (SHADEITEM Item Menu GRAYSHADE) (LIST (QUOTE SHADEITEM) Item Menu (if (NULL (NC.NoteFileOpenP NoteFile)) then GRAYSHADE elseif (AND (EQ (CAR Item) (QUOTE NewCards)) (NC.ReadOnlyNoteFileP NoteFile)) then GRAYSHADE else WHITESHADE))) (if (NULL (NC.NoteFileOpenP NoteFile)) then (* * If the NoteFile is not open, just print a message and return) (FLASHW Window) (NC.PrintMsg Window T (fetch (NoteFile FullFileName) of NoteFile) " is not an open notefile.") (DISMISS 1000) (NC.ClearMsg Window T) elseif (PROCESSP (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress))) then (* * This will probably be overhauled with Randy G.'s concurrancy fixes) (NC.PrintOperationInProgressMsg Window (CAR Item) (NC.NoteFileProp NoteFile (QUOTE OperationInProgress))) NIL else (SELECTQ (CAR Item) (NewCards (if (NC.ReadOnlyNoteFileP NoteFile) then (FLASHW Window) (NC.PrintMsg Window T "Can't create a new card in a Read-Only notefile.") (DISMISS 1000) (NC.ClearMsg Window T) elseif (LASTMOUSESTATE LEFT) then (* For the left button, don't do anything until the button comes back up. Otherwise, things happen too soon.) (UNTILMOUSESTATE UP) (if (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) then (SHADEITEM Item Menu WHITESHADE) ( NC.MakeNoteCard NC.DefaultCardType NoteFile)) else (SHADEITEM Item Menu WHITESHADE) (NC.MakeNoteCard NIL NoteFile))) (ShowCards (if (LASTMOUSESTATE LEFT) then (* For the left button, don't do anything until the button comes back up. Otherwise, things happen too soon.) (UNTILMOUSESTATE UP) (if (INSIDEP (MENUITEMREGION Item Menu) (LASTMOUSEX Window) (LASTMOUSEY Window)) then (NC.EditNoteCard (fetch (NoteFile TableOfContentsCard) of NoteFile) (fetch (NoteFile ReadOnlyFlg) of NoteFile))) else (NC.ChooseTopLevelCard NoteFile))) NIL))) (RETURN) finally (if (LASTMOUSESTATE MIDDLE) then (NC.NoteFileIconMiddleButtonFn Window NoteFile) elseif (NULL (WINDOWPROP Window (QUOTE BusyOperation))) then (RESETLST (RESETSAVE (WINDOWPROP Window (QUOTE BusyOperation) "Operation") (BQUOTE (WINDOWPROP , Window BusyOperation NIL) )) (NC.NoteFileOperations NoteFile)) else (NC.PrintMsg NIL NIL (CHARACTER 13) (WINDOWPROP Window (QUOTE BusyOperation)) " in progress. Please wait."]) (NC.ChooseTopLevelCard [LAMBDA (NoteFile) (* Randy.Gobbel " 4-Nov-87 14:18") (* Let the user choose one of the top level cards. Top level cards are specified by globalvar NC.TopLevelCards which is a list of IDs) (* * fgh 11/14/85 Updated to handle NoteFile object and per NoteFile menus.) (* * kirk 6May86 Deleted SETQ of undeclared Menu var in the last expression) (* * rht 11/20/86: Now looks on "SpecialCards" prop of notefile for other cards to make available from ShowCards menu.) (* * pmi 3/20/87: Changed fields of NC.NoteCardTypeMenu: added 1 to ITEMHEIGHT, added title of "Special Cards") (* * pmi 3/25/87: Added NC.MenuFont to all menus) (* * rg 11/4/87 added ReadOnly to NC.EditNoteCard call) (DECLARE (GLOBALVARS NC.MenuFont)) (LET ((NoteFileMenu (fetch (NoteFile Menu) of NoteFile)) Menu W Z) [SETQ Menu (create MENU ITEMS ← (for Card in (APPEND (NC.FetchTopLevelCards NoteFile) (NC.NoteFileProp NoteFile (QUOTE SpecialCards))) when (NC.ValidCardP Card) collect (LIST (NC.RetrieveTitle Card) Card)) CENTERFLG ← T TITLE ← " Special Cards " MENUFONT ← NC.MenuFont ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont (QUOTE HEIGHT)) 1) WHENSELECTEDFN ← (FUNCTION (LAMBDA (Item Button Menu) (NC.EditNoteCard (CADR Item) (fetch (NoteFile ReadOnlyFlg) of NoteFile] (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NoteFileMenu) 2)) NoteFileMenu)) (SETQ Z (WINDOWPROP (WFROMMENU NoteFileMenu) (QUOTE REGION))) [replace (MENU MENUPOSITION) of Menu with (create POSITION XCOORD ← (IPLUS (fetch (REGION LEFT) of W) (fetch (REGION LEFT) of Z)) YCOORD ← (IPLUS (fetch (REGION TOP) of W) (fetch (REGION BOTTOM) of Z) (IMINUS (fetch (MENU IMAGEHEIGHT) of Menu] (MENU Menu]) ) (* * changes to NCCARDS) (DEFINEQ (NC.EditProperties [LAMBDA (TextStream) (* Randy.Gobbel " 1-Apr-87 12:25") (* Open a property list editor for the card corresponding to TextStream. Called from Title bar menus.) (* * fgh 11/13/85 Updated to handle Card object.) (* * rht 4/11/86: No longer sticks dates and Updates in property list. Only user-defined stuff.) (* * kef 7/22/86: Added call to card's obtain write permission function for the PROPLIST.) (* * fgh 8/30/86 Converted APPLY* to NC.ApplyFn.) (* * rht 1/16/87: Now uses NC.SystemCardPropNames globalvar.) (* * rg 4/1/87 added NC.ProtectedCardOperation wrapper) (DECLARE (GLOBALVARS NC.SystemCardPropNames)) (LET ((Card (NC.CoerceToCard (WINDOW.FROM.TEDIT.THING TextStream))) PropList PropEditorWindow) (NC.ProtectedCardOperation Card "Edit Properties" NIL (SETQ PropList (NC.FetchPropList Card)) (COND ((NC.ApplyFn ObtainWritePermissionFn Card (QUOTE PROPLIST)) (WINDOWPROP (SETQ PropEditorWindow (NC.OpenPropListEditor TextStream (for SubList on PropList by (CDDR SubList) when (NOT (FMEMB (CAR SubList) NC.SystemCardPropNames)) join (LIST (CAR SubList) (CADR SubList))) "Edit Property List")) (QUOTE ReleaseWritePermissionP) T) PropEditorWindow) (T (NC.CardPartBusy Card (QUOTE PROPLIST]) (NC.EditPropList [LAMBDA (propList window showOnlyFlg) (* Randy.Gobbel "20-Nov-87 14:45") (* * propList is a list of RECORDS of type PropListItem) (* * Edit a property list using the TEDIT menu-based editor. The var window is the window to use. If none supplied, get one from user.) (* * rht 4/11/86: Now stashes length of propList on WINDOWPROP.) (* * rht 8/12/86: Moved code to add NC.ClosePropListEditor on CLOSEFN from NC.OpenPropListEditor to here so that it can before TEDIT.DEACTIVATE.WINDOW on the CLOSEFN list.) (* * rht 1/16/87: Now stashes prop names on windowprop rather than number of props.) (* * pmi 3/25/87: Added NC.MenuFont to all menus) (* * rg 11/19/87 menu items put on global vars (for make read-only)) (* * rht/rg 11/20/87 Now kills any existing edit process in editW before starting new one.) (DECLARE (GLOBALVARS NC.MenuFont NC.ShowPropListMenu NC.EditPropListMenu)) (PROG (menuStream textObj editW button editProcess (font (FONTCREATE (QUOTE HELVETICA) 8)) (CH# 1) (ENDCH# 1)) (* Init the editList and the propFnsList) (* Create a TEDITMenu that reflects the structure of the proplist) [SETQ menuStream (\TEXTMENU.DOC.CREATE (for X in propList join (NCONC [LIST (LIST (QUOTE MB.BUTTON) (MKSTRING (fetch (PropListItem PropertyName) of X)) (OR (fetch (PropListItem ButtonFn) of X) (FUNCTION NC.EditPropButtonFN] (COND [(NOT (IMAGEOBJP (fetch (PropListItem Value) of X))) (COND ((fetch (PropListItem AllowEditFlg) of X) (LIST (LIST (QUOTE MB.TEXT) (CONCAT (CHARACTER 9) " [" (MKSTRING (fetch (PropListItem Value) of X)) "]" (CHARACTER 13)) font))) (T (LIST (LIST (QUOTE MB.TEXT) (CHARACTER 9) font) (LIST (QUOTE MB.INSERT) (MKSTRING (fetch (PropListItem Value) of X))) (LIST (QUOTE MB.TEXT) (CHARACTER 13) font] (T (LIST (LIST (QUOTE MB.TEXT) (CHARACTER 9) font) (LIST (QUOTE MB.INSERT)) (LIST (QUOTE MB.TEXT) (CHARACTER 13) font] (SETQ textObj (TEXTOBJ menuStream)) (* Go back and insert the ImageObjects into their value fields.) (SETQ CH# 0) [for prop in propList when (OR (IMAGEOBJP (fetch (PropListItem Value) of prop)) (NULL (fetch (PropListItem AllowEditFlg) of prop))) do (MBUTTON.FIND.NEXT.FIELD textObj (SETQ CH# (ADD1 CH#))) (SETQ CH# (fetch CH# of (fetch SCRATCHSEL of textObj))) (COND ((IMAGEOBJP (CADR prop)) (TEDIT.INSERT.OBJECT (fetch (PropListItem Value) of prop) menuStream CH#] (SETQ CH# 0) (for prop in propList do (SETQ button (MBUTTON.FIND.NEXT.BUTTON textObj (ADD1 CH#))) (SETQ CH# (CDR button)) (* If the buttonProtect flag is on, protect the button) (AND (fetch (PropListItem AllowSelectFlg) of prop) (IMAGEOBJPROP (CAR button) (QUOTE EditPropListNoDelete) T))) (* Set up window and window title) [SETQ editW (COND (window window) (T (CREATEW (GETREGION) "Edit Property List"] (* Point to the proplist being edited so we can update it when this menu is closed. (See NC.CloseEditPropListWindow)) (WINDOWPROP editW (QUOTE PROPERTYLIST.BEING.EDITED) propList) (WINDOWPROP editW (QUOTE PROPERTYLIST.PROPNAMES) (for Item in propList collect (CAR Item))) (* Set the right margin to very-far-away. Prevents stuff from wrapping around) (TEDIT.PARALOOKS textObj [QUOTE (RIGHTMARGIN 1000 TABS (50 (80 . LEFT] 1 (GETFILEINFO menuStream (QUOTE LENGTH))) (* Set the first tab so the fields will line up correctly) (* Set selection to the top -- make it look pretty) (replace (SELECTION SET) of (fetch (TEXTOBJ SEL) of textObj) with NIL) (* Kill any existing tedit process. Notice we have to do WINDOWPROP because calling TEXTSTREAM breaks if window doesn't have one.) (LET [(OldTextStream (WINDOWPROP editW (QUOTE TEXTSTREAM] (if (TEXTSTREAMP OldTextStream) then (TEDIT.KILL OldTextStream))) [SETQ editProcess (TEDIT menuStream editW NIL (LIST (QUOTE MENU) (COND (showOnlyFlg NC.ShowPropListMenu) (T NC.EditPropListMenu] (until (TEDIT-PROCESS-P editProcess) do (BLOCK)) (if showOnlyFlg then (NC.MakeTEditReadOnly editW)) (WINDOWADDPROP editW (QUOTE CLOSEFN) (FUNCTION NC.ClosePropListEditor) T]) (NC.ShowLinks [LAMBDA (CardIdentifier) (* rht: "30-Sep-87 15:31") (* Open an inspector for the links for note card specified by TextStream above the window for the note card.) (* * fgh 11/13/85 Updated to handle Card object.) (* * fgh 5/2/86 Included calls to NC.InsureLinkDisplayMode to handle litatom link display modes. Added InsdiePropListEditor and Reverse indicators to UserData field of Links in show links editor. Also added ShowLinks property onto the editor window so other functions can detect that a window is a show links window.) (* * rht 8/11/86: Now passes non-nil ShowLinksFlg to NC.OpenPropListEditor.) (* * rg 4/6/87 removed NC.ProtectedCardOperation wrapper.) (* * pmi 6/19/87: Now places each link's UID on the corresponding link created for the inspector. Checks for the validity of each link's source and destination cards and deletes links that are bad (half-links.)) (* * rht 9/30/87: Now takes arbitrary CardIdentifier as arg.) (LET ((Card (NC.CoerceToCard CardIdentifier)) Links EditWindow) [SETQ Links (NCONC [for Link in (NC.FetchToLinks Card) when (if (NC.ValidCardP (fetch (Link DestinationCard) of Link)) then (* The link is good, include it in the show links window.) T else (* The link is bad, delete it and don't include it in the show links window.) (NC.DeleteLink Link) NIL) join (LIST (COND ((EQ (fetch (Link AnchorMode) of Link) (QUOTE GlobalGlobal)) "Global TO") (T "TO")) (LIST (create Link using Link DisplayMode ← (create LINKDISPLAYMODE copying (NC.InsureLinkDisplayMode (fetch (Link DisplayMode) of Link)) SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T) UserData ← (QUOTE ( InsidePropListEditor T)) UID ← (fetch (Link UID) of Link] (for Link in (NC.FetchFromLinks Card) when (if (NC.ValidCardP (fetch (Link SourceCard) of Link)) then (* The link is good, include it in the show links window.) T else (* The link is bad, delete it and don't include it in the show links window.) (NC.DeleteLink Link) NIL) join (LIST "FROM" (LIST (create Link using Link DisplayMode ← (create LINKDISPLAYMODE copying (NC.InsureLinkDisplayMode (fetch (Link DisplayMode) of Link)) SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T) SourceCard ← (fetch (Link DestinationCard) of Link) DestinationCard ← (fetch (Link SourceCard) of Link) UserData ← (QUOTE (InsidePropListEditor T Reversed T)) UID ← (fetch (Link UID) of Link] (WINDOWPROP (SETQ EditWindow (NC.OpenPropListEditor (NC.FetchWindow Card) Links "List of Links" T T T)) (QUOTE ShowLinks) T) EditWindow]) (NC.PropListEditorOpenP [LAMBDA (Window ShowLinksFlg) (* rht: "30-Sep-87 12:10") (* Is there a prop list editor opened on this window?) (* * rht 8/11/86: Now doesn't return NIL unless there's an open proplist editor of our type.) (* * rht 9/30/87: Now returns the attached window if successful.) (for AttachedWindow in (ALLATTACHEDWINDOWS Window) thereis (AND (WINDOWPROP AttachedWindow (QUOTE PropListEditor)) [LET [(ShowLinks (WINDOWPROP AttachedWindow (QUOTE ShowLinks] (* Check that ShowLinksFlg iff ShowLinks.) (OR (AND ShowLinksFlg ShowLinks) (AND (NULL ShowLinksFlg) (NULL ShowLinks] AttachedWindow]) (NC.ClosePropListEditor [LAMBDA (Window SaveFlg) (* Randy.Gobbel "20-Nov-87 12:44") (* Close the prop list editor, saving or not saving the edited prop list as specified by the SaveFlg or by the user if SaveFlg is NIL) (* * fgh 11/13/85 Updated to handle Card object.) (* * fgh 6/8/86 Added call to RAPOSITIONATTACHEDWINDOWS) (* * rht 8/12/86 Now uses TEXTOBJ to get TextObj from window.) (* * kef 7/16/86: Added the call to release the write permission should the window property declare that it be necessary.) (* * kef 7/22/86: Now only releases the write permission if the card is inactive. The reason is that it was determined that a card being edited would update the property list upon being closed.) (* * fgh 8/30/86 Converted APPLY* to NC.ApplyFn. Added Card local var.) (* * rht 11/12/86: Now calls MAINWINDOW instead of WINDOWPROP to get Window's mainwindow and recovers card from a prop of Window.) (* * rht 1/16/87: Now checks that tedit stream has been modified before using user as to whether to save changes. No longer puts up stupid save/cancel menu.) (* * rht&rg 4/24/87: Now smashes more windowprops to prevent storage leaks.) (* * rg 11/20/87 now makes window read-write so TEDIT.QUIT will work - UGH!!) (DECLARE (GLOBALVARS NC.SavePropEditMenu)) (PROG (TextObj Answered OldPropList NewPropList MainWindow Card) (SETQ Card (WINDOWPROP Window (QUOTE SavedCardObject))) (SETQ MainWindow (MAINWINDOW Window)) (DETACHWINDOW Window) [SETQ TextObj (CAR (NLSETQ (TEXTOBJ Window] (SETQ OldPropList (WINDOWPROP Window (QUOTE PROPERTYLIST.BEING.EDITED))) [AND TextObj (COND ((EQ SaveFlg (QUOTE NoSave))) ((EQ (WINDOWPROP Window (QUOTE PropListEditor)) (QUOTE ShowOnly))) ((OR (EQ SaveFlg (QUOTE Save)) (TEDIT.STREAMCHANGEDP TextObj)) (SETQ NewPropList (NC.ExtractPropList Window)) (NC.ProcessEditedPropList NewPropList OldPropList Card] (WINDOWPROP Window (QUOTE TEDIT.MENU) NIL) (WINDOWPROP Window (QUOTE TEDIT.PROPS) NIL) (WINDOWPROP Window (QUOTE PropListEditor) NIL) (WINDOWPROP Window (QUOTE SavedCardObject) NIL) (WINDOWPROP Window (QUOTE PROPERTYLIST.BEING.EDITED) NIL) (WINDOWPROP Window (QUOTE PROPERTYLIST.PROPNAMES) NIL) (WINDOWDELPROP Window (QUOTE CLOSEFN) (FUNCTION NC.ClosePropListEditor)) (COND ((AND (WINDOWPROP Window (QUOTE ReleaseWritePermissionP)) (NOT (NC.ActiveCardP Card))) (NC.ApplyFn ReleaseWritePermissionFn Card (QUOTE PROPLIST)) (WINDOWPROP Window (QUOTE ReleaseWritePermissionP) NIL))) [COND (TextObj [if (NULL (WINDOWPROP Window (QUOTE PROCESS))) then (NC.MakeTEditReadWrite Window) (LET ((Process (MAKE-NEW-TEDIT-PROCESS Window))) (SETQ TEDIT-PROCESSES (CONS Process TEDIT-PROCESSES] (replace (TEXTOBJ \DIRTY) of TextObj with NIL) [\TEDIT.QUIT (CAR (MKLIST (fetch (TEXTOBJ \WINDOW) of TextObj] (until (fetch (TEXTOBJ EDITFINISHEDFLG) of TextObj) do (BLOCK] (ADD.PROCESS (BQUOTE (PROGN (until (NULL (OPENWP , Window)) do (BLOCK)) (REPOSITIONATTACHEDWINDOWS , MainWindow]) ) (PUTPROPS RGPATCH062 COPYRIGHT ("Xerox Corporation" 1987)) (DECLARE: DONTCOPY (FILEMAP (NIL (3097 8236 (NC.AddTextCard 3107 . 4736) (NC.BringUpTEditCard 4738 . 8234)) (8268 11691 ( NC.MakeTextCardReadOnly 8278 . 9705) (NC.MakeTextCardReadWrite 9707 . 10504) (NC.RevertTextCard 10506 . 11360) (NC.LastPieceOffset 11362 . 11689)) (11937 27657 (NC.PrintReadOnlyMsg 11947 . 13766) ( NC.CopyMenu 13768 . 14509) (NC.ReadOnlyTEditSelFn 14511 . 15072) (NC.MakeTEditReadOnly 15074 . 19054) (NC.MakeTEditReadWrite 19056 . 19872) (NC.NoteFileIconButtonEventFn 19874 . 25163) ( NC.ChooseTopLevelCard 25165 . 27655)) (28871 36664 (NC.NoteFileIconButtonEventFn 28881 . 34170) ( NC.ChooseTopLevelCard 34172 . 36662)) (36696 52915 (NC.EditProperties 36706 . 38468) (NC.EditPropList 38470 . 44435) (NC.ShowLinks 44437 . 48182) (NC.PropListEditorOpenP 48184 . 49089) ( NC.ClosePropListEditor 49091 . 52913))))) STOP