editor options, identifier match can be tweaked, whole word / case sens

This commit is contained in:
Basile Burg 2015-12-15 01:55:09 +01:00
parent d3f7196af6
commit bbdef1778f
2 changed files with 27 additions and 3 deletions

View File

@ -39,7 +39,7 @@ type
fIdentifierMarkup: TSynSelectedColor;
fFont: TFont;
//
fIdentiMatchOpts: TIdentifierMatchOptions;
fLineNumEvery: Integer;
fDDocDelay: Integer;
fAutoDotDelay: Integer;
@ -99,6 +99,7 @@ type
property highlighterGeneric: TPersistent read fTxtSyn write setTxtSyn;
property shortcuts: TCollection read fShortCuts write setShortcuts;
property lineNumberEvery: integer read fLineNumEvery write setLineNumEvery default 5;
property identifierMatchOptions: TIdentifierMatchOptions read fIdentiMatchOpts write fIdentiMatchOpts default [caseSensitive];
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -192,6 +193,7 @@ begin
fIdentifierMarkup.Foreground:= clNone;
fIdentifierMarkup.Background:= clSilver;
fIdentifierMarkup.BackAlpha:=70;
fIdentiMatchOpts := [caseSensitive];
//
fCompletionMenuWidth:= 160;
fCompletionMenuLines:= 15;
@ -267,6 +269,7 @@ begin
fTxtSyn.Assign(srcopt.fTxtSyn);
background := srcopt.background;
lineNumberEvery := srcopt.lineNumberEvery;
identifierMatchOptions:=srcopt.identifierMatchOptions;
tabulationWidth := srcopt.tabulationWidth;
blockIdentation := srcopt.blockIdentation;
@ -610,6 +613,7 @@ begin
anEditor.Color := background;
anEditor.RightEdge := rightEdge;
anEditor.RightEdgeColor := rightEdgeColor;
anEditor.IdentifierMatchOptions:= identifierMatchOptions;
for i := 0 to anEditor.Keystrokes.Count-1 do
begin
kst := anEditor.Keystrokes.Items[i];

View File

@ -16,6 +16,13 @@ type
TCESynMemo = class;
TIdentifierMatchOption = (
caseSensitive = longInt(ssoMatchCase),
wholeWord = longInt(ssoWholeWord)
);
TIdentifierMatchOptions = set of TIdentifierMatchOption;
TBreakPointModification = (bpAdded, bpRemoved);
// breakpoint added or removed
@ -118,6 +125,10 @@ type
fImages: TImageList;
fBreakPoints: TFPList;
fBreakpointEvent: TBreakPointModifyEvent;
fMatchSelectionOpts: TSynSearchOptions;
fMatchIdentOpts: TSynSearchOptions;
fMatchOpts: TIdentifierMatchOptions;
procedure setMatchOpts(value: TIdentifierMatchOptions);
function getMouseFileBytePos: Integer;
procedure changeNotify(Sender: TObject);
procedure highlightCurrentIdentifier;
@ -175,6 +186,7 @@ type
function breakPointLine(index: integer): integer;
property onBreakpointModify: TBreakPointModifyEvent read fBreakpointEvent write fBreakpointEvent;
//
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
property Identifier: string read fIdentifier;
property fileName: string read fFilename;
property modified: boolean read fModified;
@ -499,6 +511,7 @@ begin
HighlightAllColor.Foreground := clNone;
HighlightAllColor.Background := clSilver;
HighlightAllColor.BackAlpha := 70;
IdentifierMatchOptions:= [caseSensitive];
//
LineHighlightColor.Background := color - $080808;
LineHighlightColor.Foreground := clNone;
@ -846,9 +859,16 @@ procedure TCESynMemo.highlightCurrentIdentifier;
begin
fIdentifier := GetWordAtRowCol(LogicalCaretXY);
if (length(fIdentifier) > 2) and (not SelAvail) then
SetHighlightSearch(fIdentifier,[ssoMatchCase])
SetHighlightSearch(fIdentifier, fMatchIdentOpts)
else if SelAvail then
SetHighlightSearch(SelText,[ssoMatchCase]);
SetHighlightSearch(SelText,fMatchSelectionOpts);
end;
procedure TCESynMemo.setMatchOpts(value: TIdentifierMatchOptions);
begin
fMatchOpts:= value;
fMatchIdentOpts := TSynSearchOptions(fMatchOpts);
fMatchSelectionOpts:= TSynSearchOptions(fMatchOpts - [wholeWord]);
end;
procedure TCESynMemo.changeNotify(Sender: TObject);