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

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