From e15c44577c2978039db4effdcb3f9dbcd0ec30a0 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 14 Jun 2016 14:46:01 +0200 Subject: [PATCH] add an option to deactivate IDE-grade features in with non D files, close #47 --- src/ce_editor.pas | 18 ++++++++++++++---- src/ce_editoroptions.pas | 4 ++++ src/ce_synmemo.pas | 25 ++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/ce_editor.pas b/src/ce_editor.pas index 65541e41..959915a2 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -678,9 +678,12 @@ end; procedure TCEEditorWidget.mnuedCallTipClick(Sender: TObject); begin - if fDoc.isNil then exit; + if fDoc.isNil then + exit; mnuEditor.Close; fDoc.hideDDocs; + if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then + exit; fDoc.showCallTips; end; @@ -704,14 +707,19 @@ end; procedure TCEEditorWidget.mnuedInvAllNoneClick(Sender: TObject); begin - if fDoc.isNotNil then - fDoc.CommandProcessor(ecSwapVersionAllNone, '', nil); + if fDoc.isNil then + exit; + if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then + exit; + fDoc.CommandProcessor(ecSwapVersionAllNone, '', nil); end; procedure TCEEditorWidget.MenuItem5Click(Sender: TObject); begin if fDoc.isNil then exit; + if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then + exit; with TSaveDialog.Create(nil) do try if execute then @@ -749,6 +757,8 @@ begin if fDoc.isNil then exit; mnuEditor.Close; fDoc.hideCallTips; + if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then + exit; fDoc.showDDocs; end; @@ -780,7 +790,7 @@ procedure TCEEditorWidget.mnuEditorPopup(Sender: TObject); begin if fDoc.isNil then exit; // - mnuedCut.Enabled:=fDOc.SelAvail; + mnuedCut.Enabled:=fDoc.SelAvail; mnuedPaste.Enabled:=fDoc.CanPaste; mnuedCopy.Enabled:=fDoc.SelAvail; mnuedUndo.Enabled:=fDoc.CanUndo; diff --git a/src/ce_editoroptions.pas b/src/ce_editoroptions.pas index d9289f27..69264f1a 100644 --- a/src/ce_editoroptions.pas +++ b/src/ce_editoroptions.pas @@ -60,6 +60,7 @@ type fCompletionMenuLines: Byte; fAutoCLoseCurlyBrace: TBraceAutoCloseStyle; fPhobosDocRoot: TCEPathname; + fAlwaysAdvancedFeatures: boolean; // procedure setPhobosDocRoot(value: TCEPathname); procedure setFont(value: TFont); @@ -77,6 +78,7 @@ type procedure setCompletionMenuLines(value: byte); procedure setLineNumEvery(value: integer); published + property alwaysAdvancedFeatures: boolean read fAlwaysAdvancedFeatures write fAlwaysAdvancedFeatures; property autoCloseCurlyBrace: TBraceAutoCloseStyle read fAutoCLoseCurlyBrace write fAutoCLoseCurlyBrace default TBraceAutoCloseStyle.autoCloseNever; property autoDotDelay: integer read fAutoDotDelay write SetautoDotDelay; property background: TColor read fBackground write fBackground default clWhite; @@ -269,6 +271,7 @@ begin begin srcopt := TCEEditorOptionsBase(src); // + fAlwaysAdvancedFeatures:=srcopt.fAlwaysAdvancedFeatures; fResetFontSize:=srcopt.fResetFontSize; fAutoCLoseCurlyBrace := srcopt.fAutoCLoseCurlyBrace; fCompletionMenuWidth:=srcopt.fCompletionMenuWidth; @@ -651,6 +654,7 @@ begin anEditor.IdentifierMatchOptions:= identifierMatchOptions; anEditor.detectIndentMode := detectIndentMode; anEditor.phobosDocRoot:=fPhobosDocRoot; + anEditor.alwaysAdvancedFeatures:=fAlwaysAdvancedFeatures; for i := 0 to anEditor.Keystrokes.Count-1 do begin kst := anEditor.Keystrokes.Items[i]; diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index dddd3e21..327bd814 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -145,6 +145,7 @@ type fDisableFileDateCheck: boolean; fDetectIndentMode: boolean; fPhobosDocRoot: string; + fAlwaysAdvancedFeatures: boolean; procedure decCallTipsLvl; procedure setMatchOpts(value: TIdentifierMatchOptions); function getMouseFileBytePos: Integer; @@ -225,6 +226,7 @@ type property isTemporary: boolean read getIfTemp; property TextView; // + property alwaysAdvancedFeatures: boolean read fAlwaysAdvancedFeatures write fAlwaysAdvancedFeatures; property phobosDocRoot: string read fPhobosDocRoot write fPhobosDocRoot; property detectIndentMode: boolean read fDetectIndentMode write fDetectIndentMode; property disableFileDateCheck: boolean read fDisableFileDateCheck write fDisableFileDateCheck; @@ -799,7 +801,8 @@ var numTabs: integer = 0; numSpac: integer = 0; begin - + if not fIsDSource and not alwaysAdvancedFeatures then + exit; i := CaretY - 1; while true do begin @@ -980,6 +983,8 @@ begin ecCompletionMenu: begin fCanAutoDot:=false; + if not fIsDSource and not alwaysAdvancedFeatures then + exit; fCompletion.Execute(GetWordAtRowCol(LogicalCaretXY), ClientToScreen(point(CaretXPix, CaretYPix + LineHeight))); end; @@ -991,12 +996,16 @@ begin begin hideCallTips; hideDDocs; + if not fIsDSource and not alwaysAdvancedFeatures then + exit; showDDocs; end; ecShowCallTips: begin hideCallTips; hideDDocs; + if not fIsDSource and not alwaysAdvancedFeatures then + exit; showCallTips(true); end; ecCurlyBraceClose: @@ -1226,6 +1235,8 @@ var str: string; i, x: integer; begin + if not fIsDSource and not alwaysAdvancedFeatures then + exit; if not fCallTipWin.Visible then fCallTipStrings.Clear; str := LineText[1..CaretX]; @@ -1273,6 +1284,8 @@ procedure TCESynMemo.showCallTips(const tips: string); var pnt: TPoint; begin + if not fIsDSource and not alwaysAdvancedFeatures then + exit; if tips.isEmpty then exit; // pnt := ClientToScreen(point(CaretXPix, CaretYPix)); @@ -1308,6 +1321,8 @@ var str: string; begin fCanShowHint := false; + if not fIsDSource and not alwaysAdvancedFeatures then + exit; DcdWrapper.getDdocFromCursor(str); // if str.isNotEmpty then @@ -1344,6 +1359,8 @@ end; {$REGION Completion ------------------------------------------------------------} procedure TCESynMemo.completionExecute(sender: TObject); begin + if not fIsDSource and not alwaysAdvancedFeatures then + exit; fCompletion.TheForm.Font.Size := Font.Size; getCompletionList; end; @@ -1471,7 +1488,8 @@ var ext: string; begin ext := aFilename.extractFileExt; - if not hasDlangSyntax(ext) then + fIsDsource := hasDlangSyntax(ext); + if not fIsDsource then Highlighter := TxtSyn; Lines.LoadFromFile(aFilename); fFilename := aFilename; @@ -1510,7 +1528,8 @@ begin Lines.SaveToFile(aFilename); fFilename := aFilename; ext := aFilename.extractFileExt; - if hasDlangSyntax(ext) then + fIsDsource := hasDlangSyntax(ext); + if fIsDsource then Highlighter := fD2Highlighter; FileAge(fFilename, fFileDate); fModified := false;