synedit: markup for special line, selection and ctrl mouse link, from Martin Friebe, bug #11693

git-svn-id: trunk@15861 -
This commit is contained in:
mattias 2008-07-24 22:41:25 +00:00
parent 7e7711b535
commit 2e9d466c2d
21 changed files with 2250 additions and 1507 deletions

3
.gitattributes vendored
View File

@ -1041,7 +1041,10 @@ components/synedit/syneditlazdsgn.lrs svneol=native#text/pascal
components/synedit/syneditlazdsgn.pas svneol=native#text/pascal
components/synedit/syneditmarkup.pp svneol=native#text/plain
components/synedit/syneditmarkupbracket.pp svneol=native#text/plain
components/synedit/syneditmarkupctrlmouselink.pp svneol=native#text/plain
components/synedit/syneditmarkuphighall.pp svneol=native#text/plain
components/synedit/syneditmarkupselection.pp svneol=native#text/plain
components/synedit/syneditmarkupspecialline.pp svneol=native#text/plain
components/synedit/syneditmiscclasses.pp svneol=native#text/pascal
components/synedit/syneditmiscprocs.pp svneol=native#text/pascal
components/synedit/syneditplugins.pas svneol=native#text/pascal

File diff suppressed because it is too large Load Diff

View File

@ -62,6 +62,8 @@ type
{$ENDIF}
end;
{ TSynHighlighterAttributes }
TSynHighlighterAttributes = class(TPersistent)
private
fBackground: TColor;
@ -71,18 +73,28 @@ type
fName: string;
fStyle: TFontStyles;
fStyleDefault: TFontStyles; //mh 2000-10-08
{$IFDEF SYN_LAZARUS}
fStyleMask: TFontStyles;
fStyleMaskDefault: TFontStyles; //mh 2000-10-08
{$ENDIF}
fOnChange: TNotifyEvent;
procedure Changed; virtual;
{begin} //mh 2000-10-08
function GetBackgroundColorStored: boolean;
function GetFontStyleMaskStored : boolean;
function GetForegroundColorStored: boolean;
function GetFontStyleStored: boolean;
{end} //mh 2000-10-08
procedure SetBackground(Value: TColor);
procedure SetForeground(Value: TColor);
procedure SetStyle(Value: TFontStyles);
function GetStyleFromInt: integer;
procedure SetStyleFromInt(const Value: integer);
function GetFontStyleStored: boolean;
{$IFDEF SYN_LAZARUS}
procedure SetStyleMask(const AValue : TFontStyles);
function GetStyleMaskFromInt : integer;
procedure SetStyleMaskFromInt(const Value : integer);
{$ENDIF}
public
procedure Assign(Source: TPersistent); override;
constructor Create(attribName: string);
@ -95,6 +107,9 @@ type
function SaveToFile(Ini : TIniFile): boolean; //DDH 10/16/01
public
property IntegerStyle: integer read GetStyleFromInt write SetStyleFromInt;
{$IFDEF SYN_LAZARUS}
property IntegerStyleMask: integer read GetStyleMaskFromInt write SetStyleMaskFromInt;
{$ENDIF}
property Name: string read fName;
property OnChange: TNotifyEvent read fOnChange write fOnChange;
published
@ -104,6 +119,10 @@ type
stored GetForegroundColorStored; //mh 2000-10-08
property Style: TFontStyles read fStyle write SetStyle //default [];
stored GetFontStyleStored; //mh 2000-10-08
{$IFDEF SYN_LAZARUS}
property StyleMask: TFontStyles read fStyleMask write SetStyleMask //default [];
stored GetFontStyleMaskStored; //mh 2000-10-08
{$ENDIF}
end;
TSynHighlighterCapability = (
@ -506,6 +525,12 @@ begin
fStyle := src.fStyle;
bChanged := TRUE;
end;
{$IFDEF SYN_LAZARUS}
if fStyleMask <> src.fStyleMask then begin
fStyleMask := src.fStyleMask;
bChanged := TRUE;
end;
{$ENDIF}
if bChanged then
Changed;
end else
@ -531,6 +556,11 @@ begin
Result := fBackground <> fBackgroundDefault;
end;
function TSynHighlighterAttributes.GetFontStyleMaskStored : boolean;
begin
Result := fStyleMask <> fStyleMaskDefault;
end;
function TSynHighlighterAttributes.GetForegroundColorStored: boolean;
begin
Result := fForeground <> fForegroundDefault;
@ -546,6 +576,9 @@ begin
fForegroundDefault := fForeground;
fBackgroundDefault := fBackground;
fStyleDefault := fStyle;
{$IFDEF SYN_LAZARUS}
fStyleMaskDefault := fStyleMask;
{$ENDIF}
end;
function TSynHighlighterAttributes.LoadFromBorlandRegistry(rootKey: HKEY;
@ -780,6 +813,9 @@ begin
Reg.WriteInteger('Background', Background);
Reg.WriteInteger('Foreground', Foreground);
Reg.WriteInteger('Style', IntegerStyle);
{$IFDEF SYN_LAZARUS}
Reg.WriteInteger('StyleMask', IntegerStyleMask);
{$ENDIF}
reg.OpenKey('\' + key, false);
Result := true;
end else
@ -801,6 +837,10 @@ begin
Foreground := Ini.ReadInteger(Name, 'Foreground', clWindowText);
if S.IndexOf('Style') <> -1 then
IntegerStyle := Ini.ReadInteger(Name, 'Style', 0);
{$IFDEF SYN_LAZARUS}
if S.IndexOf('StyleMask') <> -1 then
IntegerStyleMask := Ini.ReadInteger(Name, 'StyleMask', 0);
{$ENDIF}
Result := true;
end else Result := false;
finally
@ -813,6 +853,9 @@ begin
Ini.WriteInteger(Name, 'Background', Background);
Ini.WriteInteger(Name, 'Foreground', Foreground);
Ini.WriteInteger(Name, 'Style', IntegerStyle);
{$IFDEF SYN_LAZARUS}
Ini.WriteInteger(Name, 'StyleMask', IntegerStyleMask);
{$ENDIF}
Result := true;
end;
@ -832,6 +875,32 @@ begin
if Value and $8 <> 0 then Style:= Style + [fsStrikeout];
end;
{$IFDEF SYN_LAZARUS}
procedure TSynHighlighterAttributes.SetStyleMask(const AValue : TFontStyles);
begin
if fStyleMask <> AValue then begin
fStyleMask := AValue;
Changed;
end;
end;
function TSynHighlighterAttributes.GetStyleMaskFromInt : integer;
begin
if fsBold in StyleMask then Result:= 1 else Result:= 0;
if fsItalic in StyleMask then Result:= Result + 2;
if fsUnderline in StyleMask then Result:= Result + 4;
if fsStrikeout in StyleMask then Result:= Result + 8;
end;
procedure TSynHighlighterAttributes.SetStyleMaskFromInt(const Value : integer);
begin
if Value and $1 = 0 then StyleMask:= [] else StyleMask:= [fsBold];
if Value and $2 <> 0 then StyleMask:= StyleMask + [fsItalic];
if Value and $4 <> 0 then StyleMask:= StyleMask + [fsUnderline];
if Value and $8 <> 0 then StyleMask:= StyleMask + [fsStrikeout];
end;
{$ENDIF}
{ TSynCustomHighlighter }
constructor TSynCustomHighlighter.Create(AOwner: TComponent);

View File

@ -26,7 +26,7 @@ unit SynEditMarkup;
interface
uses
Classes, SysUtils, Graphics, SynEditTextBuffer, SynEditMiscClasses, Controls;
Classes, SysUtils, Graphics, SynEditTextBuffer, SynEditMiscClasses, Controls, SynEditHighlighter;
type
@ -51,6 +51,7 @@ type
procedure SetFGColor(const AValue : TColor);
procedure SetStyle(const AValue : TFontStyles);
procedure MarkupChanged(AMarkup: TObject);
protected
procedure SetInvalidateLinesMethod(const AValue : TInvalidateLines); virtual;
procedure SetLines(const AValue : TSynEditStringList); virtual;
@ -61,21 +62,28 @@ type
procedure DoCaretChanged(OldCaret : TPoint); virtual;
procedure DoTopLineChanged(OldTopLine : Integer); virtual;
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); virtual;
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); virtual;
procedure InvalidateSynLines(FirstLine, LastLine: integer); // Call Synedt to invalidate lines
function ScreenRowToRow(aRow : Integer) : Integer;
function RowToScreenRow(aRow : Integer) : Integer;
function LogicalToPhysicalPos(const p: TPoint): TPoint;
function Highlighter: TSynCustomHighlighter;
property SynEdit : TCustomControl read fSynEdit;
public
constructor Create(ASynEdit : TCustomControl);
destructor Destroy; override;
Function GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor; virtual; abstract;
Function GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer; virtual; abstract;
Procedure PrepareMarkupForRow(aRow : Integer); virtual;
Procedure FinishMarkupForRow(aRow : Integer); virtual;
Procedure EndMarkup; virtual;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; virtual; abstract;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; virtual; abstract;
property MarkupInfo : TSynSelectedColor read fMarkupInfo;
property FGColor : TColor read GetFGColor write SetFGColor;
property BGColor : TColor read GetBGColor write SetBGColor;
property Style : TFontStyles read GetStyle write SetStyle;
property FGColor : TColor read GetFGColor;
property BGColor : TColor read GetBGColor;
property Style : TFontStyles read GetStyle;
property Lines : TSynEditStringList read fLines write SetLines;
property Caret : TPoint read fCaret write SetCaret;
property TopLine : Integer read fTopLine write SetTopLine;
@ -101,14 +109,17 @@ type
Procedure AddMarkUp(aMarkUp : TSynEditMarkup);
Function GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer; override;
Procedure PrepareMarkupForRow(aRow : Integer); override;
Procedure FinishMarkupForRow(aRow : Integer); override;
Procedure EndMarkup; override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
end;
implementation
uses SynEdit;
uses SynEdit, SynEditMiscProcs;
{ TSynEditMarkup }
@ -141,8 +152,13 @@ end;
procedure TSynEditMarkup.SetStyle(const AValue : TFontStyles);
begin
// if fMarkupInfo.Style = AValue then exit;
// fMarkupInfo.Style := AValue;
if fMarkupInfo.Style = AValue then exit;
fMarkupInfo.Style := AValue;
end;
procedure TSynEditMarkup.MarkupChanged(AMarkup : TObject);
begin
DoMarkupChanged(AMarkup as TSynSelectedColor);
end;
procedure TSynEditMarkup.SetLines(const AValue : TSynEditStringList);
@ -199,6 +215,10 @@ procedure TSynEditMarkup.DoLinesInWindoChanged(OldLinesInWindow : Integer);
begin
end;
procedure TSynEditMarkup.DoMarkupChanged(AMarkup : TSynSelectedColor);
begin
end;
procedure TSynEditMarkup.InvalidateSynLines(FirstLine, LastLine : integer);
begin
if assigned(fInvalidateLinesMethod)
@ -215,12 +235,22 @@ begin
Result := TSynEdit(SynEdit).RowToScreenRow(aRow);
end;
function TSynEditMarkup.LogicalToPhysicalPos(const p : TPoint) : TPoint;
begin
Result := TSynEdit(SynEdit).LogicalToPhysicalPos(p);
end;
function TSynEditMarkup.Highlighter : TSynCustomHighlighter;
begin
Result := TSynEdit(SynEdit).Highlighter;
end;
constructor TSynEditMarkup.Create(ASynEdit : TCustomControl);
begin
inherited Create();
fSynEdit := ASynEdit;
fMarkupInfo := TSynSelectedColor.Create;
{ TODO: OnChange handler }
fMarkupInfo.OnChange := @MarkupChanged;
end;
destructor TSynEditMarkup.Destroy;
@ -229,6 +259,18 @@ begin
inherited Destroy;
end;
procedure TSynEditMarkup.FinishMarkupForRow(aRow : Integer);
begin
end;
procedure TSynEditMarkup.EndMarkup;
begin
end;
procedure TSynEditMarkup.PrepareMarkupForRow(aRow : Integer);
begin
end;
{ TSynEditMarkupManager }
constructor TSynEditMarkupManager.Create(ASynEdit : TCustomControl);
@ -252,10 +294,35 @@ begin
fMarkUpList.Add(aMarkUp);
end;
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor;
procedure TSynEditMarkupManager.FinishMarkupForRow(aRow : Integer);
var
i : integer;
begin
for i := 0 to fMarkUpList.Count-1 do
TSynEditMarkup(fMarkUpList[i]).FinishMarkupForRow(aRow);
end;
procedure TSynEditMarkupManager.EndMarkup;
var
i : integer;
begin
for i := 0 to fMarkUpList.Count-1 do
TSynEditMarkup(fMarkUpList[i]).EndMarkup;
end;
procedure TSynEditMarkupManager.PrepareMarkupForRow(aRow : Integer);
var
i : integer;
begin
for i := 0 to fMarkUpList.Count-1 do
TSynEditMarkup(fMarkUpList[i]).PrepareMarkupForRow(aRow);
end;
function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
var
i : integer;
c : TSynSelectedColor;
sMask : TFontStyles;
begin
Result := nil;
@ -268,14 +335,15 @@ begin
end else begin
if c.Background <> clNone then Result.Background := c.Background;
if c.Foreground <> clNone then Result.Foreground := c.Foreground;
Result.Style:= Result.Style + c.Style;
Result.StyleMask:= Result.StyleMask + c.StyleMask;
sMask := c.StyleMask + (fsNot(c.StyleMask) * c.Style); // Styles to be taken from c
Result.Style:= (Result.Style * fsNot(sMask)) + (c.Style * sMask);
Result.StyleMask:= (Result.StyleMask * fsNot(sMask)) + (c.StyleMask * sMask);
end;
end;
end;
end;
function TSynEditMarkupManager.GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer;
function TSynEditMarkupManager.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
var
i, j : integer;
begin

View File

@ -34,13 +34,17 @@ type
TSynEditMarkupBracket = class(TSynEditMarkup)
private
// Physical Position
fBracketHighlightPos: TPoint;
fBracketHighlightAntiPos: TPoint;
protected
procedure FindMatchingBracketPair(const PhysCaret: TPoint;
var StartBracket, EndBracket: TPoint);
public
constructor Create(ASynEdit : TCustomControl);
Function GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer; override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
procedure InvalidateBracketHighlight;
end;
@ -51,7 +55,6 @@ uses SynEdit;
{ TSynEditMarkupBracket }
constructor TSynEditMarkupBracket.Create(ASynEdit : TCustomControl);
begin
inherited Create(ASynEdit);
@ -63,6 +66,23 @@ begin
MarkupInfo.StyleMask := [];
end;
procedure TSynEditMarkupBracket.FindMatchingBracketPair(const PhysCaret : TPoint;
var StartBracket, EndBracket : TPoint);
var
StartLine: string;
LogCaretXY: TPoint;
begin
StartBracket.Y:=-1;
EndBracket.Y:=-1;
if (PhysCaret.Y<1) or (PhysCaret.Y>Lines.Count) or (PhysCaret.X<1) then exit;
StartLine := Lines[PhysCaret.Y - 1];
LogCaretXY:=TSynEdit(SynEdit).PhysicalToLogicalPos(PhysCaret);
if (length(StartLine)<LogCaretXY.X)
or (not (StartLine[LogCaretXY.X] in ['(',')','{','}','[',']'])) then exit;
StartBracket:=PhysCaret;
EndBracket:=TSynEdit(SynEdit).FindMatchingBracket(PhysCaret,false,false,false,false);
end;
procedure TSynEditMarkupBracket.InvalidateBracketHighlight;
var
NewPos, NewAntiPos, SwapPos : TPoint;
@ -70,7 +90,7 @@ begin
NewPos.Y:=-1;
NewAntiPos.Y:=-1;
if eoBracketHighlight in TSynEdit(SynEdit).Options
then TSynEdit(SynEdit).FindMatchingBracketPair(TSynEdit(SynEdit).CaretXY, NewPos, NewAntiPos, false);
then FindMatchingBracketPair(TSynEdit(SynEdit).CaretXY, NewPos, NewAntiPos);
// Always keep ordered
if (NewAntiPos.Y > 0)
@ -109,11 +129,12 @@ begin
end;
fBracketHighlightPos := NewPos;
fBracketHighlightAntiPos := NewAntiPos;
// DebugLn('TCustomSynEdit.InvalidateBracketHighlight C P=',dbgs(NewPos),' A=',dbgs(NewAntiPos), ' LP=',dbgs(fLogicalPos),' LA',dbgs(fLogicalAntiPos));
end;
function TSynEditMarkupBracket.GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor;
function TSynEditMarkupBracket.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
begin
Result := nil;
if ((fBracketHighlightPos.y = aRow) and (fBracketHighlightPos.x = aCol))
@ -121,7 +142,7 @@ begin
then Result := MarkupInfo;
end;
function TSynEditMarkupBracket.GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer;
function TSynEditMarkupBracket.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
begin
Result := -1;
if (fBracketHighlightPos.y = aRow) then begin

View File

@ -0,0 +1,85 @@
unit SynEditMarkupCtrlMouseLink;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls, LCLProc;
type
{ TSynEditMarkupCtrlMouseLink }
TSynEditMarkupCtrlMouseLink = class(TSynEditMarkup)
private
FCtrlMouseLine : Integer;
FCtrlMouseX1 : Integer;
FCtrlMouseX2 : Integer;
public
constructor Create(ASynEdit : TCustomControl);
Procedure EndMarkup; override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
property CtrlMouseLine : Integer read FCtrlMouseLine write FCtrlMouseLine;
property CtrlMouseX1 : Integer read FCtrlMouseX1 write FCtrlMouseX1;
property CtrlMouseX2 : Integer read FCtrlMouseX2 write FCtrlMouseX2;
end;
implementation
uses SynEdit; //, SynEditTypes;
{ TSynEditMarkupCtrlMouseLink }
constructor TSynEditMarkupCtrlMouseLink.Create(ASynEdit : TCustomControl);
begin
inherited Create(ASynEdit);
FCtrlMouseLine:=-1;
MarkupInfo.Style := [];
MarkupInfo.StyleMask := [];
MarkupInfo.Foreground := clBlue; {TODO: invert blue to bg .... see below}
MarkupInfo.Background := clNone;
end;
procedure TSynEditMarkupCtrlMouseLink.EndMarkup;
var
LineLeft, LineTop, LineRight: integer;
temp : TPoint;
begin
if FCtrlMouseLine < 1 then exit;
LineTop := (RowToScreenRow(FCtrlMouseLine)+1)*TSynEdit(SynEdit).LineHeight-1;
Temp := LogicalToPhysicalPos(Point(FCtrlMouseX1, FCtrlMouseLine));
LineLeft := TSynEdit(SynEdit).ScreenColumnToXValue(Temp.x);
Temp := LogicalToPhysicalPos(Point(FCtrlMouseX2, FCtrlMouseLine));
LineRight := TSynEdit(SynEdit).ScreenColumnToXValue(Temp.x);
with TSynEdit(SynEdit).Canvas do begin
Pen.Color := MarkupInfo.Foreground;
MoveTo(LineLeft,LineTop);
LineTo(LineRight,LineTop);
end;
end;
function TSynEditMarkupCtrlMouseLink.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
begin
Result := nil;
if (aRow <> FCtrlMouseLine) or ((aCol < FCtrlMouseX1) or (aCol >= FCtrlMouseX2))
then exit;
Result := MarkupInfo;
end;
function TSynEditMarkupCtrlMouseLink.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
begin
Result := -1;
if FCtrlMouseLine <> aRow
then exit;
if aCol < FCtrlMouseX1
then Result := FCtrlMouseX1;
if (aCol < FCtrlMouseX2) and (aCol >= FCtrlMouseX1)
then Result := FCtrlMouseX2;
end;
end.

View File

@ -108,12 +108,13 @@ type
protected
procedure DoTopLineChanged(OldTopLine : Integer); override;
procedure DoLinesInWindoChanged(OldLinesInWindow : Integer); override;
procedure DoMarkupChanged(AMarkup: TSynSelectedColor); override;
public
constructor Create(ASynEdit : TCustomControl);
destructor Destroy; override;
Function GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer; override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
Procedure InvalidateScreenLines(aFirstCodeLine, aLastCodeLine: Integer);
Procedure InvalidateLines(aFirstCodeLine, aLastCodeLine: Integer);
@ -304,6 +305,12 @@ begin
ValidateMatches;
end;
procedure TSynEditMarkupHighlightAll.DoMarkupChanged(AMarkup : TSynSelectedColor);
begin
Invalidate; {TODO: only redraw, no search}
ValidateMatches;
end;
procedure TSynEditMarkupHighlightAll.FindInitialize(Backward : Boolean);
begin
fSearch.Pattern := fSearchString;
@ -363,8 +370,8 @@ begin
ptStart := ptFoundEnd;
{ TODO: skip if all folded }
fMatches.StartPoint[Pos] := ptFoundStart;
fMatches.EndPoint[Pos]:= ptFoundEnd;
fMatches.StartPoint[Pos] := LogicalToPhysicalPos(ptFoundStart);
fMatches.EndPoint[Pos]:= LogicalToPhysicalPos(ptFoundEnd);
inc(Pos);
end;
@ -431,7 +438,7 @@ begin
fInvalidating := False;
end;
function TSynEditMarkupHighlightAll.GetMarkupAttributeAtRowCol(aRow, aCol : Integer) : TSynSelectedColor;
function TSynEditMarkupHighlightAll.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
var
Pos: Integer;
begin
@ -456,7 +463,7 @@ begin
result := MarkupInfo;
end;
function TSynEditMarkupHighlightAll.GetNextMarkupColAfterRowCol(aRow, aCol : Integer) : Integer;
function TSynEditMarkupHighlightAll.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
var
Pos: Integer;
begin

View File

@ -0,0 +1,127 @@
unit SynEditMarkupSelection;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls, LCLProc;
type
{ TSynEditMarkupSelection }
TSynEditMarkupSelection = class(TSynEditMarkup)
private
FMarkupInfoIncr: TSynSelectedColor; // Markup during incremental search
FMarkupInfoSelection: TSynSelectedColor; // Markup for normal Selection
FUseIncrementalColor : Boolean;
nSelStart, nSelEnd: integer; // start, end of selected area in current line (physical)
procedure SetUseIncrementalColor(const AValue : Boolean);
procedure MarkupChangedIntern(AMarkup: TObject);
public
constructor Create(ASynEdit : TCustomControl);
destructor Destroy; override;
Procedure PrepareMarkupForRow(aRow : Integer); override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
property UseIncrementalColor : Boolean read FUseIncrementalColor write SetUseIncrementalColor;
property MarkupInfoSeletion : TSynSelectedColor read FMarkupInfoSelection;
property MarkupInfoIncr : TSynSelectedColor read FMarkupInfoIncr;
end;
implementation
uses SynEdit, SynEditTypes;
{ TSynEditMarkupSelection }
procedure TSynEditMarkupSelection.SetUseIncrementalColor(const AValue : Boolean);
begin
if FUseIncrementalColor=AValue then exit;
FUseIncrementalColor:=AValue;
if FUseIncrementalColor
then MarkupInfo.Assign(FMarkupInfoIncr)
else MarkupInfo.Assign(FMarkupInfoSelection);
end;
procedure TSynEditMarkupSelection.MarkupChangedIntern(AMarkup : TObject);
begin
if FUseIncrementalColor
then MarkupInfo.Assign(FMarkupInfoIncr)
else MarkupInfo.Assign(FMarkupInfoSelection);
end;
constructor TSynEditMarkupSelection.Create(ASynEdit : TCustomControl);
begin
inherited Create(ASynEdit);
FMarkupInfoSelection := TSynSelectedColor.Create;
FMarkupInfoSelection.OnChange := @MarkupChangedIntern;
FMarkupInfoIncr := TSynSelectedColor.Create;
FMarkupInfoIncr.OnChange := @MarkupChangedIntern;
MarkupInfo.Style := [];
MarkupInfo.StyleMask := [];
end;
destructor TSynEditMarkupSelection.Destroy;
begin
inherited Destroy;
FreeAndNil(FMarkupInfoIncr);
FreeAndNil(FMarkupInfoSelection);
end;
procedure TSynEditMarkupSelection.PrepareMarkupForRow(aRow : Integer);
var
p1, p2 : TPoint;
begin
nSelStart := 0;
nSelEnd := 0;
if (not TSynEdit(SynEdit).HideSelection or TSynEdit(SynEdit).Focused) then begin
p1 := TSynEdit(SynEdit).BlockBegin; // always ordered
p2 := TSynEdit(SynEdit).BlockEnd;
if (p1.y > aRow) or (p2.y < aRow)
then exit;
p1 := LogicalToPhysicalPos(p1);
p2 := LogicalToPhysicalPos(p2);
nSelStart := 1;
nSelEnd := -1; // line end
if (TSynEdit(SynEdit).SelectionMode = smColumn) then begin
if (p1.X < p2.X) then begin
nSelStart := p1.X;
nSelEnd := p2.X;
end else begin
nSelStart := p2.X;
nSelEnd := p1.X;
end;
end else if (TSynEdit(SynEdit).SelectionMode = smNormal) then begin
if p1.y = aRow
then nSelStart := p1.x;
if p2.y = aRow
then nSelEnd := p2.x;
end;
end;
end;
function TSynEditMarkupSelection.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
begin
result := nil;
if (aCol >= nSelStart) and ((aCol < nSelEnd) or (nSelEnd < 0))
then Result := MarkupInfo;
end;
function TSynEditMarkupSelection.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
begin
result := -1;
if (aCol < nSelStart)
then Result := nSelStart;
if (aCol < nSelEnd) and (aCol >= nSelStart)
then result := nSelEnd;
end;
end.

View File

@ -0,0 +1,84 @@
unit SynEditMarkupSpecialLine;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls, LCLProc;
type
TSpecialLineMarkupEvent = procedure(Sender: TObject; Line: integer;
var Special: boolean; Markup: TSynSelectedColor) of object;
TSpecialLineColorsEvent = procedure(Sender: TObject; Line: integer;
var Special: boolean; var FG, BG: TColor) of object;
{ TSynEditMarkupSpecialLine }
TSynEditMarkupSpecialLine = class(TSynEditMarkup)
private
fOnSpecialLineColors : TSpecialLineColorsEvent;
fOnSpecialLineMarkup : TSpecialLineMarkupEvent;
bSpecialLine : Boolean;
public
constructor Create(ASynEdit : TCustomControl);
Procedure PrepareMarkupForRow(aRow : Integer); override;
Function GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor; override;
Function GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer; override;
property OnSpecialLineColors: TSpecialLineColorsEvent
read fOnSpecialLineColors write fOnSpecialLineColors; deprecated; // use SpecialMarkup instead
property OnSpecialLineMarkup: TSpecialLineMarkupEvent
read fOnSpecialLineMarkup write fOnSpecialLineMarkup;
end;
implementation
uses SynEdit;
{ TSynEditMarkupBracket }
constructor TSynEditMarkupSpecialLine.Create(ASynEdit : TCustomControl);
begin
inherited Create(ASynEdit);
MarkupInfo.Style := [];
MarkupInfo.StyleMask := [];
end;
procedure TSynEditMarkupSpecialLine.PrepareMarkupForRow(aRow : Integer);
var
colFg, colBg : TColor;
begin
bSpecialLine := False;
if Assigned(fOnSpecialLineMarkup) then
fOnSpecialLineMarkup(SynEdit, aRow, bSpecialLine, MarkupInfo);
if Assigned(fOnSpecialLineColors) then begin
If bSpecialLine then begin
colFg := MarkupInfo.Foreground;
colBg := MarkupInfo.Background;
end else begin
colFg := clNone;
colBg := clNone;
end;
fOnSpecialLineColors(SynEdit, aRow, bSpecialLine, colFg, colBg);
MarkupInfo.Foreground := colFg;
MarkupInfo.Background := colBg;
end;
end;
function TSynEditMarkupSpecialLine.GetMarkupAttributeAtRowCol(const aRow, aCol : Integer) : TSynSelectedColor;
begin
Result := nil;
if bSpecialLine then result := MarkupInfo;
end;
function TSynEditMarkupSpecialLine.GetNextMarkupColAfterRowCol(const aRow, aCol : Integer) : Integer;
begin
result := -1; // always valid for the whole line
end;
end.

View File

@ -57,23 +57,33 @@ type
private
fBG: TColor;
fFG: TColor;
fStyle: TFontStyles;
{$IFDEF SYN_LAZARUS}
// StyleMask = 1 => Copy Style Bits
// StyleMask = 0 => Invert where Style Bit = 1
fStyle, fStyleMask: TFontStyles;
fStyleMask: TFontStyles;
{$ENDIF}
fOnChange: TNotifyEvent;
procedure SetBG(Value: TColor);
procedure SetFG(Value: TColor);
procedure SetStyle(const AValue : TFontStyles);
{$IFDEF SYN_LAZARUS}
procedure SetStyleMask(const AValue : TFontStyles);
{$ENDIF}
public
constructor Create;
procedure Assign(aSource: TPersistent); override;
published
{$IFDEF SYN_LAZARUS}
function GetModifiedStyle(aStyle : TFontStyles): TFontStyles;
procedure ModifyColors(var aForeground, aBackground: TColor; var aStyle: TFontStyles);
{$ENDIF}
property Background: TColor read fBG write SetBG default clHighLight;
property Foreground: TColor read fFG write SetFG default clHighLightText;
property Style: TFontStyles read fStyle write SetStyle default [];
{$IFDEF SYN_LAZARUS}
property StyleMask: TFontStyles read fStyleMask write SetStyleMask default [];
{$ENDIF}
property OnChange: TNotifyEvent read fOnChange write fOnChange;
end;
@ -271,21 +281,22 @@ begin
fFG := clHighLightText;
end;
{$IFDEF SYN_LAZARUS}
function TSynSelectedColor.GetModifiedStyle(aStyle : TFontStyles) : TFontStyles;
function fsNot (s : TFontStyles) : TFontStyles; inline;
begin
Result := [low(TFontStyle)..High(TFontStyle)] - s;
end;
function fsXor (s1,s2 : TFontStyles) : TFontStyles; inline;
begin
Result := s1 + s2 - (s1*s2);
end;
begin
Result := fsXor(aStyle, fStyle * fsNot(fStyleMask)) // Invert Styles
+ (fStyle*fStyleMask) // Set Styles
- (fsNot(fStyle)*fStyleMask); // Remove Styles
end;
procedure TSynSelectedColor.ModifyColors(var aForeground, aBackground : TColor; var aStyle : TFontStyles);
begin
if Foreground <> clNone then aForeground := Foreground;
if Background <> clNone then aBackground := Background;
aStyle := GetModifiedStyle(aStyle);
end;
{$ENDIF}
procedure TSynSelectedColor.SetBG(Value: TColor);
begin
if (fBG <> Value) then begin
@ -310,6 +321,7 @@ begin
end;
end;
{$IFDEF SYN_LAZARUS}
procedure TSynSelectedColor.SetStyleMask(const AValue : TFontStyles);
begin
if (fStyleMask <> AValue) then begin
@ -317,6 +329,7 @@ begin
if Assigned(fOnChange) then fOnChange(Self);
end;
end;
{$ENDIF}
procedure TSynSelectedColor.Assign(aSource : TPersistent);
var
@ -328,6 +341,7 @@ begin
fFG := Source.fFG;
fStyle := Source.fStyle;
fStyleMask := Source.fStyleMask;
if Assigned(fOnChange) then fOnChange(Self); {TODO: only if really changed}
end;
end;

View File

@ -47,7 +47,7 @@ uses
{$ELSE}
Windows,
{$ENDIF}
Classes, SynEditTypes;
Classes, SynEditTypes, Graphics;
type
PIntArray = ^TIntArray;
@ -124,11 +124,25 @@ function CompareCarets(const FirstCaret, SecondCaret: TPoint): integer;
function DecodeString(s: string): string;
{end} //gp 2000-06-24
function fsNot (s : TFontStyles) : TFontStyles; inline;
function fsXor (s1,s2 : TFontStyles) : TFontStyles; inline;
implementation
uses
SysUtils;
{* fontstyle utilities *}
function fsNot (s : TFontStyles) : TFontStyles; inline;
begin
Result := [low(TFontStyle)..High(TFontStyle)] - s;
end;
function fsXor (s1,s2 : TFontStyles) : TFontStyles; inline;
begin
Result := s1 + s2 - (s1*s2);
end;
{***}
{$IFDEF FPC}

View File

@ -65,154 +65,154 @@ const
('&lt;'), { > }
('&gt;'), { < }
('&quot;'), { " }
('&trade;'), { }
('&trade;'), { ™ }
('&nbsp;'), { space }
('&copy;'), { © }
('&reg;'), { ® }
('&Agrave;'), { À }
('&Aacute;'), { Á }
('&Acirc;'), { Â }
('&Atilde;'), { Ã }
('&Auml;'), { Ä }
('&Aring;'), { Å }
('&AElig;'), { Æ }
('&Ccedil;'), { Ç }
('&Egrave;'), { È }
('&Eacute;'), { É }
('&Ecirc;'), { Ê }
('&Euml;'), { Ë }
('&Igrave;'), { Ì }
('&Iacute;'), { Í }
('&Icirc;'), { Î }
('&Iuml;'), { Ï }
('&ETH;'), { Ð }
('&Ntilde;'), { Ñ }
('&Ograve;'), { Ò }
('&Oacute;'), { Ó }
('&Ocirc;'), { Ô }
('&Otilde;'), { Õ }
('&Ouml;'), { Ö }
('&Oslash;'), { Ø }
('&Ugrave;'), { Ù }
('&Uacute;'), { Ú }
('&Ucirc;'), { Û }
('&Uuml;'), { Ü }
('&Yacute;'), { Ý }
('&THORN;'), { Þ }
('&szlig;'), { ß }
('&agrave;'), { à }
('&aacute;'), { á }
('&acirc;'), { â }
('&atilde;'), { ã }
('&auml;'), { ä }
('&aring;'), { å }
('&aelig;'), { æ }
('&ccedil;'), { ç }
('&egrave;'), { è }
('&eacute;'), { é }
('&ecirc;'), { ê }
('&euml;'), { ë }
('&igrave;'), { ì }
('&iacute;'), { í }
('&icirc;'), { î }
('&iuml;'), { ï }
('&eth;'), { ð }
('&ntilde;'), { ñ }
('&ograve;'), { ò }
('&oacute;'), { ó }
('&ocirc;'), { ô }
('&otilde;'), { õ }
('&ouml;'), { ö }
('&oslash;'), { ø }
('&ugrave;'), { ù }
('&uacute;'), { ú }
('&ucirc;'), { û }
('&uuml;'), { ü }
('&yacute;'), { ý }
('&thorn;'), { þ }
('&yuml;'), { ÿ }
('&iexcl;'), { ¡ }
('&cent;'), { ¢ }
('&pound;'), { £ }
('&curren;'), { ¤ }
('&yen;'), { ¥ }
('&brvbar;'), { ¦ }
('&sect;'), { § }
('&uml;'), { ¨ }
('&ordf;'), { ª }
('&laquo;'), { « }
('&shy;'), { ¬ }
('&macr;'), { ¯ }
('&deg;'), { ° }
('&plusmn;'), { ± }
('&sup2;'), { ² }
('&sup3;'), { ³ }
('&acute;'), { ´ }
('&micro;'), { µ }
('&middot;'), { · }
('&cedil;'), { ¸ }
('&sup1;'), { ¹ }
('&ordm;'), { º }
('&raquo;'), { » }
('&frac14;'), { ¼ }
('&frac12;'), { ½ }
('&frac34;'), { ¾ }
('&iquest;'), { ¿ }
('&times;'), { × }
('&divide'), { ÷ }
('&euro;'), { }
('&copy;'), { © }
('&reg;'), { ® }
('&Agrave;'), { À }
('&Aacute;'), { Á }
('&Acirc;'), { Â }
('&Atilde;'), { Ã }
('&Auml;'), { Ä }
('&Aring;'), { Å }
('&AElig;'), { Æ }
('&Ccedil;'), { Ç }
('&Egrave;'), { È }
('&Eacute;'), { É }
('&Ecirc;'), { Ê }
('&Euml;'), { Ë }
('&Igrave;'), { Ì }
('&Iacute;'), { Í }
('&Icirc;'), { Î }
('&Iuml;'), { Ï }
('&ETH;'), { Ð }
('&Ntilde;'), { Ñ }
('&Ograve;'), { Ò }
('&Oacute;'), { Ó }
('&Ocirc;'), { Ô }
('&Otilde;'), { Õ }
('&Ouml;'), { Ö }
('&Oslash;'), { Ø }
('&Ugrave;'), { Ù }
('&Uacute;'), { Ú }
('&Ucirc;'), { Û }
('&Uuml;'), { Ü }
('&Yacute;'), { Ý }
('&THORN;'), { Þ }
('&szlig;'), { ß }
('&agrave;'), { à }
('&aacute;'), { á }
('&acirc;'), { â }
('&atilde;'), { ã }
('&auml;'), { ä }
('&aring;'), { å }
('&aelig;'), { æ }
('&ccedil;'), { ç }
('&egrave;'), { è }
('&eacute;'), { é }
('&ecirc;'), { ê }
('&euml;'), { ë }
('&igrave;'), { ì }
('&iacute;'), { í }
('&icirc;'), { î }
('&iuml;'), { ï }
('&eth;'), { ð }
('&ntilde;'), { ñ }
('&ograve;'), { ò }
('&oacute;'), { ó }
('&ocirc;'), { ô }
('&otilde;'), { õ }
('&ouml;'), { ö }
('&oslash;'), { ø }
('&ugrave;'), { ù }
('&uacute;'), { ú }
('&ucirc;'), { û }
('&uuml;'), { ü }
('&yacute;'), { ý }
('&thorn;'), { þ }
('&yuml;'), { ÿ }
('&iexcl;'), { ¡ }
('&cent;'), { ¢ }
('&pound;'), { £ }
('&curren;'), { ¤ }
('&yen;'), { ¥ }
('&brvbar;'), { ¦ }
('&sect;'), { § }
('&uml;'), { ¨ }
('&ordf;'), { ª }
('&laquo;'), { « }
('&shy;'), { ¬ }
('&macr;'), { ¯ }
('&deg;'), { ° }
('&plusmn;'), { ± }
('&sup2;'), { ² }
('&sup3;'), { ³ }
('&acute;'), { ´ }
('&micro;'), { µ }
('&middot;'), { · }
('&cedil;'), { ¸ }
('&sup1;'), { ¹ }
('&ordm;'), { º }
('&raquo;'), { » }
('&frac14;'), { ¼ }
('&frac12;'), { ½ }
('&frac34;'), { ¾ }
('&iquest;'), { ¿ }
('&times;'), { × }
('&divide'), { ÷ }
('&euro;'), { € }
//used by very old HTML editors
('&#9;'), { TAB }
('&#127;'), {  }
('&#128;'), { }
('&#129;'), { <EFBFBD> }
('&#130;'), { }
('&#131;'), { ƒ }
('&#132;'), { }
('&ldots;'), { }
('&#134;'), { }
('&#135;'), { }
('&#136;'), { ˆ }
('&#137;'), { }
('&#138;'), { Š }
('&#139;'), { }
('&#140;'), { Œ }
('&#141;'), { <EFBFBD> }
('&#142;'), { Ž }
('&#143;'), { <EFBFBD> }
('&#144;'), { <EFBFBD> }
('&#152;'), { ˜ }
('&#153;'), { }
('&#154;'), { š }
('&#155;'), { }
('&#156;'), { œ }
('&#157;'), { <EFBFBD> }
('&#158;'), { ž }
('&#159;'), { Ÿ }
('&#161;'), { ¡ }
('&#162;'), { ¢ }
('&#163;'), { £ }
('&#164;'), { ¤ }
('&#165;'), { ¥ }
('&#166;'), { ¦ }
('&#167;'), { § }
('&#168;'), { ¨ }
('&#170;'), { ª }
('&#175;'), { » }
('&#176;'), { ° }
('&#177;'), { ± }
('&#178;'), { ² }
('&#180;'), { ´ }
('&#181;'), { µ }
('&#183;'), { · }
('&#184;'), { ¸ }
('&#185;'), { ¹ }
('&#186;'), { º }
('&#188;'), { ¼ }
('&#189;'), { ½ }
('&#190;'), { ¾ }
('&#191;'), { ¿ }
('&#215;') { Ô }
('&#128;'), { € }
('&#129;'), {  }
('&#130;'), { ‚ }
('&#131;'), { ƒ }
('&#132;'), { „ }
('&ldots;'), { … }
('&#134;'), { † }
('&#135;'), { ‡ }
('&#136;'), { ˆ }
('&#137;'), { ‰ }
('&#138;'), { Š }
('&#139;'), { ‹ }
('&#140;'), { Œ }
('&#141;'), {  }
('&#142;'), { Ž }
('&#143;'), {  }
('&#144;'), {  }
('&#152;'), { ˜ }
('&#153;'), { ™ }
('&#154;'), { š }
('&#155;'), { › }
('&#156;'), { œ }
('&#157;'), {  }
('&#158;'), { ž }
('&#159;'), { Ÿ }
('&#161;'), { ¡ }
('&#162;'), { ¢ }
('&#163;'), { £ }
('&#164;'), { ¤ }
('&#165;'), { ¥ }
('&#166;'), { ¦ }
('&#167;'), { § }
('&#168;'), { ¨ }
('&#170;'), { ª }
('&#175;'), { » }
('&#176;'), { ° }
('&#177;'), { ± }
('&#178;'), { ² }
('&#180;'), { ´ }
('&#181;'), { µ }
('&#183;'), { · }
('&#184;'), { ¸ }
('&#185;'), { ¹ }
('&#186;'), { º }
('&#188;'), { ¼ }
('&#189;'), { ½ }
('&#190;'), { ¾ }
('&#191;'), { ¿ }
('&#215;') { Ô }
);

View File

@ -37,7 +37,7 @@ uses
Graphics, Dialogs, Buttons, StdCtrls,
// components
SynHighlighterLFM, SynEdit, BasicCodeTools, CodeCache, CodeToolManager,
LFMTrees,
SynEditMiscClasses, LFMTrees,
// IDE
PropEdits, IDEDialogs, ComponentReg, PackageIntf, IDEWindowIntf,
CustomFormEditor, LazarusIDEStrConsts, OutputFilter, IDEProcs, IDEOptionDefs,
@ -59,7 +59,7 @@ type
SynLFMSyn1: TSynLFMSyn;
procedure ErrorsListBoxClick(Sender: TObject);
procedure LFMSynEditSpecialLineColors(Sender: TObject; Line: integer;
var Special: boolean; var FG, BG: TColor);
var Special: boolean; AMarkup: TSynSelectedColor);
procedure RemoveAllButtonClick(Sender: TObject);
procedure CheckLFMDialogCREATE(Sender: TObject);
private
@ -521,14 +521,15 @@ begin
end;
procedure TCheckLFMDialog.LFMSynEditSpecialLineColors(Sender: TObject;
Line: integer; var Special: boolean; var FG, BG: TColor);
Line: integer; var Special: boolean; AMarkup: TSynSelectedColor);
var
CurError: TLFMError;
begin
CurError:=LFMTree.FindErrorAtLine(Line);
if CurError = nil then Exit;
Special := EditorOpts.GetLineColors(SynLFMSyn1,ahaErrorLine,FG,BG);
Special := True;
EditorOpts.SetMarkupColor(SynLFMSyn1, ahaErrorLine, AMarkup);
end;
procedure TCheckLFMDialog.CheckLFMDialogCREATE(Sender: TObject);

