Commit ee4e8f2c authored by Martin's avatar Martin
Browse files

CodeTemplate: allow tab to trigger / selection to ignore. issue #17631

git-svn-id: trunk@36527 -
parent 1718f669
......@@ -49,7 +49,9 @@ type
TAutoCompleteOption = (
acoLineBreak,
acoSpace,
acoTab,
acoWordEnd,
acoIgnoreForSelection,
acoRemoveChar
);
......@@ -57,7 +59,9 @@ const
AutoCompleteOptionNames: array[TAutoCompleteOption] of shortstring = (
'AutoOnLineBreak',
'AutoOnSpace',
'AutoOnTab',
'AutoOnWordEnd',
'IgnoreForSelection',
'RemoveChar' // do not add the typed character
);
......@@ -948,7 +952,9 @@ begin
AutoOnOptionsCheckGroup.Caption:=lisCodeTemplAutoCompleteOn;
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnLineBreak);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnSpace);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnTab);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyOnWordEnd);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyIgnoreForSelection);
AutoOnOptionsCheckGroup.Items.Add(lisAutomaticallyRemoveCharacter);
FilenameEdit.Text:=EditorOpts.CodeTemplateFileName;
......
......@@ -4606,7 +4606,9 @@ resourcestring
rsAddInverse = 'Add Inverse';
lisAutomaticallyOnLineBreak = 'line break';
lisAutomaticallyOnSpace = 'space';
lisAutomaticallyOnTab = 'tab';
lisAutomaticallyOnWordEnd = 'word end';
lisAutomaticallyIgnoreForSelection = 'Do not complete selection';
lisAutomaticallyRemoveCharacter = 'do not add character';
lisKeepSubIndentation = 'Keep indentation';
lisPckOptsThisPackageProvidesTheSameAsTheFollowingPackages = 'This package '
......
......@@ -2977,13 +2977,23 @@ begin
end;
end;
ecTab:
begin
AddChar:=true;
if AutoCompleteChar(aChar,AddChar,acoTab) then begin
// completed
end;
if not AddChar then Command:=ecNone;
end;
ecChar:
begin
AddChar:=true;
//debugln(['TSourceEditor.ProcessCommand AChar="',AChar,'" AutoIdentifierCompletion=',dbgs(EditorOpts.AutoIdentifierCompletion),' Interval=',SourceCompletionTimer.Interval,' ',Dbgs(FEditor.CaretXY),' ',FEditor.IsIdentChar(aChar)]);
if (aChar=' ') and AutoCompleteChar(aChar,AddChar,acoSpace) then begin
// completed
end else if (not FEditor.IsIdentChar(aChar))
end
else if (not FEditor.IsIdentChar(aChar))
and AutoCompleteChar(aChar,AddChar,acoWordEnd) then begin
// completed
end else if CodeToolsOpts.IdentComplAutoStartAfterPoint then begin
......@@ -3906,6 +3916,9 @@ begin
//DebugLn(['TSourceEditor.AutoCompleteChar ',AToken,' SrcToken=',SrcToken,' CatName=',CatName,' Index=',Manager.CodeTemplateModul.CompletionAttributes[i].IndexOfName(CatName)]);
if (AnsiCompareText(AToken,SrcToken)=0)
and (Manager.CodeTemplateModul.CompletionAttributes[i].IndexOfName(CatName)>=0)
and ( (not FEditor.SelAvail) or
(Manager.CodeTemplateModul.CompletionAttributes[i].IndexOfName(
AutoCompleteOptionNames[acoIgnoreForSelection]) < 0) )
then begin
Result:=true;
//DebugLn(['TSourceEditor.AutoCompleteChar ',AToken,' SrcToken=',SrcToken,' CatName=',CatName,' Index=',Manager.CodeTemplateModul.CompletionAttributes[i].IndexOfName(CatName)]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment