Permalink
Browse files

Support changing font size via mouse wheel in query editors. Closes #143

.
  • Loading branch information...
ansgarbecker committed Apr 12, 2018
1 parent bce886d commit 26e16b13a1c02209ac943143851628e3631992f4
Showing with 33 additions and 3 deletions.
  1. +1 −0 source/main.dfm
  2. +32 −3 source/main.pas
View
@@ -1310,6 +1310,7 @@ object MainForm: TMainForm
TabOrder = 0
OnDragDrop = SynMemoQueryDragDrop
OnDragOver = SynMemoQueryDragOver
OnMouseWheel = SynMemoQueryMouseWheel
Gutter.AutoSize = True
Gutter.Font.Charset = DEFAULT_CHARSET
Gutter.Font.Color = clGrayText
View
@@ -1008,6 +1008,8 @@ TMainForm = class(TForm)
procedure actGotoFilterExecute(Sender: TObject);
procedure actGotoTabNumberExecute(Sender: TObject);
procedure StatusBarClick(Sender: TObject);
procedure SynMemoQueryMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
private
// Executable file details
FAppVerMajor: Integer;
@@ -6193,6 +6195,31 @@ procedure TMainForm.SynMemoQueryDropFiles(Sender: TObject; X, Y: Integer;
end;
procedure TMainForm.SynMemoQueryMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
Editor: TSynEdit;
NewFontSize: Integer;
begin
// Change font size with MouseWheel
if KeyPressed(VK_CONTROL) then begin
Editor := TSynEdit(Sender);
NewFontSize := Editor.Font.Size;
if WheelDelta > 0 then
Inc(NewFontSize)
else
Dec(NewFontSize);
NewFontSize := Max(NewFontSize, 1);
AppSettings.ResetPath;
AppSettings.WriteInt(asFontSize, NewFontSize);
SetupSynEditors;
Handled := True;
end else begin
Handled := False;
end;
end;
procedure TMainForm.SynMemoQueryPaintTransient(Sender: TObject; Canvas: TCanvas; TransientType: TTransientType);
var
Editor : TSynEdit;
@@ -8750,9 +8777,9 @@ procedure TMainForm.AnyGridMouseWheel(Sender: TObject; Shift: TShiftState; Wheel
Node: PVirtualNode;
NewFontSize: Integer;
begin
// Advance to next or previous grid node on Shift+MouseWheel
VT := Sender as TVirtualStringTree;
if ssAlt in Shift then begin
// Advance to next or previous grid node on Shift+MouseWheel
if Assigned(VT.FocusedNode) then begin
if WheelDelta > 0 then
Node := VT.FocusedNode.PrevSibling
@@ -8764,11 +8791,12 @@ procedure TMainForm.AnyGridMouseWheel(Sender: TObject; Shift: TShiftState; Wheel
end;
end;
end else if KeyPressed(VK_CONTROL) then begin
// Change font size with MouseWheel
NewFontSize := VT.Font.Size;
if WheelDelta > 0 then
NewFontSize := NewFontSize + 1
Inc(NewFontSize)
else
NewFontSize := NewFontSize - 1;
Dec(NewFontSize);
NewFontSize := Max(NewFontSize, 1);
AppSettings.ResetPath;
AppSettings.WriteInt(asDataFontSize, NewFontSize);
@@ -10137,6 +10165,7 @@ procedure TMainForm.actNewQueryTabExecute(Sender: TObject);
QueryTab.Memo.OnDragDrop := SynMemoQuery.OnDragDrop;
QueryTab.Memo.OnDragOver := SynMemoQuery.OnDragOver;
QueryTab.Memo.OnDropFiles := SynMemoQuery.OnDropFiles;
QueryTab.Memo.OnMouseWheel := SynMemoQuery.OnMouseWheel;
QueryTab.Memo.OnReplaceText := SynMemoQuery.OnReplaceText;
QueryTab.Memo.OnStatusChange := SynMemoQuery.OnStatusChange;
QueryTab.Memo.OnPaintTransient := SynMemoQuery.OnPaintTransient;

0 comments on commit 26e16b1

Please sign in to comment.