View File

@ -1,19 +1,19 @@
object EditorOptionsForm: TEditorOptionsForm
Left = 438
Height = 541
Height = 577
Top = 120
Width = 554
ActiveControl = MainNotebook
Caption = 'EditorOptionsForm'
ClientHeight = 541
ClientHeight = 577
ClientWidth = 554
Constraints.MinHeight = 500
Constraints.MinWidth = 400
Constraints.MinWidth = 420
Position = poScreenCenter
LCLVersion = '0.9.25'
object MainNotebook: TNotebook
AnchorSideBottom.Control = BtnPanel
Height = 494
Height = 534
Width = 554
Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom]
@ -22,17 +22,17 @@ object EditorOptionsForm: TEditorOptionsForm
TabOrder = 0
object GeneralPage: TPage
Caption = 'GeneralPage'
ClientWidth = 548
ClientHeight = 455
ClientWidth = 546
ClientHeight = 508
object BlockIndentLabel: TLabel
AnchorSideLeft.Control = BlockIndentComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = BlockIndentComboBox
AnchorSideBottom.Side = asrCenter
Left = 112
Height = 20
Top = 374
Width = 109
Height = 16
Top = 429
Width = 92
Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6
Caption = 'BlockIndentLabel'
@ -44,9 +44,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideBottom.Control = UndoLimitComboBox
AnchorSideBottom.Side = asrCenter
Left = 112
Height = 20
Top = 401
Width = 100
Height = 16
Top = 456
Width = 85
Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6
Caption = 'UndoLimitLabel'
@ -58,9 +58,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideBottom.Control = TabWidthsComboBox
AnchorSideBottom.Side = asrCenter
Left = 112
Height = 20
Top = 428
Width = 98
Height = 16
Top = 483
Width = 86
Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6
Caption = 'TabWidthsLabel'
@ -70,9 +70,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BlockIndentLabel
Left = 6
Height = 356
Height = 411
Top = 6
Width = 536
Width = 534
Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFill = True
@ -90,13 +90,13 @@ object EditorOptionsForm: TEditorOptionsForm
ColumnLayout = clVerticalThenHorizontal
Columns = 2
OnItemClick = GeneralCheckBoxOnChange
TabOrder = 0
TabOrder = 3
end
object BlockIndentComboBox: TComboBox
AnchorSideBottom.Control = UndoLimitComboBox
Left = 6
Height = 21
Top = 374
Top = 427
Width = 100
Anchors = [akLeft, akBottom]
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
@ -111,13 +111,13 @@ object EditorOptionsForm: TEditorOptionsForm
OnChange = ComboBoxOnChange
OnExit = ComboBoxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 1
TabOrder = 0
end
object UndoLimitComboBox: TComboBox
AnchorSideBottom.Control = TabWidthsComboBox
Left = 6
Height = 21
Top = 401
Top = 454
Width = 100
Anchors = [akLeft, akBottom]
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
@ -131,14 +131,14 @@ object EditorOptionsForm: TEditorOptionsForm
OnChange = ComboBoxOnChange
OnExit = ComboBoxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 2
TabOrder = 1
end
object TabWidthsComboBox: TComboBox
AnchorSideBottom.Control = GeneralPage
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 21
Top = 428
Top = 481
Width = 100
Anchors = [akLeft, akBottom]
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
@ -153,7 +153,7 @@ object EditorOptionsForm: TEditorOptionsForm
OnChange = ComboBoxOnChange
OnExit = ComboBoxOnExit
OnKeyDown = ComboBoxOnKeyDown
TabOrder = 3
TabOrder = 2
end
end
object DisplayPage: TPage
@ -168,9 +168,9 @@ object EditorOptionsForm: TEditorOptionsForm
Align = alTop
BorderSpacing.Around = 6
Caption = 'MarginAndGutterGroupBox'
ClientHeight = 106
ClientWidth = 528
TabOrder = 0
ClientHeight = 128
ClientWidth = 536
TabOrder = 1
object RightMarginLabel: TLabel
Left = 358
Height = 18
@ -262,19 +262,19 @@ object EditorOptionsForm: TEditorOptionsForm
end
object EditorFontGroupBox: TGroupBox
Left = 6
Height = 148
Height = 117
Top = 140
Width = 536
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'EditorFontGroupBox'
ClientHeight = 126
ClientWidth = 528
TabOrder = 1
ClientHeight = 117
ClientWidth = 536
TabOrder = 0
object EditorFontLabel: TLabel
Left = 6
Height = 20
Height = 16
Top = 6
Width = 516
Align = alTop
@ -420,6 +420,7 @@ object EditorOptionsForm: TEditorOptionsForm
Font.Pitch = fpFixed
ParentColor = False
TabOrder = 2
BookMarkOptions.OnChange = nil
Gutter.CodeFoldingWidth = 14
Keystrokes = <
item
@ -746,19 +747,20 @@ object EditorOptionsForm: TEditorOptionsForm
'DisplayPreview'
)
ReadOnly = True
OnSpecialLineColors = OnSpecialLineColors
OnSpecialLineMarkup = OnSpecialLineColors
OnStatusChange = DisplayPreviewStatusChange
end
end
object KeymappingPage: TPage
Caption = 'KeymappingPage'
ClientWidth = 548
ClientHeight = 455
ClientWidth = 546
ClientHeight = 508
object KeyMappingHelpLabel: TLabel
AnchorSideTop.Control = KeymappingPage
Left = 8
Height = 18
Height = 16
Top = 6
Width = 137
Width = 121
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
@ -771,9 +773,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideBottom.Control = KeymappingPage
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 20
Top = 429
Width = 242
Height = 25
Top = 477
Width = 211
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -787,10 +789,10 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = KeymappingPage
AnchorSideBottom.Side = asrBottom
Left = 281
Height = 20
Top = 429
Width = 261
Left = 314
Height = 25
Top = 477
Width = 226
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -806,9 +808,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = KeyMappingFindKeyButton
Left = 6
Height = 345
Top = 52
Width = 536
Height = 390
Top = 50
Width = 534
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
DefaultItemHeight = 21
@ -827,8 +829,8 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
Left = 6
Height = 16
Top = 30
Width = 536
Top = 28
Width = 534
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
@ -841,9 +843,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = KeyMappingChooseSchemeButton
Left = 6
Height = 20
Top = 403
Width = 197
Height = 25
Top = 446
Width = 171
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -854,37 +856,37 @@ object EditorOptionsForm: TEditorOptionsForm
end
object ColorPage: TPage
Caption = 'ColorPage'
ClientWidth = 550
ClientHeight = 463
ClientWidth = 546
ClientHeight = 508
object LanguageLabel: TLabel
Left = 214
Height = 20
Height = 16
Top = 12
Width = 98
Width = 81
Caption = 'LanguageLabel'
ParentColor = False
end
object ColorSchemeLabel: TLabel
Left = 214
Height = 20
Height = 16
Top = 36
Width = 121
Width = 100
Caption = 'ColorSchemeLabel'
ParentColor = False
end
object FileExtensionsLabel: TLabel
Left = 214
Height = 20
Height = 16
Top = 60
Width = 124
Width = 102
Caption = 'FileExtensionsLabel'
ParentColor = False
end
object ColorElementLabel: TLabel
Left = 4
Height = 20
Height = 16
Top = 90
Width = 121
Width = 101
Caption = 'ColorElementLabel'
ParentColor = False
end
@ -933,9 +935,9 @@ object EditorOptionsForm: TEditorOptionsForm
end
object ColorPreview: TSynEdit
Left = 4
Height = 100
Top = 359
Width = 542
Height = 126
Top = 378
Width = 538
Align = alBottom
BorderSpacing.Around = 4
Anchors = [akTop, akLeft, akRight, akBottom]
@ -945,6 +947,7 @@ object EditorOptionsForm: TEditorOptionsForm
ParentColor = False
TabOrder = 3
OnMouseDown = ColorPreviewMouseUp
BookMarkOptions.OnChange = nil
Gutter.CodeFoldingWidth = 14
Keystrokes = <
item
@ -1271,11 +1274,12 @@ object EditorOptionsForm: TEditorOptionsForm
'ColorPreview'
)
ReadOnly = True
OnSpecialLineColors = OnSpecialLineColors
OnSpecialLineMarkup = OnSpecialLineColors
OnStatusChange = DisplayPreviewStatusChange
end
object ColorElementListBox: TListBox
Left = 3
Height = 242
Height = 264
Top = 108
Width = 200
ClickOnSelChange = False
@ -1289,7 +1293,7 @@ object EditorOptionsForm: TEditorOptionsForm
Left = 212
Height = 25
Top = 90
Width = 332
Width = 328
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'SetAttributeToDefaultButton'
@ -1302,7 +1306,7 @@ object EditorOptionsForm: TEditorOptionsForm
Left = 212
Height = 25
Top = 122
Width = 332
Width = 328
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'SetAllAttributesToDefaultButton'
@ -1314,19 +1318,19 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ColorPreview
Left = 212
Height = 199
Height = 218
Top = 154
Width = 332
Width = 328
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
Caption = 'Attributes'
ClientHeight = 177
ClientWidth = 324
ClientHeight = 218
ClientWidth = 328
TabOrder = 7
object ForeGroundLabel: TLabel
Left = 8
Height = 20
Width = 110
Height = 16
Width = 92
Caption = 'ForeGroundLabel'
ParentColor = False
end
@ -1335,7 +1339,7 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideTop.Side = asrBottom
Left = 8
Height = 21
Top = 22
Top = 18
Width = 75
BorderSpacing.Top = 2
BorderWidth = 2
@ -1348,7 +1352,7 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideTop.Side = asrBottom
Left = 8
Height = 21
Top = 70
Top = 62
Width = 75
BorderSpacing.Top = 2
BorderWidth = 2
@ -1360,9 +1364,9 @@ object EditorOptionsForm: TEditorOptionsForm
AnchorSideTop.Control = ForeGroundLabel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 20
Top = 48
Width = 113
Height = 16
Top = 44
Width = 94
BorderSpacing.Top = 28
Caption = 'BackGroundLabel'
ParentColor = False
@ -1393,38 +1397,203 @@ object EditorOptionsForm: TEditorOptionsForm
OnChange = GeneralCheckBoxOnChange
TabOrder = 1
end
object TextBoldCheckBox: TCheckBox
object TextUnderlinePanel: TPanel
Left = 6
Height = 22
Top = 93
Width = 312
Align = alBottom
AutoSize = True
BorderSpacing.Around = 6
Caption = 'TextBoldCheckBox'
OnChange = GeneralCheckBoxOnChange
BevelOuter = bvNone
ClientHeight = 22
ClientWidth = 312
TabOrder = 2
object TextUnderlineCheckBox: TCheckBox
Height = 21
Width = 159
Align = alClient
Caption = 'TextUnderlineCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 0
end
object TextUnderlineRadioPanel: TPanel
Left = 159
Height = 21
Width = 153
Align = alRight
AutoSize = True
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 3
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 21
ClientWidth = 153
TabOrder = 1
Visible = False
object TextUnderlineRadioOn: TRadioButton
Tag = 3
Height = 21
Width = 44
Caption = 'On'
Checked = True
OnChange = TextStyleRadioOnChange
State = cbChecked
TabOrder = 0
end
object TextUnderlineRadioOff: TRadioButton
Tag = 3
Left = 47
Height = 21
Width = 45
Caption = 'Off'
OnChange = TextStyleRadioOnChange
TabOrder = 1
end
object TextUnderlineRadioInvert: TRadioButton
Tag = 3
Left = 95
Height = 21
Width = 58
Caption = 'Invert'
OnChange = TextStyleRadioOnChange
TabOrder = 2
end
end
end
object TextItalicCheckBox: TCheckBox
object TextBoldPanel: TPanel
Left = 6
Height = 22
Top = 121
Width = 312
Align = alBottom
AutoSize = True
BorderSpacing.Around = 6
Caption = 'TextItalicCheckBox'
OnChange = GeneralCheckBoxOnChange
BevelOuter = bvNone
ClientHeight = 22
ClientWidth = 312
TabOrder = 3
object TextBoldCheckBox: TCheckBox
Height = 21
Width = 159
Align = alClient
Caption = 'TextBoldCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 0
end
object TextBoldRadioPanel: TPanel
Left = 159
Height = 21
Width = 153
Align = alRight
AutoSize = True
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 3
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 21
ClientWidth = 153
TabOrder = 1
Visible = False
object TextBoldRadioOn: TRadioButton
Tag = 1
Height = 21
Width = 44
Caption = 'On'
Checked = True
OnChange = TextStyleRadioOnChange
State = cbChecked
TabOrder = 0
end
object TextBoldRadioOff: TRadioButton
Tag = 1
Left = 47
Height = 21
Width = 45
Caption = 'Off'
OnChange = TextStyleRadioOnChange
TabOrder = 1
end
object TextBoldRadioInvert: TRadioButton
Tag = 1
Left = 95
Height = 21
Width = 58
Caption = 'Invert'
OnChange = TextStyleRadioOnChange
TabOrder = 2
end
end
end
object TextUnderlineCheckBox: TCheckBox
object TextItalicPanel: TPanel
Left = 6
Height = 22
Top = 149
Width = 312
Align = alBottom
AutoSize = True
BorderSpacing.Around = 6
Caption = 'TextUnderlineCheckBox'
OnChange = GeneralCheckBoxOnChange
BevelOuter = bvNone
ClientHeight = 22
ClientWidth = 312
TabOrder = 4
object TextItalicCheckBox: TCheckBox
Height = 21
Width = 159
Align = alClient
Caption = 'TextItalicCheckBox'
OnChange = GeneralCheckBoxOnChange
TabOrder = 0
end
object TextItalicRadioPanel: TPanel
Left = 159
Height = 21
Width = 153
Align = alRight
AutoSize = True
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 3
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 21
ClientWidth = 153
TabOrder = 1
Visible = False
object TextItalicRadioOn: TRadioButton
Tag = 2
Height = 21
Width = 44
Caption = 'On'
Checked = True
OnChange = TextStyleRadioOnChange
State = cbChecked
TabOrder = 0
end
object TextItalicRadioOff: TRadioButton
Tag = 2
Left = 47
Height = 21
Width = 45
Caption = 'Off'
OnChange = TextStyleRadioOnChange
TabOrder = 1
end
object TextItalicRadioInvert: TRadioButton
Tag = 2
Left = 95
Height = 21
Width = 58
Caption = 'Invert'
OnChange = TextStyleRadioOnChange
TabOrder = 2
end
end
end
end
end
@ -1440,8 +1609,8 @@ object EditorOptionsForm: TEditorOptionsForm
Align = alClient
BorderSpacing.Around = 6
Caption = 'AutomaticFeaturesGroupBox'
ClientHeight = 429
ClientWidth = 530
ClientHeight = 451
ClientWidth = 538
TabOrder = 0
object AutoDelayLabel: TLabel
Left = 6
@ -1578,21 +1747,21 @@ object EditorOptionsForm: TEditorOptionsForm
end
end
object BtnPanel: TPanel
Height = 41
Top = 500
Height = 37
Top = 540
Width = 554
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 41
ClientHeight = 37
ClientWidth = 554
TabOrder = 1
object OkButton: TButton
AnchorSideBottom.Side = asrBottom
Left = 342
Height = 29
Left = 367
Height = 25
Top = 6
Width = 88
Width = 77
Align = alRight
AutoSize = True
BorderSpacing.Around = 6
@ -1604,10 +1773,10 @@ object EditorOptionsForm: TEditorOptionsForm
object CancelButton: TButton
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 436
Height = 29
Left = 450
Height = 25
Top = 6
Width = 112
Width = 98
Align = alRight
AutoSize = True
BorderSpacing.Around = 6

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@ uses
SynHighlighterCPP, SynHighlighterHTML, SynHighlighterJava, SynHighlighterLFM,
SynHighlighterPas, SynHighlighterPerl, SynHighlighterPHP, SynHighlighterSQL,
SynHighlighterPython, SynHighlighterUNIXShellScript, SynHighlighterXML,
SynHighlighterJScript,
SynHighlighterJScript, SynEditMiscClasses,
// codetools
Laz_XMLCfg,
// IDEIntf
@ -55,6 +55,9 @@ uses
KeymapSchemeDlg, LazConf, Spin;
type
{ TPreviewEditor }
TPreviewEditor = TSynEdit;
TPreviewPasSyn = TSynFreePascalSyn;
TCustomSyn = TSynCustomHighlighter;
@ -85,7 +88,8 @@ type
TAdditionalHilightAttribute = (ahaNone, ahaTextBlock, ahaExecutionPoint,
ahaEnabledBreakpoint, ahaDisabledBreakpoint,
ahaInvalidBreakpoint, ahaUnknownBreakpoint,
ahaErrorLine, ahaIncrementalSearch, ahaHighlightAll);
ahaErrorLine, ahaIncrementalSearch, ahaHighlightAll, ahaBracketMatch,
ahaMouseLink);
const
AdditionalHighlightAttributes: array[TAdditionalHilightAttribute] of String =
@ -99,13 +103,16 @@ const
'Unknown breakpoint',
'Error line',
'Incremental search match',
'Highlight all'
'Highlight all',
'Matching Brackets',
'Mouse Link'
);
type
TSchemeAttribute = record
BG, FG: TColor;
Styles: TFontStyles;
StylesMask: TFontStyles; // For Markup, normal Attributes will ignore this
end;
TPascalColorScheme = record
@ -118,138 +125,148 @@ type
const
DEFAULT_COLOR_SCHEME: TPascalColorScheme = (
Name: 'Default';
Default: (BG: clNone; FG: clNone; Styles: []);
Default: (BG: clNone; FG: clNone; Styles: []; StylesMask: []);
Attributes: (
{ phaAssembler } (BG: clNone; FG: clGreen; Styles: []),
{ phaComment } (BG: clNone; FG: clBlue; Styles: [fsBold]),
{ phaDirective } (BG: clNone; FG: clRed; Styles: [fsBold]),
{ phaReservedWord } (BG: clNone; FG: clNone; Styles: [fsBold]),
{ phaNumber } (BG: clNone; FG: clNavy; Styles: []),
{ phaString } (BG: clNone; FG: clBlue; Styles: []),
{ phaSymbol } (BG: clNone; FG: clRed; Styles: [])
{ phaAssembler } (BG: clNone; FG: clGreen; Styles: []; StylesMask: []),
{ phaComment } (BG: clNone; FG: clBlue; Styles: [fsBold]; StylesMask: []),
{ phaDirective } (BG: clNone; FG: clRed; Styles: [fsBold]; StylesMask: []),
{ phaReservedWord } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ phaNumber } (BG: clNone; FG: clNavy; Styles: []; StylesMask: []),
{ phaString } (BG: clNone; FG: clBlue; Styles: []; StylesMask: []),
{ phaSymbol } (BG: clNone; FG: clRed; Styles: []; StylesMask: [])
);
Additional: (
{ ahaNone } (BG: clWhite; FG: clBlack; Styles: []),
{ ahaTextBlock } (BG: clNavy; FG: clWhite; Styles: []),
{ ahaExecutionPoint } (BG: clDKGray; FG: clWhite; Styles: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clBlack; Styles: []),
{ ahaDisabledBreakpoint } (BG: clGreen; FG: clBlack; Styles: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []),
{ ahaErrorLine } (BG: $50a0ff; FG: clBlack; Styles: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: [])
{ ahaNone } (BG: clWhite; FG: clBlack; Styles: []; StylesMask: []),
{ ahaTextBlock } (BG: clNavy; FG: clWhite; Styles: []; StylesMask: []),
{ ahaExecutionPoint } (BG: clDKGray; FG: clWhite; Styles: []; StylesMask: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clBlack; Styles: []; StylesMask: []),
{ ahaDisabledBreakpoint } (BG: clGreen; FG: clBlack; Styles: []; StylesMask: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []; StylesMask: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []; StylesMask: []),
{ ahaErrorLine } (BG: $50a0ff; FG: clBlack; Styles: []; StylesMask: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []; StylesMask: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: []; StylesMask: []),
{ ahaBracketMatch } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ ahaMouseLink } (BG: clNone; FG: clBlue; Styles: []; StylesMask: [])
)
);
TWILIGHT_COLOR_SCHEME: TPascalColorScheme = (
Name: 'Twilight';
Default: (BG: clBlack; FG: clWhite; Styles: []);
Default: (BG: clBlack; FG: clWhite; Styles: []; StylesMask: []);
Attributes: (
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []),
{ phaComment } (BG: clNone; FG: clGray; Styles: []),
{ phaDirective } (BG: clNone; FG: clRed; Styles: []),
{ phaReservedWord } (BG: clNone; FG: clAqua; Styles: [fsBold]),
{ phaNumber } (BG: clNone; FG: clFuchsia; Styles: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []),
{ phaSymbol } (BG: clNone; FG: clAqua; Styles: [])
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []; StylesMask: []),
{ phaComment } (BG: clNone; FG: clGray; Styles: []; StylesMask: []),
{ phaDirective } (BG: clNone; FG: clRed; Styles: []; StylesMask: []),
{ phaReservedWord } (BG: clNone; FG: clAqua; Styles: [fsBold]; StylesMask: []),
{ phaNumber } (BG: clNone; FG: clFuchsia; Styles: []; StylesMask: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []; StylesMask: []),
{ phaSymbol } (BG: clNone; FG: clAqua; Styles: []; StylesMask: [])
);
Additional: (
{ ahaNone } (BG: clNone; FG: clNone; Styles: []),
{ ahaTextBlock } (BG: clWhite; FG: clBlack; Styles: []),
{ ahaExecutionPoint } (BG: clBlue; FG: clWhite; Styles: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []),
{ ahaErrorLine } (BG: $50a0ff; FG: clBlack; Styles: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: [])
{ ahaNone } (BG: clNone; FG: clNone; Styles: []; StylesMask: []),
{ ahaTextBlock } (BG: clWhite; FG: clBlack; Styles: []; StylesMask: []),
{ ahaExecutionPoint } (BG: clBlue; FG: clWhite; Styles: []; StylesMask: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []; StylesMask: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []; StylesMask: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []; StylesMask: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []; StylesMask: []),
{ ahaErrorLine } (BG: $50a0ff; FG: clBlack; Styles: []; StylesMask: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []; StylesMask: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: []; StylesMask: []),
{ ahaBracketMatch } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ ahaMouseLink } (BG: clNone; FG: clBlue; Styles: []; StylesMask: [])
)
);
CLASSIC_COLOR_SCHEME: TPascalColorScheme = (
Name: 'Pascal Classic';
Default: (BG: clNavy; FG: clYellow; Styles: []);
Default: (BG: clNavy; FG: clYellow; Styles: []; StylesMask: []);
Attributes: (
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []),
{ phaComment } (BG: clNone; FG: clSilver; Styles: []),
{ phaDirective } (BG: clNone; FG: clSilver; Styles: []),
{ phaReservedWord } (BG: clNone; FG: clWhite; Styles: []),
{ phaNumber } (BG: clNone; FG: clYellow; Styles: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []),
{ phaSymbol } (BG: clNone; FG: clYellow; Styles: [])
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []; StylesMask: []),
{ phaComment } (BG: clNone; FG: clSilver; Styles: []; StylesMask: []),
{ phaDirective } (BG: clNone; FG: clSilver; Styles: []; StylesMask: []),
{ phaReservedWord } (BG: clNone; FG: clWhite; Styles: []; StylesMask: []),
{ phaNumber } (BG: clNone; FG: clYellow; Styles: []; StylesMask: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []; StylesMask: []),
{ phaSymbol } (BG: clNone; FG: clYellow; Styles: []; StylesMask: [])
);
Additional: (
{ ahaNone } (BG: clNone; FG: clNone; Styles: []),
{ ahaTextBlock } (BG: clBlue; FG: clWhite; Styles: []),
{ ahaExecutionPoint } (BG: clAqua; FG: clBlack; Styles: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clLime; Styles: []),
{ ahaUnknownBreakpoint } (BG: clNone; FG: clNone; Styles: []),
{ ahaErrorLine } (BG: clMaroon; FG: clWhite; Styles: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: [])
{ ahaNone } (BG: clNone; FG: clNone; Styles: []; StylesMask: []),
{ ahaTextBlock } (BG: clBlue; FG: clWhite; Styles: []; StylesMask: []),
{ ahaExecutionPoint } (BG: clAqua; FG: clBlack; Styles: []; StylesMask: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []; StylesMask: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []; StylesMask: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clLime; Styles: []; StylesMask: []),
{ ahaUnknownBreakpoint } (BG: clNone; FG: clNone; Styles: []; StylesMask: []),
{ ahaErrorLine } (BG: clMaroon; FG: clWhite; Styles: []; StylesMask: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []; StylesMask: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: []; StylesMask: []),
{ ahaBracketMatch } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ ahaMouseLink } (BG: clNone; FG: clBlue; Styles: []; StylesMask: [])
)
);
OCEAN_COLOR_SCHEME: TPascalColorScheme = (
Name: 'Ocean';
Default: (BG: clNavy; FG: clYellow; Styles: []);
Default: (BG: clNavy; FG: clYellow; Styles: []; StylesMask: []);
Attributes: (
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []),
{ phaComment } (BG: clNone; FG: clGray; Styles: []),
{ phaDirective } (BG: clNone; FG: clRed; Styles: []),
{ phaReservedWord } (BG: clNone; FG: clAqua; Styles: [fsBold]),
{ phaNumber } (BG: clNone; FG: clFuchsia; Styles: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []),
{ phaSymbol } (BG: clNone; FG: clAqua; Styles: [])
{ phaAssembler } (BG: clNone; FG: clLime; Styles: []; StylesMask: []),
{ phaComment } (BG: clNone; FG: clGray; Styles: []; StylesMask: []),
{ phaDirective } (BG: clNone; FG: clRed; Styles: []; StylesMask: []),
{ phaReservedWord } (BG: clNone; FG: clAqua; Styles: [fsBold]; StylesMask: []),
{ phaNumber } (BG: clNone; FG: clFuchsia; Styles: []; StylesMask: []),
{ phaString } (BG: clNone; FG: clYellow; Styles: []; StylesMask: []),
{ phaSymbol } (BG: clNone; FG: clAqua; Styles: []; StylesMask: [])
);
Additional: (
{ ahaNone } (BG: clNone; FG: clNone; Styles: []),
{ ahaTextBlock } (BG: clWhite; FG: clBlack; Styles: []),
{ ahaExecutionPoint } (BG: clBlue; FG: clWhite; Styles: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []),
{ ahaErrorLine } (BG: $50A0FF; FG: clBlack; Styles: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: [])
{ ahaNone } (BG: clNone; FG: clNone; Styles: []; StylesMask: []),
{ ahaTextBlock } (BG: clWhite; FG: clBlack; Styles: []; StylesMask: []),
{ ahaExecutionPoint } (BG: clBlue; FG: clWhite; Styles: []; StylesMask: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []; StylesMask: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []; StylesMask: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clGreen; Styles: []; StylesMask: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []; StylesMask: []),
{ ahaErrorLine } (BG: $50A0FF; FG: clBlack; Styles: []; StylesMask: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []; StylesMask: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: []; StylesMask: []),
{ ahaBracketMatch } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ ahaMouseLink } (BG: clNone; FG: clBlue; Styles: []; StylesMask: [])
)
);
DELPHI_COLOR_SCHEME: TPascalColorScheme = (
Name: 'Delphi';
Default: (BG: clNone; FG: clNone; Styles: []);
Default: (BG: clNone; FG: clNone; Styles: []; StylesMask: []);
Attributes: (
{ phaAssembler } (BG: clNone; FG: clBlack; Styles: []),
{ phaComment } (BG: clNone; FG: clNavy; Styles: [fsItalic]),
{ phaDirective } (BG: clNone; FG: clGreen; Styles: []),
{ phaReservedWord } (BG: clNone; FG: clBlack; Styles: [fsBold]),
{ phaNumber } (BG: clNone; FG: clNavy; Styles: []),
{ phaString } (BG: clNone; FG: clNavy; Styles: []),
{ phaSymbol } (BG: clNone; FG: clBlack; Styles: [])
{ phaAssembler } (BG: clNone; FG: clBlack; Styles: []; StylesMask: []),
{ phaComment } (BG: clNone; FG: clNavy; Styles: [fsItalic]; StylesMask: []),
{ phaDirective } (BG: clNone; FG: clGreen; Styles: []; StylesMask: []),
{ phaReservedWord } (BG: clNone; FG: clBlack; Styles: [fsBold]; StylesMask: []),
{ phaNumber } (BG: clNone; FG: clNavy; Styles: []; StylesMask: []),
{ phaString } (BG: clNone; FG: clNavy; Styles: []; StylesMask: []),
{ phaSymbol } (BG: clNone; FG: clBlack; Styles: []; StylesMask: [])
);
Additional: (
{ ahaNone } (BG: clNone; FG: clNone; Styles: []),
{ ahaTextBlock } (BG: clHighlight; FG: clHighlightText; Styles: []),
{ ahaExecutionPoint } (BG: clNavy; FG: clWhite; Styles: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clLime; Styles: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []),
{ ahaErrorLine } (BG: clMaroon; FG: clWhite; Styles: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: [])
{ ahaNone } (BG: clNone; FG: clNone; Styles: []; StylesMask: []),
{ ahaTextBlock } (BG: clHighlight; FG: clHighlightText; Styles: []; StylesMask: []),
{ ahaExecutionPoint } (BG: clNavy; FG: clWhite; Styles: []; StylesMask: []),
{ ahaEnabledBreakpoint } (BG: clRed; FG: clWhite; Styles: []; StylesMask: []),
{ ahaDisabledBreakpoint } (BG: clLime; FG: clRed; Styles: []; StylesMask: []),
{ ahaInvalidBreakpoint } (BG: clOlive; FG: clLime; Styles: []; StylesMask: []),
{ ahaUnknownBreakpoint } (BG: clRed; FG: clBlack; Styles: []; StylesMask: []),
{ ahaErrorLine } (BG: clMaroon; FG: clWhite; Styles: []; StylesMask: []),
{ ahaIncrementalSearch } (BG: $30D070; FG: clWhite; Styles: []; StylesMask: []),
{ ahaHighlightAll } (BG: clYellow; FG: clNone; Styles: []; StylesMask: []),
{ ahaBracketMatch } (BG: clNone; FG: clNone; Styles: [fsBold]; StylesMask: []),
{ ahaMouseLink } (BG: clNone; FG: clBlue; Styles: []; StylesMask: [])
)
);
const
EditorOptsFormatVersion = 2;
EditorOptsFormatVersion = 3;
LazSyntaxHighlighterClasses: array[TLazSyntaxHighlighter] of
TCustomSynClass =
@ -307,6 +324,7 @@ type
Integer; // first line = 1
MappedAttributes: TStringList; // map attributes to pascal
DefaultCommentType: TCommentType;
CaretXY: TPoint;
constructor Create;
destructor Destroy; override;
function GetDefaultFilextension: String;
@ -422,8 +440,11 @@ type
DefaultPascalSyn: TPreviewPasSyn);
procedure WriteHighlighterSettings(Syn: TCustomSyn;
SynColorScheme: String);
function GetLineColors(Syn: TCustomSyn; AddHilightAttr: TAdditionalHilightAttribute;
out FG, BG: TColor): Boolean;
function GetLineColors(Syn: TCustomSyn; AddHilightAttr: TAdditionalHilightAttribute; {TODO: MFR maybe remove?}
out FG, BG: TColor; out Styles, StylesMask: TFontStyles): Boolean;
procedure SetMarkupColor(Syn: TCustomSyn; AddHilightAttr: TAdditionalHilightAttribute;
aMarkup: TSynSelectedColor);
procedure SetMarkupColors(Syn: TCustomSyn; aSynEd: TSynEdit);
published
// general options
property SynEditOptions: TSynEditorOptions
@ -527,6 +548,21 @@ type
BlockIndentLabel: TLabel;
CodeFolding: TPage;
BtnPanel: TPanel;
TextBoldRadioOn : TRadioButton;
TextBoldRadioOff : TRadioButton;
TextBoldRadioInvert : TRadioButton;
TextItalicRadioOn : TRadioButton;
TextItalicRadioOff : TRadioButton;
TextItalicRadioInvert : TRadioButton;
TextUnderlineRadioOn : TRadioButton;
TextUnderlineRadioOff : TRadioButton;
TextUnderlineRadioInvert : TRadioButton;
TextBoldRadioPanel : TPanel;
TextItalicRadioPanel : TPanel;
TextUnderlineRadioPanel : TPanel;
TextUnderlinePanel : TPanel;
TextItalicPanel : TPanel;
TextBoldPanel : TPanel;
UndoLimitComboBox: TComboBox;
UndoLimitLabel: TLabel;
TabWidthsComboBox: TComboBox;
@ -607,6 +643,7 @@ type
// general
procedure ColorElementListBoxClick(Sender: TObject);
procedure DisplayPreviewStatusChange(Sender : TObject; Changes : TSynStatusChanges);
procedure GeneralCheckBoxOnChange(Sender: TObject);
procedure ComboBoxOnChange(Sender: TObject);
procedure ComboBoxOnExit(Sender: TObject);
@ -633,7 +670,7 @@ type
procedure ColorPreviewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OnSpecialLineColors(Sender: TObject; Line: Integer;
var Special: Boolean; var FG, BG: TColor);
var Special: boolean; aMarkUp : TSynSelectedColor);
procedure SetAttributeToDefaultButtonClick(Sender: TObject);
procedure SetAllAttributesToDefaultButtonClick(Sender: TObject);
@ -645,6 +682,7 @@ type
// buttons at bottom
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure TextStyleRadioOnChange(Sender : TObject);
private
FormCreating: Boolean;
PreviewSyn: TCustomSyn;
@ -652,6 +690,7 @@ type
CurLanguageID: Integer;
// current index in EditorOpts.EditOptHighlighterList
CurHighlightElement: TSynHighlightElement;
CurHighlightElementIsExtra: Boolean;
UpdatingColor: Boolean;
fHighlighterList: TStringList; // list of "ColorScheme" Data=TCustomSyn
fColorSchemes: TStringList; // list of LanguageName=ColorScheme
@ -904,6 +943,7 @@ begin
Dest.Background := Src.Background;
Dest.Foreground := Src.Foreground;
Dest.Style := Src.Style;
Dest.StyleMask := Src.StyleMask;
end;
{ TEditOptLanguageInfo }
@ -1000,20 +1040,20 @@ begin
'var // Delphi Comment'#13 +
' Number, I, X: Integer;'#13 +
'begin'#13 +
' Number := 12345;'#13 +
' Number := 12345 * (2 + 9) // << Matching Brackets ;'#13 +
' Caption := ''The number is '' + IntToStr(Number);'#13 +
' asm'#13 + ' MOV AX,1234h'#13 +
' MOV Number,AX'#13 +
' end;'#13 +
' X := 10;'#13 +
' { Search Match, Text Block }'#13 +
' for I := 0 to Number do { execution point }'#13 +
' inc(X); {$R+} { Search Match, Text Block }'#13 +
' for I := 0 to Number do {$R-} { execution point }'#13 +
' begin'#13 +
' Inc(X); { Enabled breakpoint }'#13 +
' Dec(X); { Disabled breakpoint }'#13 +
' // { Invalid breakpoint }'#13 +
' WriteLN(X); { Unknown breakpoint }'#13 +
' X := X + 1.0; { Error line }'#13 +
' Inc(X, 2); {$R+} { Enabled breakpoint }'#13 +
' Dec(X, 3); {$R+} { Disabled breakpoint }'#13 +
' {$R-} // { Invalid breakpoint }'#13 +
' WriteLN(X); {$R-} { Unknown breakpoint }'#13 +
' X := X + 1.0; {$R-} { Error line }'#13 +
' ListBox1.Items.Add(IntToStr(X));'#13 +
' end;'#13 +
'end;'#13 + #13;
@ -1024,6 +1064,7 @@ begin
AddAttrSampleLines[ahaErrorLine] := 21;
AddAttrSampleLines[ahaExecutionPoint] := 15;
AddAttrSampleLines[ahaTextBlock] := 14;
CaretXY := Point(21, 7);
end;
Add(NewInfo);
@ -1050,6 +1091,7 @@ begin
Add('Comment=Comment');
Add('Space=Space');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1082,6 +1124,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1108,6 +1151,7 @@ begin
Add('Space=Space');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1137,6 +1181,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1165,6 +1210,7 @@ begin
Add('StringAttri=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1200,6 +1246,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1233,6 +1280,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1266,6 +1314,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1293,6 +1342,7 @@ begin
Add('Key=Key');
Add('String=String');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1323,6 +1373,7 @@ begin
Add('Key=Key');
Add('String=String');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
@ -1351,6 +1402,7 @@ begin
Add('String=String');
Add('Symbol=Symbol');
end;
CaretXY := Point(1,1);
end;
Add(NewInfo);
end;
@ -1510,6 +1562,7 @@ var
SynEditOpt2: TSynEditorOption2;
begin
try
// general options
for SynEditOpt := Low(TSynEditorOption) to High(TSynEditorOption) do
begin
@ -1908,6 +1961,7 @@ begin
else Attr.Background := Scheme.Attributes[pha].BG;
//DebugLn(['TEditorOptions.GetDefaultsForPascalAttribute SynColorScheme=',SynColorScheme,' AttriName=',AttriName,' BG=',ColorToString(Scheme.Attributes[pha].BG),' Background=',ColorToString(Attr.Background),' SchemeBG=',ColorToString(Scheme.Default.BG)]);
Attr.Style := Scheme.Attributes[pha].Styles;
Attr.StyleMask := Scheme.Attributes[pha].StylesMask;
Exit;
end;
@ -1921,12 +1975,14 @@ begin
then Attr.Background := Scheme.Default.BG
else Attr.Background := Scheme.Additional[aha].BG;
Attr.Style := Scheme.Additional[aha].Styles;
Attr.StyleMask := Scheme.Additional[aha].StylesMask;
Exit;
end;
Attr.Foreground := Scheme.Default.FG;
Attr.Background := Scheme.Default.BG;
Attr.Style := Scheme.Additional[aha].Styles;
Attr.Style := Scheme.Default.Styles;
Attr.StyleMask := Scheme.Default.StylesMask;
end;
procedure TEditorOptions.ReadDefaultsForHighlighterSettings(Syn: TCustomSyn;
@ -2063,6 +2119,17 @@ begin
if b then
Include(fs, fsUnderline);
Attri.Style := fs;
fs := [];
b := XMLConfig.GetValue(Path + 'StyleMask/Bold', fsBold in Attri.StyleMask);
if b then
Include(fs, fsBold);
b := XMLConfig.GetValue(Path + 'StyleMask/Italic', fsItalic in Attri.StyleMask);
if b then
Include(fs, fsItalic);
b := XMLConfig.GetValue(Path + 'StyleMask/Underline', fsUnderline in Attri.StyleMask);
if b then
Include(fs, fsUnderline);
Attri.StyleMask := fs;
end// read all attributes
else
if Syn is TPreviewPasSyn then
@ -2089,6 +2156,7 @@ begin
if b then
Include(fs, fsUnderline);
Attri.Style := fs;
Attri.StyleMask := [];
end// FormatVersion < 2
// the oldest format only supports pascal
;
@ -2135,6 +2203,12 @@ begin
XMLConfig.SetValue(Path + 'Style/Italic', fsItalic in Attri.Style);
XMLConfig.SetValue(Path + 'Style/Underline', fsUnderline in Attri.Style);
end;
if Attri.StyleMask <> OldAttri.StyleMask then
begin
XMLConfig.SetValue(Path + 'StyleMask/Bold', fsBold in Attri.StyleMask);
XMLConfig.SetValue(Path + 'StyleMask/Italic', fsItalic in Attri.StyleMask);
XMLConfig.SetValue(Path + 'StyleMask/Underline', fsUnderline in Attri.StyleMask);
end;
end;
finally
OldSyn.Free;
@ -2153,8 +2227,9 @@ begin
WriteHighlighterSettings(Syn, '');
end;
function TEditorOptions.GetLineColors(Syn: TCustomSyn; AddHilightAttr: TAdditionalHilightAttribute;
out FG, BG: TColor{; out Styles: TFontStyles}): Boolean;
function TEditorOptions.GetLineColors(Syn: TCustomSyn;
AddHilightAttr: TAdditionalHilightAttribute;
out FG, BG: TColor; out Styles, StylesMask: TFontStyles): Boolean;
var
i: Integer;
Attrib: TSynHighlighterAttributes;
@ -2170,22 +2245,60 @@ begin
FG := Attrib.Foreground;
BG := Attrib.Background;
// Styles := Attrib.Style;
Exit((FG <> clNone) or (BG <> clNone) {or (Styles <> [])});
Styles := Attrib.Style;
StylesMask := Attrib.StyleMask;
Exit((FG <> clNone) or (BG <> clNone) or (Styles <> []) or (StylesMask <> []));
end;
end;
// set default
FG := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].FG;
BG := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].BG;
// Styles := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].Styles;
Styles := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].Styles;
StylesMask := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].StylesMask;
Result := True;
end;
procedure TEditorOptions.SetMarkupColors(Syn : TCustomSyn; aSynEd : TSynEdit);
begin
SetMarkupColor(aSynEd.Highlighter, ahaTextBlock, aSynEd.SelectedColor);
SetMarkupColor(aSynEd.Highlighter, ahaIncrementalSearch, aSynEd.IncrementColor);
SetMarkupColor(aSynEd.Highlighter, ahaHighlightAll, aSynEd.HighlightAllColor);
SetMarkupColor(aSynEd.Highlighter, ahaBracketMatch, aSynEd.BracketMatchColor);
SetMarkupColor(aSynEd.Highlighter, ahaMouseLink, aSynEd.MouseLinkColor);
end;
procedure TEditorOptions.SetMarkupColor(Syn : TCustomSyn; AddHilightAttr : TAdditionalHilightAttribute; aMarkup : TSynSelectedColor);
var
i: Integer;
Attrib: TSynHighlighterAttributes;
begin
if Syn <> nil
then begin
for i := 0 to Syn.AttrCount - 1 do
begin
Attrib := Syn.Attribute[i];
if Attrib.Name = '' then Continue;
if LowerCase(Attrib.Name) <> LowerCase(AdditionalHighlightAttributes[AddHilightAttr])
then Continue;
aMarkup.Foreground := Attrib.Foreground;
aMarkup.Background := Attrib.Background;
aMarkup.Style := Attrib.Style;
aMarkup.StyleMask := Attrib.StyleMask;
Exit;
end;
end;
// set default
aMarkup.Foreground := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].FG;;
aMarkup.Background := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].BG;
aMarkup.Style := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].Styles;
aMarkup.StyleMask := DEFAULT_COLOR_SCHEME.Additional[AddHilightAttr].StylesMask;
end;
procedure TEditorOptions.GetSynEditSettings(ASynEdit: TSynEdit);
// read synedit setings from config file
var
FG, BG: TColor;
begin
// general options
ASynEdit.Options := fSynEditOptions;
@ -2218,10 +2331,8 @@ begin
ASynEdit.ExtraCharSpacing := fExtraCharSpacing;
ASynEdit.ExtraLineSpacing := fExtraLineSpacing;
ASynEdit.MaxUndo := fUndoLimit;
GetLineColors(ASynEdit.Highlighter, ahaTextBlock, FG, BG);
ASynEdit.SelectedColor.Foreground := FG;
ASynEdit.SelectedColor.Background := BG;
SetMarkupColors(ASynEdit.Highlighter, ASynEdit);
// Code Folding
ASynEdit.CFDividerDrawLevel := FCFDividerDrawLevel;
@ -2293,7 +2404,7 @@ begin
// general options
ASynEdit.Options := fSynEditOptions - [eoDragDropEditing, eoDropFiles,
eoScrollPastEof] + [eoNoCaret, eoNoSelection];
eoScrollPastEof, eoScrollPastEol] + [eoNoCaret, eoNoSelection];
ASynEdit.BlockIndent := fBlockIndent;
ASynEdit.TabWidth := fTabWidth;
@ -2340,6 +2451,7 @@ begin
UpdatingColor := False;
CurHighlightElement := Nil;
CurHighlightElementIsExtra := False;
// create a temporary copy of the keymap for editing
EditingKeyMap := TKeyCommandRelationList.Create;
@ -2368,8 +2480,8 @@ begin
begin
Lines.Text := EditorOpts.HighlighterList[CurLanguageID].SampleSource;
PreviewEdits[a].Options :=
PreviewEdits[a].Options + [eoNoCaret,
eoNoSelection] - [eoBracketHighlight];
PreviewEdits[a].Options - [eoScrollPastEol] + [eoNoCaret, eoNoSelection];
PreviewEdits[a].CaretXY := EditorOpts.HighlighterList[CurLanguageID].CaretXY;
end;
end;
@ -2388,6 +2500,7 @@ begin
FillColorElementListBox;
FindCurHighlightElement;
ShowCurAttribute;
InvalidatePreviews;
// code Tools options
@ -2531,7 +2644,9 @@ begin
end;
end;
if Sender = TextBoldCheckBox then
if TextBoldCheckBox.Checked xor (fsBold in CurHighlightElement.Style) then
if CurHighlightElementIsExtra
then TextStyleRadioOnChange(Sender)
else if TextBoldCheckBox.Checked xor (fsBold in CurHighlightElement.Style) then
begin
if TextBoldCheckBox.Checked then
CurHighlightElement.Style := CurHighlightElement.Style + [fsBold]
@ -2540,7 +2655,9 @@ begin
InvalidatePreviews;
end;
if Sender = TextItalicCheckBox then
if TextItalicCheckBox.Checked then
if CurHighlightElementIsExtra
then TextStyleRadioOnChange(Sender)
else if TextItalicCheckBox.Checked then
begin
if not (fsItalic in CurHighlightElement.Style) then
begin
@ -2555,7 +2672,9 @@ begin
InvalidatePreviews;
end;
if Sender = TextUnderlineCheckBox then
if TextUnderlineCheckBox.Checked then
if CurHighlightElementIsExtra
then TextStyleRadioOnChange(Sender)
else if TextUnderlineCheckBox.Checked then
begin
if not (fsUnderline in CurHighlightElement.Style) then
begin
@ -2577,6 +2696,18 @@ begin
FindCurHighlightElement;
end;
procedure TEditorOptionsForm.DisplayPreviewStatusChange(Sender : TObject; Changes : TSynStatusChanges);
var
Syn: TSynEdit;
p: TPoint;
begin
p := EditorOpts.HighlighterList[CurLanguageID].CaretXY;
Syn := Sender as TSynEdit;
if (Syn.CaretX <> p.x)
or (Syn.Carety <> p.y)
then Syn.CaretXY:= p;
end;
procedure TEditorOptionsForm.chkCodeFoldingEnabledChange(Sender: TObject);
begin
lblDividerDrawLevel.Enabled := chkCodeFoldingEnabled.Checked;
@ -2856,12 +2987,15 @@ begin
SetComboBoxText(FileExtensionsComboBox,
GetCurFileExtensions(PreviewSyn.LanguageName));
for a := Low(PreviewEdits) to High(PreviewEdits) do
if a <> 3 then
if a <> 3 then begin
PreviewEdits[a].Lines.Text :=
EditorOpts.HighlighterList[CurLanguageID].SampleSource;
PreviewEdits[a].CaretXY := EditorOpts.HighlighterList[CurLanguageID].CaretXY;
end;
SetPreviewSynInAllPreviews;
FillColorElementListBox;
FindCurHighlightElement;
InvalidatePreviews;
end;
end// change language
// general
@ -2887,6 +3021,7 @@ end;
procedure TEditorOptionsForm.FindCurHighlightElement;
var
a, i: Integer;
h: TAdditionalHilightAttribute;
Old: TSynHighlightElement;
begin
Old := CurHighlightElement;
@ -2905,8 +3040,15 @@ begin
dec(i);
end;
end;
if Old <> CurHighlightElement then
if Old <> CurHighlightElement then begin
CurHighlightElementIsExtra := False;
for h := Low(TAdditionalHilightAttribute)
to high(TAdditionalHilightAttribute) do
if ColorElementListBox.Items[a] = AdditionalHighlightAttributes[h]
then CurHighlightElementIsExtra := true;
ShowCurAttribute;
end;
end;
procedure TEditorOptionsForm.InvalidatePreviews;
@ -2914,8 +3056,10 @@ var
a: Integer;
begin
for a := Low(PreviewEdits) to High(PreviewEdits) do
if PreviewEdits[a] <> Nil then
if PreviewEdits[a] <> Nil then begin
EditorOpts.SetMarkupColors(PreviewEdits[a].Highlighter, PreviewEdits[a]);
PreviewEdits[a].Invalidate;
end;
end;
procedure TEditorOptionsForm.SetPreviewSynInAllPreviews;
@ -2935,9 +3079,44 @@ begin
if (CurHighlightElement = nil) or UpdatingColor then
exit;
UpdatingColor := True;
TextBoldCheckBox.Checked := fsBold in CurHighlightElement.Style;
TextItalicCheckBox.Checked := fsItalic in CurHighlightElement.Style;
TextUnderlineCheckBox.Checked := fsUnderline in CurHighlightElement.Style;
TextBoldRadioPanel.Visible := CurHighlightElementIsExtra;
TextItalicRadioPanel.Visible := CurHighlightElementIsExtra;
TextUnderlineRadioPanel.Visible := CurHighlightElementIsExtra;
if CurHighlightElementIsExtra then begin
TextBoldCheckBox.Checked := (fsBold in CurHighlightElement.Style)
or (fsBold in CurHighlightElement.StyleMask);
TextBoldRadioPanel.Enabled := TextBoldCheckBox.Checked;
if not(fsBold in CurHighlightElement.StyleMask)
then TextBoldRadioInvert.Checked := True
else if fsBold in CurHighlightElement.Style
then TextBoldRadioOn.Checked := True
else TextBoldRadioOff.Checked := True;
TextItalicCheckBox.Checked := (fsItalic in CurHighlightElement.Style)
or (fsItalic in CurHighlightElement.StyleMask);
TextItalicRadioPanel.Enabled := TextItalicCheckBox.Checked;
if not(fsItalic in CurHighlightElement.StyleMask)
then TextItalicRadioInvert.Checked := True
else if fsItalic in CurHighlightElement.Style
then TextItalicRadioOn.Checked := True
else TextItalicRadioOff.Checked := True;
TextUnderlineCheckBox.Checked := (fsUnderline in CurHighlightElement.Style)
or (fsUnderline in CurHighlightElement.StyleMask);
TextUnderlineRadioPanel.Enabled := TextUnderlineCheckBox.Checked;
if not(fsUnderline in CurHighlightElement.StyleMask)
then TextUnderlineRadioInvert.Checked := True
else if fsUnderline in CurHighlightElement.Style
then TextUnderlineRadioOn.Checked := True
else TextUnderlineRadioOff.Checked := True;
end else begin
TextBoldCheckBox.Checked := fsBold in CurHighlightElement.Style;
TextItalicCheckBox.Checked := fsItalic in CurHighlightElement.Style;
TextUnderlineCheckBox.Checked := fsUnderline in CurHighlightElement.Style;
end;
if CurHighlightElement.Foreground = clNone then
ForeGroundUseDefaultCheckBox.Checked := True
else
@ -3084,6 +3263,7 @@ begin
end;
CurHighlightElement := Nil;
CurHighlightElementIsExtra := False;
if ColorElementListBox.Items.Count > 0 then
ColorElementListBox.Selected[0] := True;
FindCurHighlightElement;
@ -3127,7 +3307,7 @@ begin
end;
procedure TEditorOptionsForm.OnSpecialLineColors(Sender: TObject;
Line: Integer; var Special: Boolean; var FG, BG: TColor);
Line: Integer; var Special: boolean; aMarkup: TSynSelectedColor);
var
e: TSynHighlightElement;
AddAttr: TAdditionalHilightAttribute;
@ -3146,11 +3326,8 @@ begin
continue;
if e.Name = AdditionalHighlightAttributes[AddAttr] then
begin
Special := (e.ForeGround <> clNone) or (e.BackGround <> clNone);
if e.ForeGround <> clNone then
FG := e.ForeGround;
if e.BackGround <> clNone then
BG := e.BackGround;
Special := True;
EditorOpts.SetMarkupColor(PreviewSyn, AddAttr, aMarkup);
exit;
end;
dec(i);
@ -3715,10 +3892,19 @@ begin
TextAttributesGroupBox.Caption := dlgTextAttributes;
TextBoldCheckBox.Caption := dlgEdBold;
TextBoldRadioOn.Caption := dlgEdOn;
TextBoldRadioOff.Caption := dlgEdOff;
TextBoldRadioInvert.Caption := dlgEdInvert;
TextItalicCheckBox.Caption := dlgEdItal;
TextItalicRadioOn.Caption := dlgEdOn;
TextItalicRadioOff.Caption := dlgEdOff;
TextItalicRadioInvert.Caption := dlgEdInvert;
TextUnderlineCheckBox.Caption := dlgEdUnder;
TextUnderlineRadioOn.Caption := dlgEdOn;
TextUnderlineRadioOff.Caption := dlgEdOff;
TextUnderlineRadioInvert.Caption := dlgEdInvert;
end;
procedure TEditorOptionsForm.SetupCodeToolsPage(Page: Integer);
@ -3786,15 +3972,16 @@ begin
// save all values
EditorOpts.KeyMap.Assign(EditingKeyMap);
SynOptions := PreviewEdits[1].Options - [eoNoSelection, eoNoCaret];
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgBracHighlight) then
Include(SynOptions, eoBracketHighlight)
else
Exclude(SynOptions, eoBracketHighlight);
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgBracHighlight)
then Include(SynOptions, eoBracketHighlight)
else Exclude(SynOptions, eoBracketHighlight);
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgScrollPastEndLine)
then Include(SynOptions, eoScrollPastEol)
else Exclude(SynOptions, eoScrollPastEol);
PreviewEdits[1].Options := SynOptions;
EditorOpts.SetSynEditSettings(PreviewEdits[1]);
PreviewEdits[1].Options :=
SynOptions - [eoBracketHighlight] +
[eoNoCaret, eoNoSelection];
SynOptions - [eoScrollPastEol] + [eoNoCaret, eoNoSelection];
// general
EditorOpts.ShowTabCloseButtons :=
@ -3859,6 +4046,52 @@ begin
ModalResult := mrCancel;
end;
procedure TEditorOptionsForm.TextStyleRadioOnChange(Sender : TObject);
procedure CalcNewStyle(CheckBox: TCheckBox; RadioOn, RadioOff,
RadioInvert: TRadioButton; fs : TFontStyle;
Panel: TPanel);
begin
if CheckBox.Checked then begin
Panel.Enabled := True;
if RadioInvert.Checked then begin
CurHighlightElement.Style := CurHighlightElement.Style + [fs];
CurHighlightElement.StyleMask := CurHighlightElement.StyleMask - [fs];
end else if RadioOn.Checked then begin
CurHighlightElement.Style := CurHighlightElement.Style + [fs];
CurHighlightElement.StyleMask := CurHighlightElement.StyleMask + [fs];
end else if RadioOff.Checked then begin
CurHighlightElement.Style := CurHighlightElement.Style - [fs];
CurHighlightElement.StyleMask := CurHighlightElement.StyleMask + [fs];
end
end else begin
Panel.Enabled := False;
CurHighlightElement.Style := CurHighlightElement.Style - [fs];
CurHighlightElement.StyleMask := CurHighlightElement.StyleMask - [fs];
end;
end;
begin
if FormCreating then exit;
if UpdatingColor or not CurHighlightElementIsExtra then exit;
if (Sender = TextBoldCheckBox) or (Sender = TextBoldRadioOn)
or (Sender = TextBoldRadioOff) or (Sender = TextBoldRadioInvert)
then CalcNewStyle(TextBoldCheckBox, TextBoldRadioOn, TextBoldRadioOff,
TextBoldRadioInvert, fsBold, TextBoldRadioPanel);
if (Sender = TextItalicCheckBox) or (Sender = TextItalicRadioOn)
or (Sender = TextItalicRadioOff) or (Sender = TextItalicRadioInvert)
then CalcNewStyle(TextItalicCheckBox, TextItalicRadioOn, TextItalicRadioOff,
TextItalicRadioInvert, fsItalic, TextItalicRadioPanel);
if (Sender = TextUnderlineCheckBox) or (Sender = TextUnderlineRadioOn)
or (Sender = TextUnderlineRadioOff) or (Sender = TextUnderlineRadioInvert)
then CalcNewStyle(TextUnderlineCheckBox, TextUnderlineRadioOn, TextUnderlineRadioOff,
TextUnderlineRadioInvert, fsUnderline, TextUnderlineRadioPanel);
InvalidatePreviews;
end;
//=============================================================================
initialization

