completion menu, add special closing chars

This commit is contained in:
Basile Burg 2017-05-03 01:34:41 +02:00
parent 4a0827ddf7
commit 8dbce64dd0
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 39 additions and 4 deletions

View File

@ -118,6 +118,8 @@ The shortcuts are editable in the [shortcut editor](options_shortcuts_editor), u
- **autoDotDelay**: Sets, in milliseconds, how responsive is the completion menu after a `.`.
- **blockIndentation**: By default 4 for the D style.
- **bracketMatch**: Defines the visual style applied to matching brackets pairs.
- **closeCompletionChars**: Defines the characters that, in addition to close the completion menu, are inserted after the proposal.
- **closeCompletionCharsWithSapce**: Defines the characters that, in addition to close the completion menu, are inserted after the proposal and a space.
- **currentLine**: Defines the visual style applied to the current line.
- **ddocDelay**: Sets, in milliseconds, how responsive is the popup that displays the inline documentation.
- **detectIndentMode**: If checked the the indentation style (tabs or spaces) is detected when a document is opened. It's applied automatically when <kbd>TAB</kbd> is used.

View File

@ -65,6 +65,8 @@ type
fSmartDdocNewline: boolean;
fInsertPlusDdoc: boolean;
fAutoCallCompletion: boolean;
fCloseCompletionCharsWithSpace: AnsiString;
fCloseCompletionChars: AnsiString;
//
procedure setPhobosDocRoot(value: TCEPathname);
procedure setFont(value: TFont);
@ -91,6 +93,8 @@ type
property blockIndentation: Integer read fBlockIdent write fBlockIdent default 4;
property bracketMatch: TSynSelectedColor read fBracketMatchAttribs write setBracketMatchColor;
property characterSpacing: Integer read fCharSpacing write fCharSpacing default 0;
property closeCompletionCharsWithSpace: AnsiString read fCloseCompletionCharsWithSpace write fCloseCompletionCharsWithSpace;
property closeCompletionChars: AnsiString read fCloseCompletionChars write fCloseCompletionChars;
property completionMenuCaseCare: boolean read fCompletionMenuCaseCare write fCompletionMenuCaseCare;
property completionMenuLines: byte read fCompletionMenuLines write setCompletionMenuLines;
property completionMenuWidth: integer read fCompletionMenuWidth write fCompletionMenuWidth;
@ -240,6 +244,9 @@ begin
fCurrLineAttribs.Background := 15789545;
fCurrLineAttribs.Foreground := clNone;
//
fCloseCompletionCharsWithSpace := '*+-/^=~><';
fCloseCompletionChars:= ',;)}]!';
//
options1 :=
[eoAutoIndent, eoBracketHighlight, eoGroupUndo, eoTabsToSpaces, eoTrimTrailingSpaces,
eoDragDropEditing, eoShowCtrlMouseLinks, eoEnhanceHomeKey, eoTabIndent];
@ -310,6 +317,8 @@ begin
fPhobosDocRoot:=srcopt.fPhobosDocRoot;
fInsertPlusDdoc:= srcopt.fInsertPlusDdoc;
fAutoCallCompletion:= srcopt.fAutoCallCompletion;
fCloseCompletionChars:=srcopt.fCloseCompletionChars;
fCloseCompletionCharsWithSpace:=srcopt.fCloseCompletionCharsWithSpace;
fSmartDdocNewline:=srcopt.fSmartDdocNewline;
if fSmartDdocNewline then
@ -637,6 +646,8 @@ var
kst: TSynEditKeyStroke;
dup: boolean;
savedSize: integer;
cs: TSysCharSet;
c: char;
begin
anEditor.D2Highlighter.Assign(D2Syn);
anEditor.TxtHighlighter.Assign(TxtSyn);
@ -682,6 +693,17 @@ begin
anEditor.smartDdocNewline:= fSmartDdocNewline;
anEditor.insertPlusDdoc:= fInsertPlusDdoc;
anEditor.autoCallCompletion:= fAutoCallCompletion;
cs := [];
for c in fCloseCompletionCharsWithSpace do
include(cs, c);
anEditor.closeCompletionCharsWithSpace:=cs;
cs := [];
for c in fCloseCompletionChars do
include(cs, c);
anEditor.closeCompletionChars:=cs;
for i := 0 to anEditor.Keystrokes.Count-1 do
begin
kst := anEditor.Keystrokes.Items[i];

View File

@ -13,8 +13,7 @@ uses
//SynEditMarkupFoldColoring,
Clipbrd, fpjson, jsonparser, LazUTF8, LazUTF8Classes, Buttons, StdCtrls,
ce_common, ce_writableComponent, ce_d2syn, ce_txtsyn, ce_dialogs, ce_dastworx,
ce_sharedres, ce_dlang, ce_stringrange, ce_dbgitf, ce_observer, ce_diff,
ce_dlangutils;
ce_sharedres, ce_dlang, ce_stringrange, ce_dbgitf, ce_observer, ce_diff;
type
@ -184,6 +183,8 @@ type
fDebugger: ICEDebugger;
fInsertPlusDdoc: boolean;
fAutoCallCompletion: boolean;
fCloseCompletionCharsWithSpace: TSysCharSet;
fCloseCompletionChars: TSysCharSet;
procedure decCallTipsLvl;
procedure setMatchOpts(value: TIdentifierMatchOptions);
function getMouseBytePosition: Integer;
@ -311,6 +312,8 @@ type
property smartDdocNewline: boolean read fSmartDdocNewline write fSmartDdocNewline;
property insertPlusDdoc: boolean read fInsertPlusDdoc write fInsertPlusDdoc;
property autoCallCompletion: boolean read fAutoCallCompletion write fAutoCallCompletion;
property closeCompletionCharsWithSpace: TSysCharSet read fCloseCompletionCharsWithSpace write fCloseCompletionCharsWithSpace;
property closeCompletionChars: TSysCharSet read fCloseCompletionChars write fCloseCompletionChars;
end;
TSortDialog = class(TForm)
@ -2089,10 +2092,18 @@ procedure TCESynMemo.completionCodeCompletion(var value: string;
SourceValue: string; var SourceStart, SourceEnd: TPoint; KeyChar: TUTF8Char;
Shift: TShiftState);
begin
if (isOperator1(KeyChar[1])) or (KeyChar[1] = ' ') then
value := SourceValue + KeyChar
if (KeyChar[1] = ' ') then
begin
value := sourceValue + KeyChar;
end
else
begin
fLastCompletion := value;
if KeyChar[1] in fCloseCompletionCharsWithSpace then
value += ' ' + KeyChar
else if KeyChar[1] in fCloseCompletionChars then
value += KeyChar;
end;
end;
procedure TCESynMemo.completionFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);