Browse Source

ADD: cm_ZoomIn / cm_ZoomOut in Editor

rich2014 2 months ago
parent
commit
0244357e5b
1 changed files with 44 additions and 0 deletions
  1. 44 0
      src/feditor.pas

+ 44 - 0
src/feditor.pas

@@ -177,6 +177,9 @@ type
     function SaveFile(const aFileName: String): Boolean;
     procedure SetFileName(const AValue: String);
 
+    procedure DoZoom( const inc: Integer );
+    function DoZoomIn: Boolean;
+    function DoZoomOut: Boolean;
   protected
     procedure CMThemeChanged(var Message: TLMessage); message CM_THEMECHANGED;
 
@@ -229,6 +232,8 @@ type
      procedure cm_FileExit(const {%H-}Params:array of string);
      procedure cm_ConfHigh(const {%H-}Params:array of string);
      procedure cm_EditRplc(const {%H-}Params:array of string);
+     procedure cm_ZoomIn(const {%H-}Params: array of string);
+     procedure cm_ZoomOut(const {%H-}Params: array of string);
   end;
 
   procedure ShowEditor(const sFileName: String; WaitData: TWaitData = nil);
@@ -600,6 +605,35 @@ begin
   Caption := ReplaceHome(FFileName);
 end;
 
+procedure TfrmEditor.DoZoom(const inc: Integer);
+var
+  t:integer;
+begin
+  t:=Editor.TopLine;
+  gFonts[dcfEditor].Size:=gFonts[dcfEditor].Size+inc;
+  FontOptionsToFont(gFonts[dcfEditor], Editor.Font);
+  Editor.TopLine:=t;
+  Editor.Refresh;
+end;
+
+function TfrmEditor.DoZoomIn: Boolean;
+begin
+  Result:= False;
+  if gFonts[dcfEditor].Size < gFonts[dcfEditor].MaxValue then begin
+    self.DoZoom( 1 );
+    Result:= True;
+  end;
+end;
+
+function TfrmEditor.DoZoomOut: Boolean;
+begin
+  Result:= False;
+  if gFonts[dcfEditor].Size > gFonts[dcfEditor].MinValue then begin
+    self.DoZoom( -1 );
+    Result:= True;
+  end;
+end;
+
 procedure TfrmEditor.CMThemeChanged(var Message: TLMessage);
 var
   Highlighter: TSynCustomHighlighter;
@@ -1071,6 +1105,16 @@ begin
   ShowSearchReplaceDialog(Self, Editor, cbChecked, FSearchOptions)
 end;
 
+procedure TfrmEditor.cm_ZoomIn(const Params: array of string);
+begin
+  self.DoZoomIn;
+end;
+
+procedure TfrmEditor.cm_ZoomOut(const Params: array of string);
+begin
+  self.DoZoomOut;
+end;
+
 procedure TfrmEditor.frmEditorClose(Sender: TObject;
   var CloseAction: TCloseAction);
 begin