mirror of https://gitlab.com/basile.b/dexed.git
fix #85 - Add local, non semantic, completions
This commit is contained in:
parent
077b4c35e7
commit
3df1a3b720
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Enhancement
|
## Enhancement
|
||||||
|
|
||||||
|
- editor: a new option, _textCompletion_, sets if the completion menu includes the identifiers obtained by word-splitting the whole document. (#85)
|
||||||
- Halstead metrics: show full function signatures.
|
- Halstead metrics: show full function signatures.
|
||||||
- projects: added the _Check semantics_ to the menu. (#83)
|
- projects: added the _Check semantics_ to the menu. (#83)
|
||||||
- DUB projects: added support for the _syntax_ build type. (#83)
|
- DUB projects: added support for the _syntax_ build type. (#83)
|
||||||
|
|
|
@ -106,7 +106,7 @@ The category _Highlighter presets_ can be used to customize more easily the styl
|
||||||
|
|
||||||
The shortcuts are editable in the [shortcut editor](options_shortcuts_editor.html), under the category _Code editor._
|
The shortcuts are editable in the [shortcut editor](options_shortcuts_editor.html), under the category _Code editor._
|
||||||
|
|
||||||
- **alwaysAdvancedFeatures**: When checked, auto-closing or DCD features also work on documents that don't have the _.d_ or the _.di_ extensions.
|
- **alwaysAdvancedFeatures**: When checked, brace completions and other code editing features also work on documents that don't have the _.d_ or the _.di_ extensions.
|
||||||
- **autoCallCompletion**: Call completion after an alphabetic character, without explicit <kbd>CTRL</kbd>+<kbd>SPACE</kbd>.
|
- **autoCallCompletion**: Call completion after an alphabetic character, without explicit <kbd>CTRL</kbd>+<kbd>SPACE</kbd>.
|
||||||
- **autoCloseCurlyBraces**: See the _Automatic features_ section.
|
- **autoCloseCurlyBraces**: See the _Automatic features_ section.
|
||||||
- **autoClosedPairs**: See the _Automatic features_ section.
|
- **autoClosedPairs**: See the _Automatic features_ section.
|
||||||
|
@ -128,5 +128,7 @@ The shortcuts are editable in the [shortcut editor](options_shortcuts_editor.htm
|
||||||
- **plusDdoc**: Sets if instead of `*`, `+` are used in the comment produced by the command _Insert DDoc Template_.
|
- **plusDdoc**: Sets if instead of `*`, `+` are used in the comment produced by the command _Insert DDoc Template_.
|
||||||
- **resetFontSize**: When checked and if the font size is modified then the font size is resets in all the documents that are opened. The option can be disabled in order to keep the current zoom ratio.
|
- **resetFontSize**: When checked and if the font size is modified then the font size is resets in all the documents that are opened. The option can be disabled in order to keep the current zoom ratio.
|
||||||
- **smartDdocNewLine**: Allow the auto insertion of a leading `*` or a `+` while writing documentation comments.
|
- **smartDdocNewLine**: Allow the auto insertion of a leading `*` or a `+` while writing documentation comments.
|
||||||
|
- **textCompletion**: Sets if the completion menu contains the identifiers obtained by word-splitting the whole document.
|
||||||
|
- **textCompletionMinLength**: Sets the minimum length a word must have when _textCompletion_ is activated.
|
||||||
|
|
||||||
<script>anchors.add();</script>
|
<script>anchors.add();</script>
|
||||||
|
|
|
@ -440,7 +440,7 @@ begin
|
||||||
pge.Align:= alClient;
|
pge.Align:= alClient;
|
||||||
|
|
||||||
fPages.Add(pge);
|
fPages.Add(pge);
|
||||||
fTabs.Tabs.Add(format('', [fPages.Count]));
|
fTabs.Tabs.Add('%d', [fPages.Count]);
|
||||||
setPageIndex(fTabs.Tabs.Count-1);
|
setPageIndex(fTabs.Tabs.Count-1);
|
||||||
|
|
||||||
result := pge;
|
result := pge;
|
||||||
|
|
|
@ -72,6 +72,8 @@ type
|
||||||
fDscannerDelay: integer;
|
fDscannerDelay: integer;
|
||||||
fDscannerEnabled: boolean;
|
fDscannerEnabled: boolean;
|
||||||
fScrollPreview: boolean;
|
fScrollPreview: boolean;
|
||||||
|
fTextCompletion: boolean;
|
||||||
|
fTextCompletionMinLength : integer;
|
||||||
//
|
//
|
||||||
procedure setPhobosDocRoot(value: TPathname);
|
procedure setPhobosDocRoot(value: TPathname);
|
||||||
procedure setFont(value: TFont);
|
procedure setFont(value: TFont);
|
||||||
|
@ -134,6 +136,8 @@ type
|
||||||
property smartDdocNewline: boolean read fSmartDdocNewline write fSmartDdocNewline;
|
property smartDdocNewline: boolean read fSmartDdocNewline write fSmartDdocNewline;
|
||||||
property tabulationWidth: Integer read fTabWidth write fTabWidth default 4;
|
property tabulationWidth: Integer read fTabWidth write fTabWidth default 4;
|
||||||
property transparentGutter: boolean read fTransparentGutter write fTransparentGutter default false;
|
property transparentGutter: boolean read fTransparentGutter write fTransparentGutter default false;
|
||||||
|
property textCompletion: boolean read fTextCompletion write fTextCompletion default true;
|
||||||
|
property textCompletionMinLength: integer read fTextCompletionMinLength write fTextCompletionMinLength default 3;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
@ -272,6 +276,9 @@ begin
|
||||||
mouseOptions := MouseOptions +
|
mouseOptions := MouseOptions +
|
||||||
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks];
|
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks];
|
||||||
//
|
//
|
||||||
|
fTextCompletion:=true;
|
||||||
|
fTextCompletionMinLength:=3;
|
||||||
|
//
|
||||||
fShortCuts := TCollection.Create(TPersistentShortcut);
|
fShortCuts := TCollection.Create(TPersistentShortcut);
|
||||||
ed := TSynEdit.Create(nil);
|
ed := TSynEdit.Create(nil);
|
||||||
try
|
try
|
||||||
|
@ -355,6 +362,8 @@ begin
|
||||||
rightEdge := srcopt.rightEdge;
|
rightEdge := srcopt.rightEdge;
|
||||||
rightEdgeColor := srcopt.rightEdgeColor;
|
rightEdgeColor := srcopt.rightEdgeColor;
|
||||||
fShortCuts.Assign(srcopt.fShortCuts);
|
fShortCuts.Assign(srcopt.fShortCuts);
|
||||||
|
textCompletion:=srcopt.textCompletion;
|
||||||
|
textCompletionMinLength:=srcopt.textCompletionMinLength;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
inherited;
|
inherited;
|
||||||
|
@ -726,6 +735,8 @@ begin
|
||||||
anEditor.transparentGutter:=fTransparentGutter;
|
anEditor.transparentGutter:=fTransparentGutter;
|
||||||
anEditor.setDscannerOptions(fDscannerEnabled, fDscannerDelay);
|
anEditor.setDscannerOptions(fDscannerEnabled, fDscannerDelay);
|
||||||
anEditor.scrollPreview:=fScrollPreview;
|
anEditor.scrollPreview:=fScrollPreview;
|
||||||
|
anEditor.textCompletion:=fTextCompletion;
|
||||||
|
anEditor.textCompletionMinLength:=fTextCompletionMinLength;
|
||||||
|
|
||||||
if not (eoTabsToSpaces in options1) then
|
if not (eoTabsToSpaces in options1) then
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -448,7 +448,8 @@ type
|
||||||
dckAA,
|
dckAA,
|
||||||
dckAlias,
|
dckAlias,
|
||||||
dckTemplate,
|
dckTemplate,
|
||||||
dckMixin
|
dckMixin,
|
||||||
|
dckText
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,8 @@ type
|
||||||
fScrollPreview: boolean;
|
fScrollPreview: boolean;
|
||||||
fDiffDialogWillClose: boolean;
|
fDiffDialogWillClose: boolean;
|
||||||
fMultiGutterMarks: TSynMultiGutterMarks;
|
fMultiGutterMarks: TSynMultiGutterMarks;
|
||||||
|
fTextCompletion: boolean;
|
||||||
|
fTextCompletionMinLength: integer;
|
||||||
procedure showHintEvent(Sender: TObject; HintInfo: PHintInfo);
|
procedure showHintEvent(Sender: TObject; HintInfo: PHintInfo);
|
||||||
procedure setGutterTransparent(value: boolean);
|
procedure setGutterTransparent(value: boolean);
|
||||||
procedure decCallTipsLvl;
|
procedure decCallTipsLvl;
|
||||||
|
@ -412,6 +414,8 @@ type
|
||||||
property closeCompletionChars: TSysCharSet read fCloseCompletionChars write fCloseCompletionChars;
|
property closeCompletionChars: TSysCharSet read fCloseCompletionChars write fCloseCompletionChars;
|
||||||
property completionMenuAutoClose: boolean read fCompletionMenuAutoClose write fCompletionMenuAutoClose;
|
property completionMenuAutoClose: boolean read fCompletionMenuAutoClose write fCompletionMenuAutoClose;
|
||||||
property scrollPreview: boolean read fScrollPreview write fScrollPreview;
|
property scrollPreview: boolean read fScrollPreview write fScrollPreview;
|
||||||
|
property textCompletion: boolean read fTextCompletion write fTextCompletion default true;
|
||||||
|
property textCompletionMinLength: integer read fTextCompletionMinLength write fTextCompletionMinLength default 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSortDialog = class(TForm)
|
TSortDialog = class(TForm)
|
||||||
|
@ -505,7 +509,8 @@ const
|
||||||
' (associative array)',
|
' (associative array)',
|
||||||
' (alias) ',
|
' (alias) ',
|
||||||
' (template) ',
|
' (template) ',
|
||||||
' (mixin) '
|
' (mixin) ',
|
||||||
|
' (text) '
|
||||||
);
|
);
|
||||||
|
|
||||||
{$REGION TEditorCallTipWindow --------------------------------------------------}
|
{$REGION TEditorCallTipWindow --------------------------------------------------}
|
||||||
|
@ -1618,8 +1623,6 @@ 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;
|
||||||
|
@ -2842,10 +2845,11 @@ end;
|
||||||
{$REGION Completion ------------------------------------------------------------}
|
{$REGION Completion ------------------------------------------------------------}
|
||||||
procedure TDexedMemo.completionExecute(sender: TObject);
|
procedure TDexedMemo.completionExecute(sender: TObject);
|
||||||
begin
|
begin
|
||||||
if not fIsDSource and not alwaysAdvancedFeatures then
|
if fIsDSource then
|
||||||
exit;
|
begin
|
||||||
hideDDocs;
|
hideDDocs;
|
||||||
hideCallTips;
|
hideCallTips;
|
||||||
|
end;
|
||||||
fCompletion.TheForm.Font.Size := Font.Size;
|
fCompletion.TheForm.Font.Size := Font.Size;
|
||||||
fCompletion.TheForm.BackgroundColor:= self.Color;
|
fCompletion.TheForm.BackgroundColor:= self.Color;
|
||||||
fCompletion.TheForm.TextColor:= fD2Highlighter.identifiers.Foreground;
|
fCompletion.TheForm.TextColor:= fD2Highlighter.identifiers.Foreground;
|
||||||
|
@ -2879,24 +2883,42 @@ procedure TDexedMemo.getCompletionList;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
o: TObject;
|
o: TObject;
|
||||||
|
s: string;
|
||||||
|
r: TStringRange = (ptr:nil; pos:0; len: 0);
|
||||||
|
const
|
||||||
|
c: TSysCharSet = ['A'..'Z', 'a'..'z', '_'];
|
||||||
begin
|
begin
|
||||||
if not DcdWrapper.available then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
fCompletion.Position := 0;
|
fCompletion.Position := 0;
|
||||||
fCompletion.ItemList.Clear;
|
fCompletion.ItemList.Clear;
|
||||||
DcdWrapper.getComplAtCursor(TStringList(fCompletion.ItemList));
|
|
||||||
if fLastCompletion.isNotEmpty then
|
if fIsDSource and DCDWrapper.available then
|
||||||
begin
|
begin
|
||||||
i := fCompletion.ItemList.IndexOf(fLastCompletion);
|
DcdWrapper.getComplAtCursor(TStringList(fCompletion.ItemList));
|
||||||
if i <> -1 then
|
if fLastCompletion.isNotEmpty then
|
||||||
begin
|
begin
|
||||||
o := fCompletion.ItemList.Objects[i];
|
i := fCompletion.ItemList.IndexOf(fLastCompletion);
|
||||||
fCompletion.ItemList.Delete(i);
|
if i <> -1 then
|
||||||
fCompletion.ItemList.InsertObject(0, fLastCompletion, o);
|
begin
|
||||||
end
|
o := fCompletion.ItemList.Objects[i];
|
||||||
else fLastCompletion:= '';
|
fCompletion.ItemList.Delete(i);
|
||||||
|
fCompletion.ItemList.InsertObject(0, fLastCompletion, o);
|
||||||
|
end
|
||||||
|
else fLastCompletion:= '';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if fTextCompletion then
|
||||||
|
begin
|
||||||
|
r := TStringRange.create(lines.Text);
|
||||||
|
while not r.empty do
|
||||||
|
begin
|
||||||
|
s := r.popUntil(c)^.takeWhile(c).yield;
|
||||||
|
if (s.length > fTextCompletionMinLength) and fCompletion.ItemList.IndexOfName(s).equals(-1) then
|
||||||
|
fCompletion.ItemList.AddObject(s, TObject(PtrUint(dckText)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDexedMemo.completionCodeCompletion(var value: string;
|
procedure TDexedMemo.completionCodeCompletion(var value: string;
|
||||||
|
@ -2969,6 +2991,8 @@ begin
|
||||||
ACanvas.Font.Color:= clBlue;
|
ACanvas.Font.Color:= clBlue;
|
||||||
dckTemplate, dckMixin:
|
dckTemplate, dckMixin:
|
||||||
ACanvas.Font.Color:= clTeal;
|
ACanvas.Font.Color:= clTeal;
|
||||||
|
dckText:
|
||||||
|
ACanvas.Font.Color:= clLtGray;
|
||||||
end;
|
end;
|
||||||
ACanvas.Font.Style := [fsItalic];
|
ACanvas.Font.Style := [fsItalic];
|
||||||
ACanvas.TextOut(2 + X + len + 2, Y, knd);
|
ACanvas.TextOut(2 + X + len + 2, Y, knd);
|
||||||
|
|
Loading…
Reference in New Issue