//***************************************************************************************** // Copyright (c) 2000 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : cEditorEditView.Pkg // $ProjectName : CODEMAX EDITOR // $Author : Michael Kurz // $Created : 01-25-2001 @ 19:00 // // Contents: // // // $Rev History // //***************************************************************************************** // TRF 11/05/2004 - Procedure savefile has been amended to not save a file if it hasn't been // saved. This takes care of the problem with a "save all" saving // nonchanged files unconditionally hereby risking to overwrite changed sources. // Use cIconView.Pkg Use cTreeViewEx.Pkg Use cEditorElementsView.Pkg Use cEditorHotKey_Mixin.pkg Register_Procedure Define_EditViewHotkeys Handle hoEditView Class cEditorEditView Is a cIconView Import_Class_Protocol cEditorHotKey_Mixin Procedure Construct_Object Forward Send Construct_Object // SVN on 29/03/2017, new file tabs support Property String psFileName "" Property Integer piElement 0 Property Handle phoCodeMaxEditor 0 Property Handle phoEditorEditView Self Property Boolean pbClosingPanel False End_Procedure Procedure End_Construct_Object Integer hoID Forward Send end_Construct_Object Move Self To hoID Object oParser Is a cParser End_Object Object oEdit Is a cEditorEdit Set GuiLocation To 0 100 Set phoParser To (oParser(Parent(Self))) Set piListID Of (oParser(Parent(Self))) To Self Set size To 100 200 // Changed and added to support a own PopUp Menu // 17.05.01 Bernhard //Object oEditorPopupMenu is a cEditorPopupMenu //End_Object Set Floating_Menu_Object To ghoEditorPopupMenu Set phoCodeMaxEditor To Self Send Define_cEditorHotKey_Mixin End_Object Object oEditorElements Is a cEditorElements Set GuiLocation To 15 0 // Here! Set GuiSize To 100 100 Set Visible_State To (pbCodeViewVisible(ghoEditorProperties)) Set Object_Shadow_State To (Not(pbCodeViewVisible(ghoEditorProperties))) // not yet mixed in (sorry) //Send Define_cEditorHotKey_Mixin End_Object Property Integer phoElements (oEditorElements(Self)) Object oElementTools Is a cElementTools Set GUILocation To 0 0 Set GUISize To 15 100 // not yet mixed in (sorry) //Send Define_cEditorHotKey_Mixin End_Object Object oVerticalSplitter1 Is a cVerticalSplitter Set GuiLocation To 0 200 If (piCodeViewWidth(ghoEditorProperties)) Ne 0 ; Set GuiLocation To 0 (piCodeViewWidth(ghoEditorProperties)) Set Visible_State To (pbCodeViewVisible(ghoEditorProperties)) Set GuiSize To 100 3 Send DoAddObjectToNotify hoID End_Object Set Border_Style To Border_Thick Set Maximize_Icon To True Set LargeTaskbarIcon To "" Set SmallTaskbarIcon To "VIEW16.bmp" Set IconTransparentColor To (Rgb(255,255,0)) Send Adjust_Logicals //On_Key key_alt+key_f3 Send HideIt On_Key key_Ctrl+key_F4 Send CloseFileXButton Send Define_cEditorHotKey_Mixin End_Procedure Procedure CME_Find Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send Find Of hoEdit End End_Procedure Procedure CME_FindNext Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send FindNext Of hoEdit End End_Procedure Procedure CME_FindPrevious Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send FindPrevious Of hoEdit End End_Procedure Procedure CME_FindReplace Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send Replace Of hoEdit End End_Procedure Procedure CME_GotoLine Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send GotoLine Of hoEdit End End_Procedure Procedure CME_SelectAll Handle hoEdit Get phoCodeMaxEditor To hoEdit If (hoEdit) Begin Send Activate Of hoEdit Send SelectAll Of hoEdit End End_Procedure Procedure SetCodeViewVisible Integer iFlag Set Visible_State Of (oEditorElements(Self)) To iFlag Set Visible_State Of (oElementTools(Self)) To iFlag Set Object_Shadow_State Of (oEditorElements(Self)) To (Not(iFlag)) Set visible_State Of (oVerticalSplitter1(Self)) To iFlag Set GuiSize To (Hi(GuiSize(Self))) (Low(GuiSize(Self))) Set pbCodeViewVisible Of ghoEditorProperties To iFlag End_Procedure Procedure HideIt Send SetCodeViewVisible (Not(Visible_State(oEditorElements(Self)))) End_Procedure Procedure OnSplitterChange Integer iTrack Integer hoID Move (oEditorElements(Self)) To hoID If (Object_Shadow_State(hoID)) Procedure_Return 1 Set GuiSize Of hoID To (Hi(GuiSize(hoID))) (Low(GuiSize(hoID))+iTrack) Move (oEdit(Self)) To hoID Set GuiSize Of hoID To (Hi(GuiSize(hoID))) (Low(GuiSize(hoID))-iTrack) Set GuiLocation Of hoID To (Hi(GuiLocation(hoID))) (Low(GuiLocation(hoID))+iTrack) Set piCodeViewWidth Of ghoEditorProperties To ; (Low(GuiLocation(oVerticalSplitter1(Self)))+iTrack) End_Procedure // OnSplitterChange // Cancel the Splitting request if the object shadow state of EditorElements is TRUE // Otherwise the splitter is lost (in space??) // 03.03.2003 BP Procedure OnRequestSplitter If (object_shadow_state(oEditorElements(Self))) Procedure_Return 1 End_Procedure Procedure DestroyObject Send Destroy //Send Request_Destroy_Object //send DestroyObject to (oEdit(Self)) //send Destroy_Object End_Procedure // Stores the view_mode which is used for opening. Procedure Set View_Mode Integer iMode //Procedure_Return If Not BuildingObjectID Begin If iMode Eq ViewMode_Zoom Delegate Set piViewsZoomed To True Else Delegate Set piViewsZoomed To False If ( (iMode Eq ViewMode_Normal) Or (iMode Eq ViewMode_Zoom) ) If Not BuildingObjectID ; Set piViewMode Of ghoEditorProperties To iMode End Forward Set View_Mode To iMode End_Procedure Procedure Set GuiSize Integer iY Integer iX Integer iPos If ( (iY Lt 10) Or (iX Lt 10) ) Procedure_Return Forward Set guiSize To iY iX If Not (oEdit(Self)) Procedure_Return If iY Gt 100 If iX Gt 150 If (View_Mode(Self)) Ne ViewMode_Zoom Begin Set piViewSize.Y Of ghoEditorProperties To iY Set piViewSize.X Of ghoEditorProperties To iX End Move ( Hi(Client_Size(Self))) To iY Move (Low(Client_Size(Self))) To iX Set GuiSize Of (oVerticalSplitter1(Self)) To iY 3 Move (Low(GuiLocation(oVerticalSplitter1(Self)))+3) To iPos If Not (Visible_State(oEditorElements(Self))) Move 0 To iPos Send Adjust_Logicals To (oVerticalSplitter1(Self)) Set GuiSize Of (oEditorElements(Self)) To iY (iPos-3) Send Adjust_Logicals To (oEditorElements(Self)) Set GuiLocation Of (oEdit(Self)) To -1 iPos //0 Set GuiSize Of (oEdit(Self)) To (iY+3) (iX-iPos) //-0 Send Adjust_Logicals To (oEdit(Self)) End_Procedure //_ACCESS_PROCEDURES..._________________________ // Set a little a "*" at the end of the filename or remove it. // SVN on 29/03/2017, new file tabs support Procedure onModifiedChange Integer bModified String sLabel sCaption Boolean bHasChanged Get Label to sLabel If (sLabel<>"") Begin Get psFileName to sCaption Move (RTrim(sLabel)) to sLabel Move (False) to bHasChanged If not bModified If (Right(sLabel,2)) Eq " *" Begin Move (Left(sLabel,Length(sLabel)-2)) to sLabel Move (True) to bHasChanged End Else If (Right(sLabel,2)) Ne " *" Begin Move (Append(sLabel," *")) to sLabel Move (sCaption + "*") to sCaption Move (True) to bHasChanged End If (bHasChanged) ; Send ShadowToolbarItem TBItem_Save (not(bModified)) Send UpdateCaption sCaption Set Label to (ToOEM(sLabel)) Send CAOnLabelChanged (Self) End End_Procedure Function GetOpenFile Returns String String sFile sTypes Get psFileTypes Of ghoEditorProperties To sTypes Get FileDialog False (_T("Open file", 770)) sTypes "" To sFile Function_Return sFile End_Function Function GetSaveFile Returns String String sFile sTypes Get psFileTypes Of ghoEditorProperties To sTypes Get FileDialog True (_T("Save file as", 771)) sTypes "" To sFile Function_Return sFile End_Function // SVN on 29/03/2017, new file tabs support Function GetFileName Returns String String sFileName Get psFileName to sFileName Move (RTrim(sFileName)) to sFileName Function_Return sFileName End_Function Function Base_FileName String sIn Returns String //@RRS Integer iLen iCnt String DirSep Move (Sysconf(SYSCONF_DIR_SEPARATOR)) To DirSep Move (Length(sIn)) To iLen Move iLen To iCnt While iCnt Gt 0 If (Mid(sIn,1,iCnt)) Eq DirSep Function_Return (Right(sIn,iLen-iCnt)) Decrement iCnt End // While iCnt Gt 0 Function_Return sIn End_Function // Base_FileName // SVN on 29/03/2017, new file tabs support Procedure Activate String sLabel sCaption Get Label to sLabel Move 0 To ghoCurrentFileTab If (pbClosingPanel(Self)=false) Begin // somehow the activate gets called from a deactivate (weird) Get psFileName to sCaption If (Right(Trim(sLabel), 1)="*") Move (sCaption+"*") to sCaption Send UpdateCaption sCaption End Forward Send Activate End_Procedure Procedure notify_focus_change Integer iFlag If iFlag Delegate Send NotifyActiveView Self Else Delegate Send NotifyActiveView 0 Forward Send notify_focus_change iFlag End_Procedure // SVN on 29/03/2017, new file tabs support Procedure OpenFile String sFile Integer iRet Handle hoParser String sFileName If (sFile="") Move CM_NewFileName To sFile Set psFileName to sFile // set here too, so that can configure for the correct language Get phoParser of oEdit to hoParser If (hoParser) Begin Set pbParseOnFileLoad of hoParser To True End Send Popup If (sFile <> CM_NewFileName) Begin Get CM_OpenFile Of (oEdit(Self)) sFile To iRet End Else Set Label To CM_NewFileName If iRet Begin Send UpdateCaption sFile Set psFileName to sFile // Move (FileFromPath(sFile)) to sFileName Set Label to (ToOem(sFileName)) If ghoCurrentFileTab Begin Set ComToolTip of ghoCurrentFileTab to sFile Send Destroy to ghoCurrentFileTab End End Procedure_Return iRet End_Procedure // SVN on 29/03/2017, new file tabs support Procedure SaveFileAs Integer iRet String sFile sFileName sFileNameOld Move (GetFileName(Self)) To sFileNameOld Move (GetSaveFile(Self)) To sFile If sFile Eq "" Procedure_Return 1 If sFile Ne "" Get CM_SaveFile Of (oEdit(Self)) sFile False To iRet If iRet Begin Send UpdateCaption sFile Move (FileFromPath(sFile)) to sFileName Set psFileName to sFile Set Label to (ToOem(sFileName)) If (Trim(gsCurrentProgramFile)) Eq (Trim(GetFileName(Self))) Send SetCurrentProgramFile sFileName If (Trim(gsCurrentProgramFile)) Eq (Trim(sFileNameOld)) Send SetCurrentProgramFile sFileName Send CAOnLabelChanged (Self) End If Not iRet Procedure_Return 1 End_Procedure Procedure SaveFile Integer iRet iReadOnly String sBackup Boolean bModified Boolean bCreateBackups Get CM_IsModified Of (oEdit(Self)) To bModified If (Not(bModified)) Procedure_Return // TRF 11/05/2004 - Bail out if the file has not been modified Move (CM_isReadOnly(oEdit(Self))) To iReadOnly If iReadOnly Procedure_Return If (GetFileName(Self)) Eq CM_NewFileName Get Msg_SaveFileAs To iRet Else Begin Get pbFileSaveBackup Of ghoEditorProperties To bCreateBackups If (bCreateBackups) Begin // Added to make a backup-copy of the original file // 18.05.01 Bernhard Move (GetFileName(Self)) To sBackup Move ((Trim(sBackup)) + ".BAK") To sBackup // Changed to speed up the Backup // 22.05.01 Bernhard Send RenameFileEx (GetFileName(Self)) sBackup True End Get CM_SaveFile Of (oEdit(Self)) (GetFileName(Self)) False To iRet Move (Not(iRet)) To iRet End Procedure_Return iRet End_Procedure // Changed to support Reopen of Files based on Workspace // 07/06/2017 - SVN Procedure CreateEditorEntry String sFile Get GetFileName To sFile If sFile Ne CM_NewFileName ; Send THWS_SaveOpened sFile (phoCodeMaxEditor(Self)) End_Procedure // Prints the File. Procedure PrintFile Integer iRet // ToDo: Add Printing support for Scintilla! End_Procedure Procedure WindowSwitchToCodeView Boolean bVisible Handle hoCodeView Get pbCodeViewVisible of ghoEditorProperties to bVisible If Not (bVisible) Begin Set pbCodeViewVisible Of ghoEditorProperties To (Not(pbCodeViewVisible(ghoEditorProperties))) Send CAWindowCodeExplorerONOFF To (oClientArea(Self)) (pbCodeViewVisible(ghoEditorProperties)) End If (Object_Shadow_State(oEditorElements(Self))) Procedure_Return Get phoCodeView of oEditorElements to hoCodeView If (hoCodeView) Begin Send Activate of hoCodeView End End_Procedure Function GetEditViewID Returns Handle Function_Return Self End_Function Function isEditView Returns Integer Function_Return 1 End_Function // Closes the file. Procedure CloseFile Integer iRet iErg hoEdit String sFile String sFileName String szText //Send Info_box ("investigating crash, not reproducable when in debugger\nclosing file"*GetFileName(Self)) "BugMeNow" Move (oEdit(Self)) To hoEdit // when closing down this will contain another object # on each call from CACloseAllFiles // the object name however always is main.oClientArea.ofile.oedit If (CM_IsModified(hoEdit)) Begin Append sFile "Save changes to " (GetFileName(Self)) "?" Get YesNoCancel_Box sFile (Label(Main_Panel_ID(Self))) To iRet If iRet Eq MBR_Cancel Procedure_Return 1 If iRet Eq MBR_Yes Begin Get Msg_SaveFile To iRet If iRet Procedure_Return 1 End End If (Trim(gsCurrentProgramFile)) Eq (Trim(GetFileName(Self))) Send SetCurrentProgramFile "" //move "" to gsCurrentProgramFile // We're closing the file, no need to clean this up. // Besides on very very rare occasions this is the EXACT line where you'll get a crash (see my 20110922 data example) //Move (CM_Settext(hoEdit,szText)) To iRet Send UpdateCaption "" Move (CM_ClearUndoBuffer(hoEdit)) To iRet Send Close_Panel Send DestroyObject Procedure_Return 0 End_Procedure Procedure RemoveCurrentFileFromReOpenList String sFileName Get GetFileName To sFileName If (sFileName<>"") Send THWS_DeleteOpened sFileName End_Procedure // RemoveCurrentFileFromReOpenList // // This method gets called from the x-button in the tab and should not // delegate upwards as then it will close the tab that has the focus while // the action might be triggered from another tab you want to close as a user. // Procedure CACloseFile Send CloseFileXButton End_Procedure // If we are getting here then we have a user initiated file close // This means that we do not want to see the file re-appear when we // reopen the hammer. So remove it from our editor file. // // Also do close the file, thank you. // Procedure CloseFileXButton Send RemoveCurrentFileFromReOpenList Send CloseFile End_Procedure // For clearing the Status Infos when new file is opened. Procedure Close_Panel Set pbClosingPanel To True Delegate Send ClearStatusInfos Forward Send Close_Panel End_Procedure // For flicker-free activating the menu via the Window-Menu Procedure activate_mdi_view_menu Integer hoObj Move (Self) To hoObj Delegate Send activate_mdi_view_menu hoObj End_Procedure End_Class