Browse Source

ADD: Some options to internal editor

Alexander Koblov 9 years ago
parent
commit
b685c9e97f

+ 9 - 1
src/doublecmd.lpi

@@ -270,7 +270,7 @@ end;"/>
         <MinVersion Minor="3" Valid="True"/>
         <MinVersion Minor="3" Valid="True"/>
       </Item11>
       </Item11>
     </RequiredPackages>
     </RequiredPackages>
-    <Units Count="224">
+    <Units Count="225">
       <Unit0>
       <Unit0>
         <Filename Value="doublecmd.lpr"/>
         <Filename Value="doublecmd.lpr"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
@@ -1593,6 +1593,14 @@ end;"/>
         <ResourceBaseClass Value="Form"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="fDeleteDlg"/>
         <UnitName Value="fDeleteDlg"/>
       </Unit223>
       </Unit223>
+      <Unit224>
+        <Filename Value="frames\foptionstoolseditor.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="frmOptionsEditor"/>
+        <HasResources Value="True"/>
+        <ResourceBaseClass Value="Frame"/>
+        <UnitName Value="fOptionsToolsEditor"/>
+      </Unit224>
     </Units>
     </Units>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>

+ 1 - 0
src/feditor.pas

@@ -245,6 +245,7 @@ var
 begin
 begin
   InitPropStorage(Self);
   InitPropStorage(Self);
 
 
+  Editor.Options:= gEditorSynEditOptions;
   FontOptionsToFont(gFonts[dcfEditor], Editor.Font);
   FontOptionsToFont(gFonts[dcfEditor], Editor.Font);
 
 
 // update menu highlighting
 // update menu highlighting

+ 1 - 0
src/frames/foptionsframe.pas

@@ -138,6 +138,7 @@ uses
   fOptionsTerminal,
   fOptionsTerminal,
   fOptionsToolbar,
   fOptionsToolbar,
   fOptionsTools,
   fOptionsTools,
+  fOptionsToolsEditor,
   fOptionsToolsDiffer,
   fOptionsToolsDiffer,
   fOptionsEditorColors,
   fOptionsEditorColors,
   fOptionsToolTips,
   fOptionsToolTips,

+ 0 - 35
src/frames/foptionstools.pas

@@ -64,17 +64,6 @@ type
     class function GetTitle: String; override;
     class function GetTitle: String; override;
   end;
   end;
 
 
-  { TfrmOptionsEditor }
-
-  TfrmOptionsEditor = class(TfrmOptionsToolBase)
-  protected
-    procedure Init; override;
-  public
-    constructor Create(TheOwner: TComponent); override;
-    class function GetIconIndex: Integer; override;
-    class function GetTitle: String; override;
-  end;
-
 implementation
 implementation
 
 
 {$R *.lfm}
 {$R *.lfm}
@@ -181,29 +170,5 @@ begin
   gBookFontColor := cbFontColorViewerBook.Selected;
   gBookFontColor := cbFontColorViewerBook.Selected;
 end;
 end;
 
 
-{ TfrmOptionsEditor }
-
-procedure TfrmOptionsEditor.Init;
-begin
-  ExternalTool := etEditor;
-  inherited Init;
-end;
-
-constructor TfrmOptionsEditor.Create(TheOwner: TComponent);
-begin
-  inherited Create(TheOwner);
-  Name := 'frmOptionsEditor';
-end;
-
-class function TfrmOptionsEditor.GetIconIndex: Integer;
-begin
-  Result := 10;
-end;
-
-class function TfrmOptionsEditor.GetTitle: String;
-begin
-  Result := rsToolEditor;
-end;
-
 end.
 end.
 
 

+ 86 - 0
src/frames/foptionstoolseditor.lfm