View File

@ -360,8 +360,7 @@ begin
begin
Lines.Text := EditorOpts.HighlighterList[CurLanguageID].SampleSource;
PreviewEdits[a].Options :=
PreviewEdits[a].Options + [eoNoCaret,
eoNoSelection];
PreviewEdits[a].Options - [eoScrollPastEol] + [eoNoCaret, eoNoSelection];
PreviewEdits[a].CaretXY := EditorOpts.HighlighterList[CurLanguageID].CaretXY;
end;
end;
@ -1811,14 +1810,16 @@ begin
// save all values
EditorOpts.KeyMap.Assign(EditingKeyMap);
SynOptions := PreviewEdits[1].Options - [eoNoSelection, eoNoCaret];
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgBracHighlight) then
Include(SynOptions, eoBracketHighlight)
else
Exclude(SynOptions, eoBracketHighlight);
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgBracHighlight)
then Include(SynOptions, eoBracketHighlight)
else Exclude(SynOptions, eoBracketHighlight);
if CheckGroupItemChecked(EditorOptionsGroupBox,dlgScrollPastEndLine)
then Include(SynOptions, eoScrollPastEol)
else Exclude(SynOptions, eoScrollPastEol);
PreviewEdits[1].Options := SynOptions;
EditorOpts.SetSynEditSettings(PreviewEdits[1]);
PreviewEdits[1].Options :=
SynOptions + [eoNoCaret, eoNoSelection];
SynOptions - [eoScrollPastEol] + [eoNoCaret, eoNoSelection];
// general
EditorOpts.ShowTabCloseButtons :=

