IDE, Options: Font for editor notebook tabs

This commit is contained in:
Martin 2022-03-09 17:22:32 +01:00
parent afd2efa96b
commit 8344427500
5 changed files with 231 additions and 33 deletions

View File

@ -1401,6 +1401,9 @@ type
TEditorOptionsBase = class(TIDEEditorOptions)
private
FTabFont: String;
FTabFontDisableAntialiasing: Boolean;
FTabFontSize: Integer;
{$IFDEF WinIME}
FUseMinimumIme: Boolean;
{$ENDIF}
@ -1506,6 +1509,10 @@ type
read fMiddleTabClickClosesToRightModifier write fMiddleTabClickClosesToRightModifier default [];
property ShowFileNameInCaption: Boolean
read fShowFileNameInCaption write fShowFileNameInCaption default False;
property TabFont: String read FTabFont write FTabFont;
property TabFontSize: Integer read FTabFontSize write FTabFontSize;
property TabFontDisableAntialiasing: Boolean read FTabFontDisableAntialiasing
write FTabFontDisableAntialiasing default DefaultEditorDisableAntiAliasing;
// Comment Continue
property AnsiCommentContinueEnabled: Boolean
read FAnsiCommentContinueEnabled write FAnsiCommentContinueEnabled;
@ -1670,6 +1677,7 @@ type
aMarkup: TSynSelectedColor);
procedure SetMarkupColors(aSynEd: TSynEdit);
procedure ApplyFontSettingsTo(ASynEdit: TSynEdit);
procedure ApplyTabFontSettingsTo(APageCtrl: TPageControl);
function ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter; override;
public
// general options
@ -4721,6 +4729,9 @@ begin
fMiddleTabClickClosesOthersModifier := [ssCtrl];
fMiddleTabClickClosesToRightModifier := [];
fShowFileNameInCaption := False;
TabFont := '';
TabFontSize := 0;
TabFontDisableAntialiasing := DefaultEditorDisableAntiAliasing;
// Comment
FAnsiCommentContinueEnabled := False;
FAnsiCommentMatch := '^\s?(\*)';
@ -4903,6 +4914,7 @@ begin
FileVersion:=XMLConfig.GetValue('EditorOptions/Version', EditorOptsFormatVersion);
XMLConfig.ReadObject('EditorOptions/Misc/', Self, FDefaultValues);
RepairEditorFontSize(FTabFontSize);
// general options
DefOpts := SynEditDefaultOptions;
@ -5796,6 +5808,25 @@ begin
ASynEdit.Font.Quality := fqDefault;
end;
procedure TEditorOptions.ApplyTabFontSettingsTo(APageCtrl: TPageControl);
begin
if FTabFont <> '' then begin
if FTabFontSize < 0 then
APageCtrl.Font.Height := -FTabFontSize
else
APageCtrl.Font.Size := FTabFontSize;
APageCtrl.Font.Name := FTabFont;
end
else begin
APageCtrl.Font.Size := 0;
APageCtrl.Font.Name := 'default';
end;
if FTabFontDisableAntialiasing then
APageCtrl.Font.Quality := fqNonAntialiased
else
APageCtrl.Font.Quality := fqDefault;
end;
function TEditorOptions.ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter;
var
s, CurExt: String;

View File

