add an option to deactivate IDE-grade features in with non D files, close #47

This commit is contained in:
Basile Burg 2016-06-14 14:46:01 +02:00
parent b12b6829aa
commit e15c44577c
3 changed files with 40 additions and 7 deletions

View File

@ -678,9 +678,12 @@ end;
procedure TCEEditorWidget.mnuedCallTipClick(Sender: TObject); procedure TCEEditorWidget.mnuedCallTipClick(Sender: TObject);
begin begin
if fDoc.isNil then exit; if fDoc.isNil then
exit;
mnuEditor.Close; mnuEditor.Close;
fDoc.hideDDocs; fDoc.hideDDocs;
if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then
exit;
fDoc.showCallTips; fDoc.showCallTips;
end; end;
@ -704,14 +707,19 @@ end;
procedure TCEEditorWidget.mnuedInvAllNoneClick(Sender: TObject); procedure TCEEditorWidget.mnuedInvAllNoneClick(Sender: TObject);
begin begin
if fDoc.isNotNil then if fDoc.isNil then
fDoc.CommandProcessor(ecSwapVersionAllNone, '', nil); exit;
if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then
exit;
fDoc.CommandProcessor(ecSwapVersionAllNone, '', nil);
end; end;
procedure TCEEditorWidget.MenuItem5Click(Sender: TObject); procedure TCEEditorWidget.MenuItem5Click(Sender: TObject);
begin begin
if fDoc.isNil then if fDoc.isNil then
exit; exit;
if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then
exit;
with TSaveDialog.Create(nil) do with TSaveDialog.Create(nil) do
try try
if execute then if execute then
@ -749,6 +757,8 @@ begin
if fDoc.isNil then exit; if fDoc.isNil then exit;
mnuEditor.Close; mnuEditor.Close;
fDoc.hideCallTips; fDoc.hideCallTips;
if not fDoc.IsDSource and not fDoc.alwaysAdvancedFeatures then
exit;
fDoc.showDDocs; fDoc.showDDocs;
end; end;
@ -780,7 +790,7 @@ procedure TCEEditorWidget.mnuEditorPopup(Sender: TObject);
begin begin
if fDoc.isNil then exit; if fDoc.isNil then exit;
// //
mnuedCut.Enabled:=fDOc.SelAvail; mnuedCut.Enabled:=fDoc.SelAvail;
mnuedPaste.Enabled:=fDoc.CanPaste; mnuedPaste.Enabled:=fDoc.CanPaste;
mnuedCopy.Enabled:=fDoc.SelAvail; mnuedCopy.Enabled:=fDoc.SelAvail;
mnuedUndo.Enabled:=fDoc.CanUndo; mnuedUndo.Enabled:=fDoc.CanUndo;

View File

@ -60,6 +60,7 @@ type
fCompletionMenuLines: Byte; fCompletionMenuLines: Byte;
fAutoCLoseCurlyBrace: TBraceAutoCloseStyle; fAutoCLoseCurlyBrace: TBraceAutoCloseStyle;
fPhobosDocRoot: TCEPathname; fPhobosDocRoot: TCEPathname;
fAlwaysAdvancedFeatures: boolean;
// //
procedure setPhobosDocRoot(value: TCEPathname); procedure setPhobosDocRoot(value: TCEPathname);
procedure setFont(value: TFont); procedure setFont(value: TFont);
@ -77,6 +78,7 @@ type
procedure setCompletionMenuLines(value: byte); procedure setCompletionMenuLines(value: byte);
procedure setLineNumEvery(value: integer); procedure setLineNumEvery(value: integer);
published published
property alwaysAdvancedFeatures: boolean read fAlwaysAdvancedFeatures write fAlwaysAdvancedFeatures;
property autoCloseCurlyBrace: TBraceAutoCloseStyle read fAutoCLoseCurlyBrace write fAutoCLoseCurlyBrace default TBraceAutoCloseStyle.autoCloseNever; property autoCloseCurlyBrace: TBraceAutoCloseStyle read fAutoCLoseCurlyBrace write fAutoCLoseCurlyBrace default TBraceAutoCloseStyle.autoCloseNever;
property autoDotDelay: integer read fAutoDotDelay write SetautoDotDelay; property autoDotDelay: integer read fAutoDotDelay write SetautoDotDelay;
property background: TColor read fBackground write fBackground default clWhite; property background: TColor read fBackground write fBackground default clWhite;
@ -269,6 +271,7 @@ begin
begin begin
srcopt := TCEEditorOptionsBase(src); srcopt := TCEEditorOptionsBase(src);
// //
fAlwaysAdvancedFeatures:=srcopt.fAlwaysAdvancedFeatures;
fResetFontSize:=srcopt.fResetFontSize; fResetFontSize:=srcopt.fResetFontSize;
fAutoCLoseCurlyBrace := srcopt.fAutoCLoseCurlyBrace; fAutoCLoseCurlyBrace := srcopt.fAutoCLoseCurlyBrace;
fCompletionMenuWidth:=srcopt.fCompletionMenuWidth; fCompletionMenuWidth:=srcopt.fCompletionMenuWidth;
@ -651,6 +654,7 @@ begin
anEditor.IdentifierMatchOptions:= identifierMatchOptions; anEditor.IdentifierMatchOptions:= identifierMatchOptions;
anEditor.detectIndentMode := detectIndentMode; anEditor.detectIndentMode := detectIndentMode;
anEditor.phobosDocRoot:=fPhobosDocRoot; anEditor.phobosDocRoot:=fPhobosDocRoot;
anEditor.alwaysAdvancedFeatures:=fAlwaysAdvancedFeatures;
for i := 0 to anEditor.Keystrokes.Count-1 do for i := 0 to anEditor.Keystrokes.Count-1 do
begin begin
kst := anEditor.Keystrokes.Items[i]; kst := anEditor.Keystrokes.Items[i];