View File

@ -1127,6 +1127,9 @@ resourcestring
dlgEdBold = 'Bold';
dlgEdItal = 'Italic';
dlgEdUnder = 'Underline';
dlgEdOn = 'On';
dlgEdOff = 'Off';
dlgEdInvert = 'Invert';
dlgEdIdComlet = 'Identifier completion';
dlgEdCodeParams = 'Code parameters';
dlgTooltipEval = 'Tooltip expression evaluation';

View File

@ -105,15 +105,12 @@ function ShowSortSelectionDialog(const TheText: string;
var SortedText: string): TModalResult;
var
SortSelectionDialog: TSortSelectionDialog;
FG, BG: TCOlor;
begin
SortSelectionDialog:=TSortSelectionDialog.Create(nil);
SortSelectionDialog.BeginUpdate;
SortSelectionDialog.TheText:=TheText;
SortSelectionDialog.PreviewSynEdit.Highlighter:=Highlighter;
EditorOpts.GetLineColors(Highlighter, ahaTextBlock, FG, BG);
SortSelectionDialog.PreviewSynEdit.SelectedColor.Foreground := FG;
SortSelectionDialog.PreviewSynEdit.SelectedColor.Background := BG;
EditorOpts.SetMarkupColor(Highlighter, ahaTextBlock, SortSelectionDialog.PreviewSynEdit.SelectedColor);
SortSelectionDialog.UpdatePreview;
SortSelectionDialog.EndUpdate;
Result:=SortSelectionDialog.ShowModal;