@@ -0,0 +1,86 @@
+inherited frmOptionsEditor: TfrmOptionsEditor
+  Height = 513
+  Width = 586
+  ClientHeight = 513
+  ClientWidth = 586
+  DesignLeft = 384
+  DesignTop = 288
+  inherited edtToolsParameters: TEdit
+    Height = 20
+    Top = 108
+  end
+  inherited fneToolsPath: TFileNameEdit
+    Height = 20
+    Top = 60
+  end
+  inherited lblToolsPath: TLabel
+    Height = 14
+    Width = 173
+  end
+  inherited lblToolsParameters: TLabel
+    Height = 14
+    Top = 90
+    Width = 140
+  end
+  inherited cbToolsKeepTerminalOpen: TCheckBox
+    Top = 161
+    Width = 350
+  end
+  inherited cbToolsRunInTerminal: TCheckBox
+    Top = 140
+    Width = 144
+  end
+  inherited cbToolsUseExternalProgram: TCheckBox
+    Width = 160
+  end
+  inherited btnRelativeToolPath: TSpeedButton
+    Top = 60
+  end
+  object gbInternalEditor: TGroupBox[8]
+    AnchorSideLeft.Control = fneToolsPath
+    AnchorSideTop.Control = cbToolsKeepTerminalOpen
+    AnchorSideTop.Side = asrBottom
+    AnchorSideRight.Control = edtToolsParameters
+    AnchorSideRight.Side = asrBottom
+    Left = 8
+    Height = 54
+    Top = 192
+    Width = 571
+    Anchors = [akTop, akLeft, akRight]
+    AutoSize = True
+    BorderSpacing.Top = 12
+    BorderSpacing.Bottom = 10
+    Caption = 'Internal editor options'
+    ChildSizing.LeftRightSpacing = 6
+    ChildSizing.TopBottomSpacing = 6
+    ChildSizing.HorizontalSpacing = 12
+    ChildSizing.EnlargeHorizontal = crsScaleChilds
+    ChildSizing.Layout = cclLeftToRightThenTopToBottom
+    ChildSizing.ControlsPerLine = 2
+    ClientHeight = 36
+    ClientWidth = 567
+    TabOrder = 5
+    object chkScrollPastEndLine: TCheckBox
+      AnchorSideTop.Side = asrBottom
+      Left = 6
+      Height = 19
+      Top = 6
+      Width = 257
+      BorderSpacing.Left = 6
+      Caption = 'Caret past end of line'
+      TabOrder = 0
+    end
+    object chkShowSpecialChars: TCheckBox
+      Left = 275
+      Height = 19
+      Top = 6
+      Width = 286
+      Caption = 'Show special characters'
+      TabOrder = 1
+    end
+  end
+  inherited pmPathHelper: TPopupMenu[9]
+    left = 424
+    top = 8
+  end
+end

+ 3 - 0
src/frames/foptionstoolseditor.lrt

@@ -0,0 +1,3 @@
+TFRMOPTIONSEDITOR.GBINTERNALEDITOR.CAPTION=Internal editor options
+TFRMOPTIONSEDITOR.CHKSCROLLPASTENDLINE.CAPTION=Caret past end of line
+TFRMOPTIONSEDITOR.CHKSHOWSPECIALCHARS.CAPTION=Show special characters

+ 105 - 0
src/frames/foptionstoolseditor.pas

@@ -0,0 +1,105 @@
+{
+   Double Commander
+   -------------------------------------------------------------------------
+   Tools options page for the editor tool
+
+   Copyright (C) 2006-2016 Alexander Koblov ([email protected])
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+}
+
+unit fOptionsToolsEditor;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, StdCtrls, ExtCtrls, Dialogs,
+  Buttons, fOptionsFrame, fOptionsToolBase;
+
+type
+
+  { TfrmOptionsEditor }
+
+  TfrmOptionsEditor = class(TfrmOptionsToolBase)
+    chkShowSpecialChars: TCheckBox;
+    gbInternalEditor: TGroupBox;
+    chkScrollPastEndLine: TCheckBox;
+  protected
+    procedure Init; override;
+    procedure Load; override;
+    function Save: TOptionsEditorSaveFlags; override;
+  public
+    constructor Create(TheOwner: TComponent); override;
+    class function GetIconIndex: Integer; override;
+    class function GetTitle: String; override;
+  end;
+
+implementation
+
+{$R *.lfm}
+
+uses
+  SynEdit, uGlobs, uLng;
+
+{ TfrmOptionsEditor }
+
+procedure TfrmOptionsEditor.Init;
+begin
+  ExternalTool := etEditor;
+  inherited Init;
+end;
+
+procedure TfrmOptionsEditor.Load;
+begin
+  inherited Load;
+  chkScrollPastEndLine.Checked:= eoScrollPastEoL in gEditorSynEditOptions;
+  chkShowSpecialChars.Checked:= eoShowSpecialChars in gEditorSynEditOptions;
+end;
+
+function TfrmOptionsEditor.Save: TOptionsEditorSaveFlags;
+
+  procedure UpdateOptionFromBool(AValue: Boolean; AnOption: TSynEditorOption);
+  begin
+    if AValue then
+      gEditorSynEditOptions := gEditorSynEditOptions + [AnOption]
+    else
+      gEditorSynEditOptions := gEditorSynEditOptions - [AnOption];
+  end;
+
+begin
+  Result:= inherited Save;
+  UpdateOptionFromBool(chkScrollPastEndLine.Checked, eoScrollPastEoL);
+  UpdateOptionFromBool(chkShowSpecialChars.Checked, eoShowSpecialChars);
+end;
+
+constructor TfrmOptionsEditor.Create(TheOwner: TComponent);
+begin
+  inherited Create(TheOwner);
+  Name := 'frmOptionsEditor';
+end;
+
+class function TfrmOptionsEditor.GetIconIndex: Integer;
+begin
+  Result := 10;
+end;
+
+class function TfrmOptionsEditor.GetTitle: String;
+begin
+  Result := rsToolEditor;
+end;
+
+end.

