mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 15:56:08 +02:00
IDE: color settings for "plain text" and "none"
This commit is contained in:
parent
77365e62a1
commit
ac18b36c00
@ -399,6 +399,28 @@ type
|
||||
property ColorSchemeGroupAtPos[Index: Integer]: TColorScheme read GetColorSchemeGroupAtPos;
|
||||
end;
|
||||
|
||||
{ TIDESynTextSyn }
|
||||
|
||||
TIDESynTextSyn = class(TSynCustomHighlighter)
|
||||
private
|
||||
FLineText: String;
|
||||
// fTextAttri: TSynHighlighterAttributes;
|
||||
FPos: Integer;
|
||||
protected
|
||||
procedure SetLine(const NewValue: String; LineNumber: Integer); override;
|
||||
function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override;
|
||||
public
|
||||
class function GetLanguageName: string; override;
|
||||
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function GetEol: Boolean; override;
|
||||
function GetToken: string; override;
|
||||
procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;
|
||||
function GetTokenAttribute: TSynHighlighterAttributes; override;
|
||||
function GetTokenPos: Integer; override;
|
||||
procedure Next; override;
|
||||
end;
|
||||
|
||||
type
|
||||
|
||||
TEditorOptionsDividerInfo = record
|
||||
@ -695,7 +717,7 @@ const
|
||||
|
||||
LazSyntaxHighlighterClasses: array[TLazSyntaxHighlighter] of
|
||||
TCustomSynClass =
|
||||
(nil, nil, TIDESynFreePasSyn, TIDESynPasSyn, TSynLFMSyn, TSynXMLSyn,
|
||||
(nil, TIDESynTextSyn, TIDESynFreePasSyn, TIDESynPasSyn, TSynLFMSyn, TSynXMLSyn,
|
||||
TSynHTMLSyn, TSynCPPSyn, TSynPerlSyn, TSynJavaSyn, TSynUNIXShellScriptSyn,
|
||||
TSynPythonSyn, TSynPHPSyn, TSynSQLSyn,TSynCssSyn, TSynJScriptSyn, TSynDiffSyn,
|
||||
TSynBatSyn, TSynIniSyn, TSynPoSyn, TSynPikeSyn);
|
||||
@ -3405,6 +3427,23 @@ begin
|
||||
end;
|
||||
Add(NewInfo);
|
||||
|
||||
// create info for text
|
||||
NewInfo := TEditOptLanguageInfo.Create;
|
||||
NewInfo.TheType := lshText;
|
||||
NewInfo.DefaultCommentType := DefaultCommentTypes[NewInfo.TheType];
|
||||
NewInfo.SynClass := LazSyntaxHighlighterClasses[NewInfo.TheType];
|
||||
NewInfo.SetBothFilextensions('txt');
|
||||
NewInfo.SampleSource := 'Text in the source editor.'+#13#10+
|
||||
'Example line 2'+#13#10+
|
||||
'Example line 3'+#13#10+
|
||||
'Example line 4'+#13#10;
|
||||
with NewInfo do
|
||||
begin
|
||||
AddAttrSampleLines[ahaTextBlock] := 12;
|
||||
MappedAttributes := TStringList.Create;
|
||||
CaretXY := Point(1,1);
|
||||
end;
|
||||
Add(NewInfo);
|
||||
end;
|
||||
|
||||
destructor TEditOptLangList.Destroy;
|
||||
@ -5804,11 +5843,20 @@ end;
|
||||
procedure TEditorOptions.SetMarkupColors(aSynEd: TSynEdit);
|
||||
var
|
||||
Scheme: TColorSchemeLanguage;
|
||||
TmpHl: TIDESynTextSyn;
|
||||
begin
|
||||
// Find current color scheme for default colors
|
||||
if (aSynEd.Highlighter = nil) then begin
|
||||
aSynEd.Color := clWhite;
|
||||
aSynEd.Font.Color := clBlack;
|
||||
TmpHl := TIDESynTextSyn.Create(nil);
|
||||
Scheme := GetColorSchemeLanguage(TmpHl);
|
||||
if Assigned(Scheme) then begin
|
||||
Scheme.ApplyTo(aSynEd);
|
||||
end
|
||||
else begin
|
||||
aSynEd.Color := clWhite;
|
||||
aSynEd.Font.Color := clBlack;
|
||||
end;
|
||||
TmpHl.Free;
|
||||
exit;
|
||||
end;
|
||||
// get current colorscheme:
|
||||
@ -6113,7 +6161,9 @@ end;
|
||||
|
||||
function TEditorOptions.CreateSyn(LazSynHilighter: TLazSyntaxHighlighter): TSrcIDEHighlighter;
|
||||
begin
|
||||
if LazSyntaxHighlighterClasses[LazSynHilighter] <> Nil then
|
||||
if (LazSyntaxHighlighterClasses[LazSynHilighter] <> Nil) and
|
||||
not (LazSyntaxHighlighterClasses[LazSynHilighter] = TIDESynTextSyn)
|
||||
then
|
||||
begin
|
||||
Result := LazSyntaxHighlighterClasses[LazSynHilighter].Create(Nil);
|
||||
GetHighlighterSettings(Result);
|
||||
@ -7192,6 +7242,64 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TIDESynTextSyn }
|
||||
|
||||
procedure TIDESynTextSyn.SetLine(const NewValue: String; LineNumber: Integer);
|
||||
begin
|
||||
inherited SetLine(NewValue, LineNumber);
|
||||
FLineText := NewValue;
|
||||
FPos := 0;
|
||||
end;
|
||||
|
||||
function TIDESynTextSyn.GetDefaultAttribute(Index: integer
|
||||
): TSynHighlighterAttributes;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
class function TIDESynTextSyn.GetLanguageName: string;
|
||||
begin
|
||||
Result := 'Plain Text';
|
||||
end;
|
||||
|
||||
constructor TIDESynTextSyn.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fDefaultFilter := '';
|
||||
end;
|
||||
|
||||
function TIDESynTextSyn.GetEol: Boolean;
|
||||
begin
|
||||
Result := FPos > 0;
|
||||
end;
|
||||
|
||||
function TIDESynTextSyn.GetToken: string;
|
||||
begin
|
||||
Result := FLineText;
|
||||
end;
|
||||
|
||||
procedure TIDESynTextSyn.GetTokenEx(out TokenStart: PChar; out
|
||||
TokenLength: integer);
|
||||
begin
|
||||
TokenStart := PChar(FLineText);
|
||||
TokenLength := Length(FLineText);
|
||||
end;
|
||||
|
||||
function TIDESynTextSyn.GetTokenAttribute: TSynHighlighterAttributes;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TIDESynTextSyn.GetTokenPos: Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure TIDESynTextSyn.Next;
|
||||
begin
|
||||
inc(FPos);
|
||||
end;
|
||||
|
||||
{ TQuickStringlist }
|
||||
|
||||
function TQuickStringlist.DoCompareText(const s1, s2: string): PtrInt;
|
||||
|
@ -60,7 +60,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
end
|
||||
object ToolButton3: TToolButton
|
||||
Left = 107
|
||||
Height = 22
|
||||
Height = 8
|
||||
Top = 0
|
||||
Caption = 'ToolButton3'
|
||||
Style = tbsSeparator
|
||||
@ -125,6 +125,10 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
inherited MarkupFoldColorUseDefaultCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = SynColorAttrEditor1
|
||||
end
|
||||
inherited lblInfo: TLabel
|
||||
AnchorSideLeft.Control = SynColorAttrEditor1
|
||||
AnchorSideRight.Control = SynColorAttrEditor1
|
||||
end
|
||||
end
|
||||
object PriorityEditor: TPanel
|
||||
AnchorSideLeft.Control = pnlElementAttributes
|
||||
@ -173,6 +177,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
ShowButtons = False
|
||||
ShowLines = False
|
||||
ShowRoot = False
|
||||
ShowSeparators = False
|
||||
SortType = stData
|
||||
TabOrder = 0
|
||||
OnAdvancedCustomDrawItem = ColorElementTreeAdvancedCustomDrawItem
|
||||
@ -255,6 +260,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
ShowButtons = False
|
||||
ShowLines = False
|
||||
ShowRoot = False
|
||||
ShowSeparators = False
|
||||
SortType = stData
|
||||
TabOrder = 0
|
||||
OnAdvancedCustomDrawItem = ColorElementTreeAdvancedCustomDrawItem
|
||||
@ -337,6 +343,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
ShowButtons = False
|
||||
ShowLines = False
|
||||
ShowRoot = False
|
||||
ShowSeparators = False
|
||||
SortType = stData
|
||||
TabOrder = 0
|
||||
OnAdvancedCustomDrawItem = ColorElementTreeAdvancedCustomDrawItem
|
||||
@ -419,6 +426,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
ShowButtons = False
|
||||
ShowLines = False
|
||||
ShowRoot = False
|
||||
ShowSeparators = False
|
||||
SortType = stData
|
||||
TabOrder = 0
|
||||
OnAdvancedCustomDrawItem = ColorElementTreeAdvancedCustomDrawItem
|
||||
@ -569,6 +577,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
ScrollBars = ssAutoBoth
|
||||
ShowButtons = False
|
||||
ShowRoot = False
|
||||
ShowSeparators = False
|
||||
TabOrder = 0
|
||||
OnAdvancedCustomDrawItem = ColorElementTreeAdvancedCustomDrawItem
|
||||
OnChange = ColorElementTreeChange
|
||||
@ -601,7 +610,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
TabStop = False
|
||||
OnMouseUp = ColorPreviewMouseUp
|
||||
BookMarkOptions.Xoffset = 30
|
||||
Gutter.Width = 59
|
||||
Gutter.Width = 61
|
||||
Gutter.MouseActions = <
|
||||
item
|
||||
ClickCount = ccAny
|
||||
@ -1041,7 +1050,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
MouseActions = <>
|
||||
end
|
||||
object TSynGutterLineNumber
|
||||
Width = 19
|
||||
Width = 21
|
||||
MouseActions = <>
|
||||
MarkupInfo.Background = clBtnFace
|
||||
MarkupInfo.Foreground = clNone
|
||||
@ -1143,7 +1152,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
end
|
||||
object ToolButton2: TToolButton
|
||||
Left = 24
|
||||
Height = 22
|
||||
Height = 5
|
||||
Top = 0
|
||||
Caption = 'ToolButton2'
|
||||
Style = tbsDivider
|
||||
@ -1182,7 +1191,7 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
end
|
||||
object ToolButton5: TToolButton
|
||||
Left = 234
|
||||
Height = 22
|
||||
Height = 5
|
||||
Top = 0
|
||||
Caption = 'ToolButton5'
|
||||
Style = tbsDivider
|
||||
@ -1202,15 +1211,15 @@ object EditorColorOptionsFrame: TEditorColorOptionsFrame
|
||||
DefaultExt = '.xml'
|
||||
Filter = 'xml|*.xml'
|
||||
Options = [ofOverwritePrompt, ofPathMustExist, ofEnableSizing, ofViewDetail]
|
||||
left = 568
|
||||
top = 56
|
||||
Left = 568
|
||||
Top = 56
|
||||
end
|
||||
object LanguageMenu: TPopupMenu
|
||||
left = 568
|
||||
top = 104
|
||||
Left = 568
|
||||
Top = 104
|
||||
end
|
||||
object ColorSchemeMenu: TPopupMenu
|
||||
left = 568
|
||||
top = 160
|
||||
Left = 568
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
|
@ -1155,7 +1155,7 @@ begin
|
||||
|
||||
// Create Groups
|
||||
if not FIsEditingDefaults then
|
||||
ColorElementTree.Items.Add(nil, FCurrentHighlighter.LanguageName)
|
||||
ColorElementTree.Items.Add(nil, FCurrentHighlighter.LanguageName + ' ')
|
||||
else
|
||||
ColorElementTree.Items.Add(nil, AdditionalHighlightGroupNames[agnDefault]);
|
||||
for j := low(TAhaGroupName) to high(TAhaGroupName) do
|
||||
@ -1175,11 +1175,14 @@ begin
|
||||
ParentName := AdditionalHighlightGroupNames[agnDefault]
|
||||
else
|
||||
ParentName := FCurrentHighlighter.LanguageName;
|
||||
ParentNode := ColorElementTree.Items.GetFirstNode;
|
||||
end;
|
||||
else
|
||||
ParentName := AdditionalHighlightGroupNames[Attr.Group];
|
||||
begin
|
||||
ParentName := AdditionalHighlightGroupNames[Attr.Group];
|
||||
ParentNode := ColorElementTree.Items.FindTopLvlNode(ParentName);
|
||||
end;
|
||||
end;
|
||||
ParentNode := ColorElementTree.Items.FindTopLvlNode(ParentName);
|
||||
if ParentNode = nil then
|
||||
ParentNode := ColorElementTree.Items.Add(nil, ParentName);
|
||||
NewNode := ColorElementTree.Items.AddChild(ParentNode, COLOR_NODE_PREFIX + Attr.Caption^);
|
||||
|
Loading…
Reference in New Issue
Block a user