View File

@ -49,7 +49,7 @@ uses
CodeToolManager, CodeCache, SourceLog,
// synedit
SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter,
SynEditAutoComplete, SynEditKeyCmds, SynCompletion,
SynEditAutoComplete, SynEditKeyCmds, SynCompletion, SynEditMiscClasses,
// IDE interface
MacroIntf, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
IDEDialogs, IDEHelpIntf, IDEWindowIntf, IDEImagesIntf,
@ -189,7 +189,7 @@ type
procedure OnGutterClick(Sender: TObject; X, Y, Line: integer;
mark: TSynEditMark);
procedure OnEditorSpecialLineColor(Sender: TObject; Line: integer;
var Special: boolean; var FG, BG: TColor);
var Special: boolean; Markup: TSynSelectedColor);
function RefreshEditorSettings: Boolean;
procedure SetSyntaxHighlighterType(
ASyntaxHighlighterType: TLazSyntaxHighlighter);
@ -512,10 +512,6 @@ type
FActiveEditKeyBGColor: TColor;
FActiveEditSymbolFGColor: TColor;
FActiveEditSymbolBGColor: TColor;
FActiveEditIncSearchFGColor: TColor;
FActiveEditIncSearchBGColor: TColor;
FActiveEditHighAllSearchFGColor: TColor;
FActiveEditHighAllSearchBGColor: TColor;
// PopupMenu
procedure BuildPopupMenu;
@ -531,7 +527,6 @@ type
const NewOnClick: TNotifyEvent): TIDEMenuItem;
procedure UpdateActiveEditColors(AEditor: TSynEdit);
procedure SetSelectedColors(AEditor: TSynEdit);
procedure SetIncrementalSearchStr(const AValue: string);
procedure IncrementalSearch(ANext, ABackward: Boolean);
@ -2084,7 +2079,7 @@ begin
end;
procedure TSourceEditor.OnEditorSpecialLineColor(Sender: TObject; Line: integer;
var Special: boolean; var FG, BG: TColor);
var Special: boolean; Markup: TSynSelectedColor);
var
i:integer;
aha: TAdditionalHilightAttribute;
@ -2094,6 +2089,7 @@ var
CurBG: TColor;
begin
aha := ahaNone;
Special := False;
if ErrorLine = Line
then begin
@ -2115,8 +2111,8 @@ begin
CurFG:=CurMarks[i].LineColorForeGround;
CurBG:=CurMarks[i].LineColorBackGround;
if (CurFG<>clNone) or (CurBG<>clNone) then begin
FG:=CurFG;
BG:=CurBG;
Markup.Foreground := CurFG;
Markup.Background := CurBG;
Special:=true;
break;
end;
@ -2128,7 +2124,8 @@ begin
if aha <> ahaNone
then begin
Special := EditorOpts.GetLineColors(TCustomSynEdit(Sender).Highlighter, aha, FG, BG);
Special := True;
EditorOpts.SetMarkupColor(TCustomSynEdit(Sender).Highlighter, aha, Markup);
end;
end;
@ -2256,7 +2253,7 @@ Begin
OnCommandProcessed := @UserCommandProcessed;
OnReplaceText := @OnReplace;
OnGutterClick := @Self.OnGutterClick;
OnSpecialLineColors := @OnEditorSpecialLineColor;
OnSpecialLineMarkup := @OnEditorSpecialLineColor;
OnMouseMove := @EditorMouseMoved;
OnMouseWheel := @EditorMouseWheel;
OnMouseDown := @EditorMouseDown;
@ -4609,7 +4606,8 @@ begin
fIncrementalSearchStartPos:=TempEditor.EditorComponent.LogicalCaretXY;
FIncrementalSearchPos:=fIncrementalSearchStartPos;
FIncrementalSearchEditor := TempEditor;
SetSelectedColors(FIncrementalSearchEditor.EditorComponent);
if assigned(FIncrementalSearchEditor.EditorComponent)
then FIncrementalSearchEditor.EditorComponent.UseIncrementalColor:= true;
IncrementalSearchStr:='';
@ -4624,7 +4622,8 @@ begin
if FIncrementalSearchEditor <> nil
then begin
SetSelectedColors(FIncrementalSearchEditor.EditorComponent);
if assigned(FIncrementalSearchEditor.EditorComponent)
then FIncrementalSearchEditor.EditorComponent.UseIncrementalColor:= false;
FIncrementalSearchEditor.EditorComponent.SetHighlightSearch('', []);
FIncrementalSearchEditor := nil;
end;
@ -6428,22 +6427,18 @@ begin
end;
procedure TSourceNotebook.UpdateActiveEditColors(AEditor: TSynEdit);
var
s, sm : TFontStyles;
begin
if AEditor=nil then exit;
EditorOpts.SetMarkupColors(AEditor.Highlighter, AEditor);
FActiveEditDefaultFGColor:=AEditor.Font.Color;
FActiveEditDefaultBGColor:=AEditor.Color;
EditorOpts.GetLineColors(AEditor.Highlighter, ahaTextBlock,
FActiveEditSelectedFGColor, FActiveEditSelectedBGColor);
EditorOpts.GetLineColors(AEditor.Highlighter, ahaIncrementalSearch,
FActiveEditIncSearchFGColor, FActiveEditIncSearchBGColor);
EditorOpts.GetLineColors(AEditor.Highlighter, ahaHighlightAll,
FActiveEditHighAllSearchFGColor, FActiveEditHighAllSearchBGColor);
EditorOpts.GetLineColors(AEditor.Highlighter, ahaTextBlock, {TODO: MFR use AEditor.SelectedColor which includes styles / or have a copy}
FActiveEditSelectedFGColor, FActiveEditSelectedBGColor, s ,sm);
AEditor.HighlightAllColor.Background := FActiveEditHighAllSearchBGColor;
AEditor.HighlightAllColor.Foreground := FActiveEditHighAllSearchFGColor;
FActiveEditKeyFGColor:=FActiveEditDefaultFGColor;
FActiveEditKeyBGColor:=FActiveEditDefaultBGColor;
FActiveEditSymbolFGColor:=FActiveEditDefaultFGColor;
@ -6475,25 +6470,9 @@ begin
end;
end;
end;
SetSelectedColors(AEditor);
AEditor.UseIncrementalColor:= snIncrementalFind in States;
end;
procedure TSourceNotebook.SetSelectedColors(AEditor: TSynEdit);
begin
if AEditor = nil then Exit;
if snIncrementalFind in States
then begin
AEditor.SelectedColor.Background := FActiveEditIncSearchBGColor;
AEditor.SelectedColor.Foreground := FActiveEditIncSearchFGColor;
end
else begin
AEditor.SelectedColor.Background := FActiveEditSelectedBGColor;
AEditor.SelectedColor.Foreground := FActiveEditSelectedFGColor;
end;
end;
Procedure TSourceNotebook.GetSynEditPreviewSettings(APreviewEditor: TObject);
var ASynEdit: TSynEdit;
begin

View File

@ -292,6 +292,8 @@ function UTF8FindNearestCharStart(UTF8Str: PChar; Len: integer;
BytePos: integer): integer;
// find the n-th UTF8 character, ignoring BIDI
function UTF8CharStart(UTF8Str: PChar; Len, Index: integer): PChar;
// find the byte index of the n-th UTF8 character, ignoring BIDI (byte len of substr)
function UTF8CharToByteIndex(UTF8Str: PChar; Len, Index: integer): Integer;
procedure UTF8FixBroken(P: PChar);
function UTF8CharacterStrictLength(P: PChar): integer;
function UTF8CStringToUTF8String(SourceStart: PChar; SourceLen: SizeInt) : string;
@ -2456,6 +2458,16 @@ begin
end;
end;
function UTF8CharToByteIndex(UTF8Str : PChar; Len, Index : integer) : Integer;
var
p: PChar;
begin
p := UTF8CharStart(UTF8Str, Len, Index);
if p = nil
then Result := -1
else Result := p - UTF8Str;
end;
{ fix any broken UTF8 sequences with spaces }
procedure UTF8FixBroken(P: PChar);
begin