+ 18 - 1
src/uglobs.pas

@@ -27,7 +27,7 @@ uses
   DCClassesUtf8, uMultiArc, uColumns, uHotkeyManager, uSearchTemplate,
   DCClassesUtf8, uMultiArc, uColumns, uHotkeyManager, uSearchTemplate,
   uFileSourceOperationOptions, uWFXModule, uWCXModule, uWDXModule, uwlxmodule,
   uFileSourceOperationOptions, uWFXModule, uWCXModule, uWDXModule, uwlxmodule,
   udsxmodule, DCXmlConfig, uInfoToolTip, fQuickSearch, uTypes, uClassesEx,
   udsxmodule, DCXmlConfig, uInfoToolTip, fQuickSearch, uTypes, uClassesEx,
-  uHotDir, uSpecialDir, uVariableMenuSupport;
+  uHotDir, uSpecialDir, uVariableMenuSupport, SynEdit;
 
 
 type
 type
   { Configuration options }
   { Configuration options }
@@ -432,6 +432,9 @@ var
   gBookFontColor: TColor;
   gBookFontColor: TColor;
   gTextPosition:PtrInt;
   gTextPosition:PtrInt;
 
 
+  { Editor }
+  gEditorSynEditOptions: TSynEditorOptions;
+
   {SyncDirs}
   {SyncDirs}
   gSyncDirsSubdirs,
   gSyncDirsSubdirs,
   gSyncDirsByContent,
   gSyncDirsByContent,
@@ -1377,6 +1380,9 @@ begin
   gTextPosition:= 0;
   gTextPosition:= 0;
   gViewerMode:= 0;
   gViewerMode:= 0;
 
 
+  { Editor }
+  gEditorSynEditOptions := SYNEDIT_DEFAULT_OPTIONS;
+
   {SyncDirs}
   {SyncDirs}
   gSyncDirsSubdirs := False;
   gSyncDirsSubdirs := False;
   gSyncDirsByContent := False;
   gSyncDirsByContent := False;
@@ -2464,6 +2470,13 @@ begin
       end;
       end;
     end;
     end;
 
 
+    { Editor }
+    Node := Root.FindNode('Editor');
+    if Assigned(Node) then
+    begin
+      gEditorSynEditOptions := TSynEditorOptions(GetValue(Node, 'SynEditOptions', Integer(gEditorSynEditOptions)));
+    end;
+
     { SyncDirs }
     { SyncDirs }
     Node := Root.FindNode('SyncDirs');
     Node := Root.FindNode('SyncDirs');
     if Assigned(Node) then
     if Assigned(Node) then
@@ -2847,6 +2860,10 @@ begin
     SetValue(Node, 'FontColor', gBookFontColor);
     SetValue(Node, 'FontColor', gBookFontColor);
     SetValue(Node, 'TextPosition', gTextPosition);
     SetValue(Node, 'TextPosition', gTextPosition);
 
 
+    { Editor }
+    Node := FindNode(Root, 'Editor',True);
+    SetValue(Node, 'SynEditOptions', Integer(gEditorSynEditOptions));
+
     { SyncDirs }
     { SyncDirs }
     Node := FindNode(Root, 'SyncDirs', True);
     Node := FindNode(Root, 'SyncDirs', True);
     SetValue(Node, 'Subdirs', gSyncDirsSubdirs);
     SetValue(Node, 'Subdirs', gSyncDirsSubdirs);