View File

@ -145,6 +145,7 @@ type
fDisableFileDateCheck: boolean; fDisableFileDateCheck: boolean;
fDetectIndentMode: boolean; fDetectIndentMode: boolean;
fPhobosDocRoot: string; fPhobosDocRoot: string;
fAlwaysAdvancedFeatures: boolean;
procedure decCallTipsLvl; procedure decCallTipsLvl;
procedure setMatchOpts(value: TIdentifierMatchOptions); procedure setMatchOpts(value: TIdentifierMatchOptions);
function getMouseFileBytePos: Integer; function getMouseFileBytePos: Integer;
@ -225,6 +226,7 @@ type
property isTemporary: boolean read getIfTemp; property isTemporary: boolean read getIfTemp;
property TextView; property TextView;
// //
property alwaysAdvancedFeatures: boolean read fAlwaysAdvancedFeatures write fAlwaysAdvancedFeatures;
property phobosDocRoot: string read fPhobosDocRoot write fPhobosDocRoot; property phobosDocRoot: string read fPhobosDocRoot write fPhobosDocRoot;
property detectIndentMode: boolean read fDetectIndentMode write fDetectIndentMode; property detectIndentMode: boolean read fDetectIndentMode write fDetectIndentMode;
property disableFileDateCheck: boolean read fDisableFileDateCheck write fDisableFileDateCheck; property disableFileDateCheck: boolean read fDisableFileDateCheck write fDisableFileDateCheck;
@ -799,7 +801,8 @@ var
numTabs: integer = 0; numTabs: integer = 0;
numSpac: integer = 0; numSpac: integer = 0;
begin begin
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
i := CaretY - 1; i := CaretY - 1;
while true do while true do
begin begin
@ -980,6 +983,8 @@ begin
ecCompletionMenu: ecCompletionMenu:
begin begin
fCanAutoDot:=false; fCanAutoDot:=false;
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
fCompletion.Execute(GetWordAtRowCol(LogicalCaretXY), fCompletion.Execute(GetWordAtRowCol(LogicalCaretXY),
ClientToScreen(point(CaretXPix, CaretYPix + LineHeight))); ClientToScreen(point(CaretXPix, CaretYPix + LineHeight)));
end; end;
@ -991,12 +996,16 @@ begin
begin begin
hideCallTips; hideCallTips;
hideDDocs; hideDDocs;
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
showDDocs; showDDocs;
end; end;
ecShowCallTips: ecShowCallTips:
begin begin
hideCallTips; hideCallTips;
hideDDocs; hideDDocs;
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
showCallTips(true); showCallTips(true);
end; end;
ecCurlyBraceClose: ecCurlyBraceClose:
@ -1226,6 +1235,8 @@ var
str: string; str: string;
i, x: integer; i, x: integer;
begin begin
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
if not fCallTipWin.Visible then if not fCallTipWin.Visible then
fCallTipStrings.Clear; fCallTipStrings.Clear;
str := LineText[1..CaretX]; str := LineText[1..CaretX];
@ -1273,6 +1284,8 @@ procedure TCESynMemo.showCallTips(const tips: string);
var var
pnt: TPoint; pnt: TPoint;
begin begin
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
if tips.isEmpty then exit; if tips.isEmpty then exit;
// //
pnt := ClientToScreen(point(CaretXPix, CaretYPix)); pnt := ClientToScreen(point(CaretXPix, CaretYPix));
@ -1308,6 +1321,8 @@ var
str: string; str: string;
begin begin
fCanShowHint := false; fCanShowHint := false;
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
DcdWrapper.getDdocFromCursor(str); DcdWrapper.getDdocFromCursor(str);
// //
if str.isNotEmpty then if str.isNotEmpty then
@ -1344,6 +1359,8 @@ end;
{$REGION Completion ------------------------------------------------------------} {$REGION Completion ------------------------------------------------------------}
procedure TCESynMemo.completionExecute(sender: TObject); procedure TCESynMemo.completionExecute(sender: TObject);
begin begin
if not fIsDSource and not alwaysAdvancedFeatures then
exit;
fCompletion.TheForm.Font.Size := Font.Size; fCompletion.TheForm.Font.Size := Font.Size;
getCompletionList; getCompletionList;
end; end;
@ -1471,7 +1488,8 @@ var
ext: string; ext: string;
begin begin
ext := aFilename.extractFileExt; ext := aFilename.extractFileExt;
if not hasDlangSyntax(ext) then fIsDsource := hasDlangSyntax(ext);
if not fIsDsource then
Highlighter := TxtSyn; Highlighter := TxtSyn;
Lines.LoadFromFile(aFilename); Lines.LoadFromFile(aFilename);
fFilename := aFilename; fFilename := aFilename;
@ -1510,7 +1528,8 @@ begin
Lines.SaveToFile(aFilename); Lines.SaveToFile(aFilename);
fFilename := aFilename; fFilename := aFilename;
ext := aFilename.extractFileExt; ext := aFilename.extractFileExt;
if hasDlangSyntax(ext) then fIsDsource := hasDlangSyntax(ext);
if fIsDsource then
Highlighter := fD2Highlighter; Highlighter := fD2Highlighter;
FileAge(fFilename, fFileDate); FileAge(fFilename, fFileDate);
fModified := false; fModified := false;