1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
{
***************************************************************************
* *
* This source 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 code 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. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
}
unit editor_general_misc_options;
{$mode objfpc}{$H+}
{$IFDEF Windows}
{$IFnDEF WithoutWinIME}
{$DEFINE WinIME}
{$ENDIF}
{$ENDIF}
interface
uses
// LCL
StdCtrls, ExtCtrls, Spin,
// SynEdit
SynEditTextTrimmer, SynEditTypes,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, DividerBevel,
// IDE
EditorOptions, LazarusIDEStrConsts, editor_general_options;
type
{ TEditorGeneralMiscOptionsFrame }
TEditorGeneralMiscOptionsFrame = class(TAbstractIDEOptionsEditor)
DBRigthScroll: TDividerBevel;
DBLeftScroll: TDividerBevel;
EditorTrimSpaceTypeComboBox: TComboBox;
EditorOptionsGroupBox: TCheckGroup;
EditorTrimSpaceTypeLabel: TLabel;
lbLeftDist: TLabel;
lbLeftDistP: TLabel;
lbLeftAdd: TLabel;
lbLeftAddP: TLabel;
lbLeftAddMax: TLabel;
lbRightDist: TLabel;
lbRightDistP: TLabel;
lbRightAdd: TLabel;
lbRightAddP: TLabel;
lbRightAddMax: TLabel;
Panel1: TPanel;
Panel10: TPanel;
Panel11: TPanel;
Panel12: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel8: TPanel;
Panel9: TPanel;
edLeftDist: TSpinEdit;
edLeftDistP: TSpinEdit;
edLeftAdd: TSpinEdit;
edLeftAddP: TSpinEdit;
edLeftAddMax: TSpinEdit;
edRightDist: TSpinEdit;
edRightDistP: TSpinEdit;
edRightAdd: TSpinEdit;
edRightAddP: TSpinEdit;
edRightAddMax: TSpinEdit;
procedure EditorOptionsGroupBoxItemClick(Sender: TObject; {%H-}Index: integer);
private
FDialog: TAbstractOptionsEditorDialog;
function GeneralPage: TEditorGeneralOptionsFrame; inline;
public
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{$R *.lfm}
{ TEditorGeneralMiscOptionsFrame }
function TEditorGeneralMiscOptionsFrame.GetTitle: String;
begin
Result := dlgEdMisc;
end;
procedure TEditorGeneralMiscOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
FDialog := ADialog;
EditorOptionsGroupBox.Caption := dlgEditorOptions;
// Warning:
// Only append new items at the end of list.
// since revision 23597 the order of boxes is hardcoded in Read/WriteSettings
with EditorOptionsGroupBox do
begin
// visual effects
//Items.Add(dlgShowGutterHints); // unimplemented
Items.Add(lisShowSpecialCharacters); // 0
// spaces
Items.Add(dlgTrimTrailingSpaces); // 1
// copying
Items.Add(dlgFindTextatCursor); // 2
Items.Add(dlgCopyWordAtCursorOnCopyNone); // 3
Items.Add(dlgCopyPasteKeepFolds); // 4
Items.Add(dlgEditExportBackColor); // 5
Items.Add(dlgBookmarkSetScroll); // 6
{$IFDEF WinIME} // Keep last, or all subsequnt indexes will depend on it
Items.Add(dlgUseMinimumIme); // 7
{$ENDIF}
end;
EditorTrimSpaceTypeComboBox.Items.Add(dlgTrimSpaceTypeLeaveLine);
EditorTrimSpaceTypeComboBox.Items.Add(dlgTrimSpaceTypeEditLine);
EditorTrimSpaceTypeComboBox.Items.Add(dlgTrimSpaceTypeCaretMove);
EditorTrimSpaceTypeComboBox.Items.Add(dlgTrimSpaceTypePosOnly);
EditorTrimSpaceTypeLabel.Caption := dlgTrimSpaceTypeCaption;
DBLeftScroll.Caption := lisDynPkgAutoScrollOnDeletePa;
lbLeftDist.Caption := lisDynPkgTriggerOnMinCharsVis;
lbLeftDistP.Caption := lisDynPkgTriggerOnMinCharsOfW;
lbLeftAdd.Caption := lisDynPkgAmountToScrollIn;
lbLeftAddP.Caption := lisDynPkgAmountToScrollIn2;
lbLeftAddMax.Caption := lisDynPkgAmountToScrollInMax;
DBRigthScroll.Caption := lisDynPkgAutoScrollOnTypePast;
lbRightDist.Caption := lisDynPkgTriggerOnMinCharsVis;
lbRightDistP.Caption := lisDynPkgTriggerOnMinCharsOfW;
lbRightAdd.Caption := lisDynPkgAmountToScrollIn;
lbRightAddP.Caption := lisDynPkgAmountToScrollIn2;
lbRightAddMax.Caption := lisDynPkgAmountToScrollInMax;
end;
procedure TEditorGeneralMiscOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
begin
with AOptions as TEditorOptions do
begin
with EditorOptionsGroupBox do
begin
Checked[0] := eoShowSpecialChars in SynEditOptions;
Checked[1] := eoTrimTrailingSpaces in SynEditOptions;
//Checked[Items.IndexOf(dlgShowGutterHints)] := ShowGutterHints;
Checked[2] := FindTextAtCursor;
Checked[3] := CopyWordAtCursorOnCopyNone;
Checked[4] := eoFoldedCopyPaste in SynEditOptions2;
Checked[5] := ExportHtmlWithBackground;
Checked[6] := eoBookmarkRestoresScroll in SynEditOptions2;
{$IFDEF WinIME}
Checked[7] := UseMinimumIme;
{$ENDIF}
with ScrollOnEditLeftOptions do begin
edLeftDist.Value := KeepBorderDistance;
edLeftDistP.Value := KeepBorderDistancePercent;
edLeftAdd.Value := ScrollExtraColumns;
edLeftAddP.Value := ScrollExtraPercent;
edLeftAddMax.Value := ScrollExtraMax;
end;
with ScrollOnEditRightOptions do begin
edRightDist.Value := KeepBorderDistance;
edRightDistP.Value := KeepBorderDistancePercent;
edRightAdd.Value := ScrollExtraColumns;
edRightAddP.Value := ScrollExtraPercent;
edRightAddMax.Value := ScrollExtraMax;
end;
end;
EditorTrimSpaceTypeComboBox.ItemIndex := ord(TrimSpaceType);
end;
end;
{
function CheckGroupItemChecked(CheckGroup: TCheckGroup; const Caption: string): Boolean;
begin
Result := CheckGroup.Checked[CheckGroup.Items.IndexOf(Caption)];
end;
}
procedure TEditorGeneralMiscOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
procedure UpdateOptionFromBool(AValue: Boolean; AnOption: TSynEditorOption); overload;
begin
if AValue then
TEditorOptions(AOptions).SynEditOptions := TEditorOptions(AOptions).SynEditOptions + [AnOption]
else
TEditorOptions(AOptions).SynEditOptions := TEditorOptions(AOptions).SynEditOptions - [AnOption];
end;
begin
with AOptions as TEditorOptions do
begin
UpdateOptionFromBool(EditorOptionsGroupBox.Checked[0], eoShowSpecialChars);
UpdateOptionFromBool(EditorOptionsGroupBox.Checked[1], eoTrimTrailingSpaces);
//ShowGutterHints := CheckGroupItemChecked(EditorOptionsGroupBox, dlgShowGutterHints);
FindTextAtCursor := EditorOptionsGroupBox.Checked[2];
CopyWordAtCursorOnCopyNone := EditorOptionsGroupBox.Checked[3];
if EditorOptionsGroupBox.Checked[4] then
SynEditOptions2 := SynEditOptions2 + [eoFoldedCopyPaste]
else
SynEditOptions2 := SynEditOptions2 - [eoFoldedCopyPaste];
TrimSpaceType := TSynEditStringTrimmingType(EditorTrimSpaceTypeComboBox.ItemIndex);
ExportHtmlWithBackground := EditorOptionsGroupBox.Checked[5];
if EditorOptionsGroupBox.Checked[6] then
SynEditOptions2 := SynEditOptions2 + [eoBookmarkRestoresScroll]
else
SynEditOptions2 := SynEditOptions2 - [eoBookmarkRestoresScroll];
{$IFDEF WinIME}
UseMinimumIme := EditorOptionsGroupBox.Checked[7];
{$ENDIF}
with ScrollOnEditLeftOptions do begin
KeepBorderDistance := edLeftDist.Value;
KeepBorderDistancePercent := edLeftDistP.Value;
ScrollExtraColumns := edLeftAdd.Value;
ScrollExtraPercent := edLeftAddP.Value;
ScrollExtraMax := edLeftAddMax.Value;
end;
with ScrollOnEditRightOptions do begin
KeepBorderDistance := edRightDist.Value;
KeepBorderDistancePercent := edRightDistP.Value;
ScrollExtraColumns := edRightAdd.Value;
ScrollExtraPercent := edRightAddP.Value;
ScrollExtraMax := edRightAddMax.Value;
end;
end;
end;
class function TEditorGeneralMiscOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TEditorOptions;
end;
procedure TEditorGeneralMiscOptionsFrame.EditorOptionsGroupBoxItemClick(
Sender: TObject; Index: integer);
procedure SetOption(const CheckBoxName: String; AnOption: TSynEditorOption);
var
i: LongInt;
a: Integer;
begin
i := EditorOptionsGroupBox.Items.IndexOf(CheckBoxName);
if i < 0 then
Exit;
with GeneralPage do
for a := Low(PreviewEdits) to High(PreviewEdits) do
begin
if PreviewEdits[a] <> nil then
if EditorOptionsGroupBox.Checked[i] then
PreviewEdits[a].Options := PreviewEdits[a].Options + [AnOption]
else
PreviewEdits[a].Options := PreviewEdits[a].Options - [AnOption];
end;
end;
begin
SetOption(lisShowSpecialCharacters, eoShowSpecialChars);
SetOption(dlgTrimTrailingSpaces, eoTrimTrailingSpaces);
end;
function TEditorGeneralMiscOptionsFrame.GeneralPage: TEditorGeneralOptionsFrame;
inline;
begin
Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
end;
initialization
RegisterIDEOptionsEditor(GroupEditor, TEditorGeneralMiscOptionsFrame, EdtOptionsGeneralMisc, EdtOptionsGeneral);
end.
|