@ -21,15 +21,15 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 138
Top = 277
Height = 67
Top = 348
Width = 509
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BevelOuter = bvNone
ClientHeight = 138
ClientHeight = 67
ClientWidth = 509
TabOrder = 0
object listAccessType: TCheckListBox
@ -52,7 +52,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
object Panel2: TPanel
Left = 0
Height = 50
Top = 138
Top = 67
Width = 509
Align = alClient
BevelOuter = bvNone
@ -67,7 +67,6 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Width = 509
Align = alTop
Caption = 'lblAccessTypeDesc'
ParentColor = False
WordWrap = True
end
end
@ -75,7 +74,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Cursor = crVSplit
Left = 0
Height = 5
Top = 138
Top = 67
Width = 509
Align = alTop
ResizeAnchor = akTop
@ -89,7 +88,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 3
Top = 170
Top = 241
Width = 60
BorderSpacing.Bottom = 6
end
@ -100,13 +99,12 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 70
Height = 15
Top = 164
Top = 235
Width = 166
BorderSpacing.Left = 10
BorderSpacing.Bottom = 6
Caption = 'lblEditActivationOrderSection'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object Bevel1: TBevel
@ -118,7 +116,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 246
Height = 3
Top = 170
Top = 241
Width = 275
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 10
@ -131,7 +129,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 6
Height = 65
Top = 185
Top = 256
Width = 509
Anchors = [akTop, akLeft, akRight]
AutoSize = True
@ -150,7 +148,6 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Align = alTop
BorderSpacing.Bottom = 6
Caption = 'lblAccessOrder'
ParentColor = False
WordWrap = True
end
object radioAccessOrderEdit: TRadioButton
@ -195,11 +192,10 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 15
Top = 256
Top = 327
Width = 521
Anchors = [akTop, akLeft, akRight]
Caption = 'lblAccessType'
ParentColor = False
end
object Bevel2a: TBevel
AnchorSideLeft.Control = Owner
@ -225,7 +221,6 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
BorderSpacing.Bottom = 6
Caption = 'lblMultiWinTabSection'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object Bevel2: TBevel
@ -249,7 +244,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 137
Height = 208
Top = 21
Width = 509
Anchors = [akTop, akLeft, akRight]
@ -259,7 +254,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
BorderSpacing.Bottom = 6
BevelOuter = bvNone
ChildSizing.ControlsPerLine = 2
ClientHeight = 137
ClientHeight = 208
ClientWidth = 509
TabOrder = 2
object chkShowCloseBtn: TCheckBox
@ -268,7 +263,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 0
Height = 19
Top = 0
Width = 115
Width = 113
BorderSpacing.CellAlignHorizontal = ccaLeftTop
BorderSpacing.CellAlignVertical = ccaLeftTop
Caption = 'chkShowCloseBtn'
@ -281,7 +276,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 255
Height = 19
Top = 0
Width = 117
Width = 115
BorderSpacing.CellAlignHorizontal = ccaLeftTop
BorderSpacing.CellAlignVertical = ccaLeftTop
Caption = 'chkShowNumbers'
@ -295,7 +290,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 0
Height = 19
Top = 19
Width = 116
Width = 113
BorderSpacing.CellAlignHorizontal = ccaLeftTop
BorderSpacing.CellAlignVertical = ccaLeftTop
Caption = 'chkHideSingleTab'
@ -309,7 +304,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 255
Height = 19
Top = 19
Width = 116
Width = 113
BorderSpacing.CellAlignHorizontal = ccaLeftTop
BorderSpacing.CellAlignVertical = ccaLeftTop
Caption = 'chkUseTabHistory'
@ -323,7 +318,6 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Height = 1
Top = 0
Width = 1
ParentColor = False
end
object chkMultiLine: TCheckBox
AnchorSideLeft.Control = CenterLabel
@ -333,7 +327,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 255
Height = 19
Top = 38
Width = 89
Width = 87
Caption = 'chkMultiLine'
TabOrder = 4
end
@ -344,17 +338,16 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 6
Height = 15
Top = 64
Width = 121
Width = 120
BorderSpacing.Left = 6
Caption = 'EditorTabPositionLabel'
ParentColor = False
end
object EditorTabPositionCheckBox: TComboBox
AnchorSideLeft.Control = EditorTabPositionLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkShowFileNameInCaption
AnchorSideTop.Side = asrBottom
Left = 132
Left = 131
Height = 23
Top = 60
Width = 150
@ -371,7 +364,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 0
Height = 19
Top = 38
Width = 170
Width = 168
BorderSpacing.CellAlignHorizontal = ccaLeftTop
BorderSpacing.CellAlignVertical = ccaLeftTop
Caption = 'chkShowFileNameInCaption'
@ -384,7 +377,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 5
Height = 51
Top = 86
Width = 134
Width = 128
AutoFill = True
AutoSize = True
BorderSpacing.Left = 5
@ -399,7 +392,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 31
ClientWidth = 130
ClientWidth = 124
Columns = 3
Items.Strings = (
'Shift'
@ -418,7 +411,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Left = 260
Height = 51
Top = 86
Width = 134
Width = 128
AutoFill = True
AutoSize = True
BorderSpacing.Left = 5
@ -433,7 +426,7 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 31
ClientWidth = 130
ClientWidth = 124
Columns = 3
Items.Strings = (
'Shift'
@ -445,5 +438,83 @@ object EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
03000000020202
}
end
object TabFontGroupBox: TGroupBox
AnchorSideLeft.Control = pnlNBTabs
AnchorSideTop.Control = cgCloseRight
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlNBTabs
AnchorSideRight.Side = asrBottom
Left = 0
Height = 68
Top = 140
Width = 509
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 3
Caption = 'TabFontGroupBox'
ClientHeight = 48
ClientWidth = 505
TabOrder = 9
object TabFontSizeSpinEdit: TSpinEdit
AnchorSideLeft.Control = TabFontGroupBox
AnchorSideTop.Control = TabFontComboBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = TabFontGroupBox
AnchorSideRight.Side = asrBottom
Left = 445
Height = 23
Top = 3
Width = 60
Anchors = [akTop, akRight]
MinValue = -100
OnChange = TabFontSizeSpinEditChange
TabOrder = 0
end
object DisableAntialiasingCheckBox: TCheckBox
AnchorSideLeft.Control = TabFontGroupBox
AnchorSideTop.Control = TabFontComboBox
AnchorSideTop.Side = asrBottom
Left = 0
Height = 19
Top = 29
Width = 171
BorderSpacing.Top = 3
Caption = 'DisableAntialiasingCheckBox'
TabOrder = 1
end
object TabFontComboBox: TComboBox
AnchorSideLeft.Control = TabFontGroupBox
AnchorSideTop.Control = TabFontGroupBox
AnchorSideRight.Control = TabFontButton
Left = 0
Height = 23
Top = 3
Width = 415
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
BorderSpacing.Right = 1
ItemHeight = 15
OnChange = TabFontComboBoxChange
TabOrder = 2
Text = 'TabFontComboBox'
end
object TabFontButton: TButton
AnchorSideLeft.Control = TabFontSizeSpinEdit
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = TabFontComboBox
AnchorSideRight.Control = TabFontSizeSpinEdit
AnchorSideBottom.Control = TabFontComboBox
AnchorSideBottom.Side = asrBottom
Left = 416
Height = 23
Top = 3
Width = 23
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 6
Caption = '...'
OnClick = TabFontButtonClick
TabOrder = 3
end
end
end
end

View File

@ -27,9 +27,9 @@ interface
uses
Classes, SysUtils,
// LCL
LCLType, StdCtrls, ExtCtrls, CheckLst, ComCtrls,
LCLType, StdCtrls, ExtCtrls, CheckLst, ComCtrls, Dialogs, Spin, Controls,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf,
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils,
// IDE
EditorOptions, LazarusIDEStrConsts, SourceEditor;
@ -51,6 +51,11 @@ type
chkShowCloseBtn: TCheckBox;
chkShowNumbers: TCheckBox;
chkHideSingleTab: TCheckBox;
DisableAntialiasingCheckBox: TCheckBox;
TabFontButton: TButton;
TabFontComboBox: TComboBox;
TabFontGroupBox: TGroupBox;
TabFontSizeSpinEdit: TSpinEdit;
EditorTabPositionCheckBox: TComboBox;
EditorTabPositionLabel: TLabel;
lblAccessTypeDesc: TLabel;
@ -69,6 +74,10 @@ type
procedure listAccessTypeClickCheck(Sender: TObject);
procedure listAccessTypeKeyUp(Sender: TObject; var {%H-}Key: Word; {%H-}Shift: TShiftState);
procedure radioAccessOrderEditChange(Sender: TObject);
procedure TabFontButtonClick(Sender: TObject);
procedure TabFontComboBoxChange(Sender: TObject);
procedure TabFontSizeSpinEditChange(Sender: TObject);
procedure SetTabFontSizeSpinEditValue(FontSize: Integer);
private
FMultiWinEditAccessOrder: TEditorOptionsEditAccessOrderList;
public
@ -113,6 +122,80 @@ begin
FMultiWinEditAccessOrder.SearchOrder := eoeaOrderByWindowFocus;
end;
procedure TEditorMultiWindowOptionsFrame.TabFontButtonClick(Sender: TObject);
var
FontDialog: TFontDialog;
fs: Integer;
begin
FontDialog := TFontDialog.Create(nil);
try
with FontDialog do
begin
Font.Name := TabFontComboBox.Text;
if TabFontSizeSpinEdit.Value < 0 then
Font.Height := -TabFontSizeSpinEdit.Value
else
Font.Size := TabFontSizeSpinEdit.Value;
if Execute then begin
SetComboBoxText(TabFontComboBox, Font.Name, cstCaseInsensitive);
fs := Font.Size;
RepairEditorFontSize(fs);
SetTabFontSizeSpinEditValue(fs);
end;
end;
finally
FontDialog.Free;
end;
end;
procedure TEditorMultiWindowOptionsFrame.TabFontComboBoxChange(Sender: TObject);
begin
TabFontSizeSpinEdit.Enabled := TabFontComboBox.Text <> '';
DisableAntialiasingCheckBox.Enabled := TabFontComboBox.Text <> '';
end;
procedure TEditorMultiWindowOptionsFrame.TabFontSizeSpinEditChange(
Sender: TObject);
var
s: TCaption;
begin
s := TabFontSizeSpinEdit.Text;
if copy(trim(s),1,1) = '-' then begin
if TabFontSizeSpinEdit.MinValue > 0 then begin
TabFontSizeSpinEdit.MinValue := -100;
TabFontSizeSpinEdit.MaxValue := -EditorOptionsMinimumFontSize;
TabFontSizeSpinEdit.Text := s;
end
else
if TabFontSizeSpinEdit.Value > -EditorOptionsMinimumFontSize then
TabFontSizeSpinEdit.Value := -EditorOptionsMinimumFontSize;
end
else begin
if TabFontSizeSpinEdit.MinValue < 0 then begin
TabFontSizeSpinEdit.MaxValue := 100;
TabFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
TabFontSizeSpinEdit.Text := s;
end
else
if TabFontSizeSpinEdit.Value < EditorOptionsMinimumFontSize then
TabFontSizeSpinEdit.Value := EditorOptionsMinimumFontSize;
end;
end;
procedure TEditorMultiWindowOptionsFrame.SetTabFontSizeSpinEditValue(
FontSize: Integer);
begin
if FontSize < 0 then begin
TabFontSizeSpinEdit.MinValue := -100;
TabFontSizeSpinEdit.MaxValue := -EditorOptionsMinimumFontSize;
end
else begin
TabFontSizeSpinEdit.MaxValue := 100;
TabFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
end;
TabFontSizeSpinEdit.Value := FontSize;
end;
constructor TEditorMultiWindowOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@ -156,6 +239,8 @@ begin
EditorTabPositionCheckBox.Items.Add(lisNotebookTabPosLeft);
EditorTabPositionCheckBox.Items.Add(lisNotebookTabPosRight);
EditorTabPositionLabel.Caption := dlgNotebookTabPos;
TabFontGroupBox.Caption := dlgDefaultTabFont;
DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
cgCloseOther.Caption := dlgMiddleTabCloseOtherPagesMod;
cgCloseRight.Caption := dlgMiddleTabCloseRightPagesMod;
end;
@ -181,6 +266,10 @@ begin
chkShowFileNameInCaption.Checked := ShowFileNameInCaption;
chkMultiLine.Checked := MultiLineTab;
EditorTabPositionCheckBox.ItemIndex := TabPosToIndex[TabPosition];
SetComboBoxText(TabFontComboBox, TabFont, cstCaseInsensitive);
SetTabFontSizeSpinEditValue(TabFontSize);
DisableAntialiasingCheckBox.Checked := TabFontDisableAntialiasing;
end;
FMultiWinEditAccessOrder.Assign(TEditorOptions(AOptions).MultiWinEditAccessOrder);
@ -219,6 +308,10 @@ begin
ShowFileNameInCaption := chkShowFileNameInCaption.Checked;
MultiLineTab := chkMultiLine.Checked;
TabPosition := TabIndexToPos[EditorTabPositionCheckBox.ItemIndex];
TabFont := TabFontComboBox.Text;
TabFontSize := TabFontSizeSpinEdit.Value;
TabFontDisableAntialiasing := DisableAntialiasingCheckBox.Checked;
end;
end;

View File

@ -1952,6 +1952,7 @@ resourcestring
dlgGutterColor = 'Gutter Color';
dlgDefaultEditorFont='Default editor font';
dlgEditorFontSize = 'Editor font size';
dlgDefaultTabFont='Default tab font';
dlgExtraCharSpacing = 'Extra character spacing';
dlgExtraLineSpacing = 'Extra line spacing';
dlgDisableAntialiasing = 'Disable anti-aliasing';

View File

@ -6662,6 +6662,7 @@ Begin
{$IFDEF IDE_DEBUG}
debugln('[TSourceNotebook.CreateNotebook] C');
{$ENDIF}
EditorOpts.ApplyTabFontSettingsTo(FNotebook);
Align := alClient;
APage:=TTabSheet.Create(FNotebook);
APage.Caption:='unit1';
@ -9084,6 +9085,7 @@ Begin
FNotebook.TabPosition := EditorOpts.TabPosition
else
FNotebook.TabPosition := tpTop;
EditorOpts.ApplyTabFontSettingsTo(FNotebook);
Exclude(States,snWarnedFont);
CheckFont;