SourceEditor, IDE: added configuration for Multi-Window

git-svn-id: trunk@24807 -
This commit is contained in:
martin 2010-04-21 23:55:49 +00:00
parent 4661ccf52b
commit e66ef81168
9 changed files with 977 additions and 41 deletions

2
.gitattributes vendored
View File

@ -3433,6 +3433,8 @@ ide/frames/editor_mouseaction_options.lfm svneol=native#text/plain
ide/frames/editor_mouseaction_options.pas svneol=native#text/pascal
ide/frames/editor_mouseaction_options_advanced.lfm svneol=native#text/plain
ide/frames/editor_mouseaction_options_advanced.pas svneol=native#text/pascal
ide/frames/editor_multiwindow_options.lfm svneol=native#text/plain
ide/frames/editor_multiwindow_options.pas svneol=native#text/pascal
ide/frames/files_options.lfm svneol=native#text/plain
ide/frames/files_options.pas svneol=native#text/pascal
ide/frames/formed_options.lfm svneol=native#text/plain

View File

@ -891,6 +891,168 @@ type
DefObject: TPersistent= nil; OnlyProperty: String= '');
end;
TEditorOptionsEditAccessInViewState =
(eoeaIgnoreInView, // Find any editor
eoeaInViewOnly, // Only editors, with the jump-target in their current visible area
eoeaInViewSoftCenterOnly // Only editors, with the jump-target in their current visible soft center (exclude up to 5 lines top/bottom)
);
TEditorOptionsEditAccessLockedState =
(eoeaIgnoreLock, // Find any editor
eoeaLockedOnly, // Only use locked Editor (e.g for InView = eoeaInViewOnly)
eoeaUnlockedOnly, // Only use unlocked Editors (default)
eoeaLockedFirst, // Search locked Editors first (each group according to Order)
eoeaLockedLast // Search locked Editoes last
);
TEditorOptionsEditAccessOrder =
(eoeaOrderByEditFocus, // prefer the editors in the order they were last focused
eoeaOrderByWindowFocus, // prefer the editors in the order their window was last focused
eoeaOrderByOldestEditFocus, // Reverse order by last focused
eoeaOrderByOldestWindowFocus,
eoeaOnlyCurrentEdit, // search only the current-active editor (and only if it has the correct file)
eoeaOnlyCurrentWindow, // search only the current window (if it has an editor for the desired file)
eoeaOrderByListPref // follow global setting on the list
);
TEditorOptionsEditAccessOpenNew =
(eoeaNoNewTab, // Do not open a new tab, if none found
eoeaNewTabInExistingWindowOnly, // Open a new tab in existing (last focus) window, if possible
eoeaNewTabInNewWindowOnly, // Open a new tab in new window
eoeaNewTabInExistingOrNewWindow // Open a new tab in existing or new window
);
TEditorOptionsEditAccessDefaultEntry = record
SearchLocked: TEditorOptionsEditAccessLockedState;
SearchInView: TEditorOptionsEditAccessInViewState;
SearchOrder: TEditorOptionsEditAccessOrder;
SearchOpenNew: TEditorOptionsEditAccessOpenNew;
Enabled: Boolean;
ID: String;
Caption, Desc: String;
end;
TEditorOptionsEditAccessDefaults = Array [0..8] of TEditorOptionsEditAccessDefaultEntry;
const
// captions and desc are set in TEditorOptions.Create
EditorOptionsEditAccessDefaults: TEditorOptionsEditAccessDefaults =
( // Find locked - InView
(SearchLocked: eoeaLockedOnly; SearchInView: eoeaInViewOnly;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNoNewTab;
Enabled: True; ID: 'Locked_InView';
Caption: ''; Desc: '' ),
// Find unlocked
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaInViewSoftCenterOnly;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNoNewTab;
Enabled: False; ID: 'UnLocked_InSoftView';
Caption: ''; Desc: '' ),
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNoNewTab;
Enabled: True; ID: 'UnLocked';
Caption: ''; Desc: '' ),
// open new tab
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNewTabInExistingWindowOnly;
Enabled: False; ID: 'UnLocked_OpenNewInOldWin';
Caption: ''; Desc: '' ),
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNewTabInNewWindowOnly;
Enabled: False; ID: 'UnLocked_OpenNewInNewWin';
Caption: ''; Desc: '' ),
// Ignore locks
(SearchLocked: eoeaIgnoreLock; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByOldestEditFocus; SearchOpenNew: eoeaNoNewTab;
Enabled: False; ID: 'IgnLocked_OldEdit';
Caption: ''; Desc: '' ),
(SearchLocked: eoeaIgnoreLock; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOnlyCurrentEdit; SearchOpenNew: eoeaNoNewTab;
Enabled: False; ID: 'IgnLocked_OnlyActEdit';
Caption: ''; Desc: '' ),
(SearchLocked: eoeaIgnoreLock; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOnlyCurrentWindow; SearchOpenNew: eoeaNoNewTab;
Enabled: False; ID: 'IgnLocked_OnlyActWin';
Caption: ''; Desc: '' ),
// Fallback (must be last)
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNewTabInExistingOrNewWindow;
Enabled: True; ID: 'UnLocked_OpenNewInAnyWin';
Caption: ''; Desc: '' )
);
EditorOptionsEditAccessUserDef: TEditorOptionsEditAccessDefaultEntry =
(SearchLocked: eoeaUnlockedOnly; SearchInView: eoeaIgnoreInView;
SearchOrder: eoeaOrderByListPref; SearchOpenNew: eoeaNoNewTab;
Enabled: True; ID: '';
Caption: ''; Desc: '' );
type
TEditorOptionsEditAccessOrderList = class;
{ TEditorOptionsEditAccessOrderEntry }
TEditorOptionsEditAccessOrderEntry = class(TPersistent)
private
FId: String;
FList: TEditorOptionsEditAccessOrderList;
FCaption: String;
FDesc: String;
FEnabled: Boolean;
FIsFallback: Boolean;
FDefaults: TEditorOptionsEditAccessOrderEntry;
FSearchInView: TEditorOptionsEditAccessInViewState;
FSearchLocked: TEditorOptionsEditAccessLockedState;
FSearchOpenNew: TEditorOptionsEditAccessOpenNew;
FSearchOrder: TEditorOptionsEditAccessOrder;
procedure AssignFrom(AValue: TEditorOptionsEditAccessDefaultEntry);
procedure SetEnabled(const AValue: Boolean);
public
constructor Create(AList: TEditorOptionsEditAccessOrderList);
destructor Destroy; override;
procedure Assign(Src: TEditorOptionsEditAccessOrderEntry); reintroduce;
procedure InitFrom(AValue: TEditorOptionsEditAccessDefaultEntry);
public
function RealSearchOrder: TEditorOptionsEditAccessOrder;
property Defaults: TEditorOptionsEditAccessOrderEntry read FDefaults;
property ID: String read FId write FId;
property IsFallback: Boolean read FIsFallback;
property Desc: String read FDesc write FDesc;
//published
property Caption: String
read FCaption write FCaption;
published
property Enabled: Boolean
read FEnabled write SetEnabled;
public
property SearchLocked: TEditorOptionsEditAccessLockedState
read FSearchLocked write FSearchLocked;
property SearchInView: TEditorOptionsEditAccessInViewState
read FSearchInView write FSearchInView;
property SearchOrder: TEditorOptionsEditAccessOrder
read FSearchOrder write FSearchOrder;
property SearchOpenNew: TEditorOptionsEditAccessOpenNew
read FSearchOpenNew write FSearchOpenNew;
//property IgnoreTopLineAdjustment;
end;
{ TEditorOptionsEditAccessOrderList }
TEditorOptionsEditAccessOrderList = class(TPersistent)
private
FList: TFPList;
FSearchOrder: TEditorOptionsEditAccessOrder;
function GetItems(Index: Integer): TEditorOptionsEditAccessOrderEntry;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure InitDefaults;
procedure Assign(Src: TEditorOptionsEditAccessOrderList); reintroduce;
procedure LoadFromXMLConfig(XMLConfig:TRttiXMLConfig; Path: String);
procedure SaveToXMLConfig(XMLConfig:TRttiXMLConfig; Path: String);
function Count: Integer;
property Items[Index: Integer]: TEditorOptionsEditAccessOrderEntry
read GetItems; default;
published
property SearchOrder: TEditorOptionsEditAccessOrder
read FSearchOrder write FSearchOrder;
end;
{ TEditorOptions - Editor Options object used to hold the editor options }
@ -969,6 +1131,9 @@ type
// Code Folding
FUseCodeFolding: Boolean;
// Multi window
FMultiWinEditAccessOrder: TEditorOptionsEditAccessOrderList;
function OldAdditionalAttributeName(NewAha:String): string;
public
class function GetGroupCaption:string; override;
@ -1139,6 +1304,10 @@ type
// Code Folding
property UseCodeFolding: Boolean
read FUseCodeFolding write FUseCodeFolding default True;
// Multi window
property MultiWinEditAccessOrder: TEditorOptionsEditAccessOrderList
read FMultiWinEditAccessOrder write FMultiWinEditAccessOrder;
end;
const
@ -2427,6 +2596,161 @@ begin
FCustomSavedActions := Result;
end;
{ TEditorOptionsEditAccessOrderList }
function TEditorOptionsEditAccessOrderList.GetItems(Index: Integer): TEditorOptionsEditAccessOrderEntry;
begin
Result := TEditorOptionsEditAccessOrderEntry(FList[Index]);
end;
constructor TEditorOptionsEditAccessOrderList.Create;
begin
Flist := TFPList.Create;
FSearchOrder := eoeaOrderByEditFocus;
end;
destructor TEditorOptionsEditAccessOrderList.Destroy;
begin
Clear;
FreeAndNil(FList);
inherited Destroy;
end;
procedure TEditorOptionsEditAccessOrderList.Clear;
var
i: Integer;
begin
for i := 0 to Count - 1 do
Items[i].Free;
FList.Clear;
end;
procedure TEditorOptionsEditAccessOrderList.InitDefaults;
var
i: Integer;
Entry: TEditorOptionsEditAccessOrderEntry;
begin
for i := 0 to high(EditorOptionsEditAccessDefaults) do begin
Entry := TEditorOptionsEditAccessOrderEntry.Create(Self);
Entry.InitFrom(EditorOptionsEditAccessDefaults[i]);
FList.Add(Entry);
end;
Entry.FIsFallback := True;
end;
procedure TEditorOptionsEditAccessOrderList.Assign(Src: TEditorOptionsEditAccessOrderList);
var
i: Integer;
Entry: TEditorOptionsEditAccessOrderEntry;
begin
Clear;
FSearchOrder := Src.FSearchOrder;
for i := 0 to Src.Count - 1 do begin
Entry := TEditorOptionsEditAccessOrderEntry.Create(Self);
Entry.Assign(Src[i]);
FList.Add(Entry);
end;
end;
procedure TEditorOptionsEditAccessOrderList.LoadFromXMLConfig(XMLConfig: TRttiXMLConfig;
Path: String);
var
i: Integer;
def: TEditorOptionsEditAccessOrderList;
begin
def := TEditorOptionsEditAccessOrderList.Create;
XMLConfig.ReadObject(Path + 'Main/', self, def);
def.Free;
Path := Path + 'Entry/';
for i := 0 to Count - 1 do
XMLConfig.ReadObject(Path + Items[i].ID + '/', Items[i], Items[i].FDefaults);
end;
procedure TEditorOptionsEditAccessOrderList.SaveToXMLConfig(XMLConfig: TRttiXMLConfig;
Path: String);
var
i: Integer;
def: TEditorOptionsEditAccessOrderList;
begin
def := TEditorOptionsEditAccessOrderList.Create;
XMLConfig.WriteObject(Path + 'Main/', Self, def);
def.Free;
Path := Path + 'Entry/';
for i := 0 to Count - 1 do
XMLConfig.WriteObject(Path + Items[i].ID + '/', Items[i], Items[i].FDefaults);
end;
function TEditorOptionsEditAccessOrderList.Count: Integer;
begin
Result := FList.Count;
end;
{ TEditorOptionsEditAccessOrderEntry }
procedure TEditorOptionsEditAccessOrderEntry.AssignFrom(AValue: TEditorOptionsEditAccessDefaultEntry);
begin
FId := AValue.ID;
FCaption := AValue.Caption;
FDesc := AValue.Desc;
FEnabled := AValue.Enabled;
FSearchInView := AValue.SearchInView;
FSearchLocked := AValue.SearchLocked;
FSearchOpenNew := AValue.SearchOpenNew;
FSearchOrder := AValue.SearchOrder;
end;
procedure TEditorOptionsEditAccessOrderEntry.SetEnabled(const AValue: Boolean);
begin
FEnabled := AValue or FIsFallback;
end;
constructor TEditorOptionsEditAccessOrderEntry.Create(AList: TEditorOptionsEditAccessOrderList);
begin
inherited Create;
FList := AList;
end;
destructor TEditorOptionsEditAccessOrderEntry.Destroy;
begin
FreeAndNil(FDefaults);
inherited Destroy;
end;
procedure TEditorOptionsEditAccessOrderEntry.Assign(Src: TEditorOptionsEditAccessOrderEntry);
begin
FId := Src.FID;
FCaption := Src.FCaption;
FDesc := Src.FDesc;
FEnabled := Src.FEnabled;
FIsFallback := Src.FIsFallback;
FSearchInView := Src.FSearchInView;
FSearchLocked := Src.FSearchLocked;
FSearchOpenNew := Src.FSearchOpenNew;
FSearchOrder := Src.FSearchOrder;
FreeAndNil(FDefaults);
if Src.FDefaults <> nil then begin
FDefaults := TEditorOptionsEditAccessOrderEntry.Create(nil);
FDefaults.Assign(Src.FDefaults);
end;
end;
procedure TEditorOptionsEditAccessOrderEntry.InitFrom(AValue: TEditorOptionsEditAccessDefaultEntry);
begin
AssignFrom(AValue);
FDefaults := TEditorOptionsEditAccessOrderEntry.Create(nil);
FDefaults.AssignFrom(AValue);
end;
function TEditorOptionsEditAccessOrderEntry.RealSearchOrder: TEditorOptionsEditAccessOrder;
begin
Result := SearchOrder;
if Result = eoeaOrderByListPref then begin
if FList = nil then Result := eoeaOrderByEditFocus;
Result := FList.SearchOrder;
if Result = eoeaOrderByListPref then Result := eoeaOrderByEditFocus;
end;
end;
{ TEditorOptions }
constructor TEditorOptions.Create;
@ -2529,6 +2853,28 @@ begin
end;
end;
EditorOptionsEditAccessDefaults[0].Caption := dlgEditAccessCaptionLockedInView;
EditorOptionsEditAccessDefaults[0].Desc := dlgEditAccessDescLockedInView;
EditorOptionsEditAccessDefaults[1].Caption := dlgEditAccessCaptionUnLockedInSoftView;
EditorOptionsEditAccessDefaults[1].Desc := dlgEditAccessDescUnLockedInSoftView;
EditorOptionsEditAccessDefaults[2].Caption := dlgEditAccessCaptionUnLocked;
EditorOptionsEditAccessDefaults[2].Desc := dlgEditAccessDescUnLocked;
EditorOptionsEditAccessDefaults[3].Caption := dlgEditAccessCaptionUnLockedOpenNewInOldWin ;
EditorOptionsEditAccessDefaults[3].Desc := dlgEditAccessDescUnLockedOpenNewInOldWin;
EditorOptionsEditAccessDefaults[4].Caption := dlgEditAccessCaptionUnLockedOpenNewInNewWin;
EditorOptionsEditAccessDefaults[4].Desc := dlgEditAccessDescUnLockedOpenNewInNewWin;
EditorOptionsEditAccessDefaults[5].Caption := dlgEditAccessCaptionIgnLockedOldEdit;
EditorOptionsEditAccessDefaults[5].Desc := dlgEditAccessDescIgnLockedOldEdit;
EditorOptionsEditAccessDefaults[6].Caption := dlgEditAccessCaptionIgnLockedOnlyActEdit;
EditorOptionsEditAccessDefaults[6].Desc := dlgEditAccessDescIgnLockedOnlyActEdit;
EditorOptionsEditAccessDefaults[7].Caption := dlgEditAccessCaptionIgnLockedOnlyActWin;
EditorOptionsEditAccessDefaults[7].Desc := dlgEditAccessDescIgnLockedOnlyActWin;
EditorOptionsEditAccessDefaults[8].Caption := dlgEditAccessCaptionUnLockedOpenNewInAnyWin;
EditorOptionsEditAccessDefaults[8].Desc := dlgEditAccessDescUnLockedOpenNewInAnyWin;
FMultiWinEditAccessOrder := TEditorOptionsEditAccessOrderList.Create;
FMultiWinEditAccessOrder.InitDefaults;
// update translation
EditorOptionsFoldInfoPas[ 0].Name := dlgFoldPasProcedure;
EditorOptionsFoldInfoPas[ 1].Name := dlgFoldLocalPasVarType;
@ -2628,6 +2974,7 @@ begin
FMouseGutterActionsFoldExp.Free;
FMouseGutterActionsLines.Free;
fKeyMap.Free;
FreeAndNil(FMultiWinEditAccessOrder);
XMLConfig.Free;
FTempMouseSettings.Free;
inherited Destroy;
@ -2896,6 +3243,8 @@ begin
FTempMouseSettings.WriteBack;
end;
FMultiWinEditAccessOrder.LoadFromXMLConfig(XMLConfig, 'EditorOptions/MultiWin/');
except
on E: Exception do
DebugLn('[TEditorOptions.Load] ERROR: ', e.Message);
@ -3106,6 +3455,8 @@ begin
XMLConfig.DeletePath('EditorOptions/Mouse/GutterLineNum');
end;
FMultiWinEditAccessOrder.SaveToXMLConfig(XMLConfig, 'EditorOptions/MultiWin/');
InvalidateFileStateCache;
XMLConfig.Flush;
except

View File

@ -82,7 +82,6 @@ begin
Items.Add(dlgCopyWordAtCursorOnCopyNone);
Items.Add(dlgCopyPasteKeepFolds);
Items.Add(dlgTabNumbersNotebook);
Items.Add(dlgHideSingleTabInNotebook);
end;
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeLeaveLine);
EditorTrimSpaceTypeCheckBox.Items.Add(dlgTrimSpaceTypeEditLine);
@ -112,7 +111,6 @@ begin
Checked[4] := CopyWordAtCursorOnCopyNone;
Checked[5] := eoFoldedCopyPaste in SynEditOptions2;
Checked[6] := ShowTabNumbers;
Checked[7] := HideSingleTabInWindow; // dlgHideSingleTabInNotebook
end;
EditorTrimSpaceTypeCheckBox.ItemIndex := ord(TrimSpaceType);
EditorTabPositionCheckBox.ItemIndex := TabPosToIndex[TabPosition];
@ -147,7 +145,6 @@ begin
ShowTabNumbers := EditorOptionsGroupBox.Checked[6];
TrimSpaceType := TSynEditStringTrimmingType(EditorTrimSpaceTypeCheckBox.ItemIndex);
TabPosition := TabIndexToPos[EditorTabPositionCheckBox.ItemIndex];
HideSingleTabInWindow := EditorOptionsGroupBox.Checked[7]; // dlgHideSingleTabInNotebook
end;
end;

View File

@ -0,0 +1,255 @@
inherited EditorMultiWindowOptionsFrame: TEditorMultiWindowOptionsFrame
Height = 387
Width = 521
Anchors = [akTop]
AutoSize = False
ClientHeight = 387
ClientWidth = 521
Visible = False
DesignLeft = 2048
DesignTop = 143
object AccessTypePanel: TPanel[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblAccessType
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 224
Top = 163
Width = 509
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BevelOuter = bvNone
ClientHeight = 224
ClientWidth = 509
TabOrder = 0
object listAccessType: TCheckListBox
AnchorSideLeft.Control = AccessTypePanel
AnchorSideTop.Control = AccessTypePanel
AnchorSideBottom.Control = AccessTypePanel
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 224
Top = 0
Width = 200
Align = alLeft
Constraints.MinWidth = 120
ExtendedSelect = False
ItemHeight = 0
OnClick = listAccessTypeClickCheck
OnClickCheck = listAccessTypeClickCheck
OnExit = listAccessTypeClickCheck
OnKeyUp = listAccessTypeKeyUp
TabOrder = 0
end
object Splitter1: TSplitter
Left = 200
Height = 224
Top = 0
Width = 5
end
object Panel2: TPanel
Left = 205
Height = 224
Top = 0
Width = 304
Align = alClient
BevelOuter = bvNone
ClientHeight = 224
ClientWidth = 304
Constraints.MinWidth = 100
TabOrder = 2
object lblAccessTypeDesc: TLabel
Left = 0
Height = 16
Top = 0
Width = 304
Align = alTop
Caption = 'lblAccessTypeDesc'
ParentColor = False
WordWrap = True
end
end
end
object Bevel1a: TBevel[1]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblEditActivationOrderSection
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 3
Top = 54
Width = 60
BorderSpacing.Bottom = 6
end
object lblEditActivationOrderSection: TLabel[2]
AnchorSideLeft.Control = Bevel1a
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkHideSingleTab
AnchorSideTop.Side = asrBottom
Left = 70
Height = 16
Top = 47
Width = 167
BorderSpacing.Left = 10
BorderSpacing.Bottom = 6
Caption = 'lblEditActivationOrderSection'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object Bevel1: TBevel[3]
AnchorSideLeft.Control = lblEditActivationOrderSection
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblEditActivationOrderSection
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 247
Height = 3
Top = 54
Width = 274
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 10
end
object Panel1: TPanel[4]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblEditActivationOrderSection
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 66
Top = 69
Width = 509
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
BevelOuter = bvNone
ClientHeight = 66
ClientWidth = 509
TabOrder = 1
object lblAccessOrder: TLabel
Left = 0
Height = 16
Top = 0
Width = 509
Align = alTop
BorderSpacing.Bottom = 6
Caption = 'lblAccessOrder'
ParentColor = False
WordWrap = True
end
object radioAccessOrderEdit: TRadioButton
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = lblAccessOrder
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 19
Top = 22
Width = 509
Anchors = [akTop, akLeft, akRight]
Caption = 'radioAccessOrderEdit'
OnChange = radioAccessOrderEditChange
TabOrder = 0
end
object radioAccessOrderWin: TRadioButton
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = radioAccessOrderEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 19
Top = 41
Width = 509
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Bottom = 6
Caption = 'radioAccessOrderWin'
OnChange = radioAccessOrderEditChange
TabOrder = 1
end
end
object lblAccessType: TLabel[5]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 16
Top = 141
Width = 521
Anchors = [akTop, akLeft, akRight]
Caption = 'lblAccessType'
ParentColor = False
end
object Bevel2a: TBevel[6]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblMultiWinTabSection
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 3
Top = 7
Width = 60
BorderSpacing.Bottom = 6
end
object lblMultiWinTabSection: TLabel[7]
AnchorSideLeft.Control = Bevel1a
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 70
Height = 16
Top = 0
Width = 127
BorderSpacing.Left = 10
BorderSpacing.Bottom = 6
Caption = 'lblMultiWinTabSection'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object Bevel2: TBevel[8]
AnchorSideLeft.Control = lblEditActivationOrderSection
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblMultiWinTabSection
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 247
Height = 3
Top = 7
Width = 274
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 10
end
object chkHideSingleTab: TCheckBox[9]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblMultiWinTabSection
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 19
Top = 22
Width = 509
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = 'chkHideSingleTab'
TabOrder = 2
end
end

View File

@ -0,0 +1,169 @@
{
***************************************************************************
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
}
unit editor_multiwindow_options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, StdCtrls, ExtCtrls, Graphics,
LCLType, EditorOptions, LazarusIDEStrConsts, IDEOptionsIntf, Controls,
SynEditHighlighter, SynEditHighlighterFoldBase, Spin, ComCtrls, ColorBox, CheckLst, Buttons;
type
{ TEditorMultiWindowOptionsFrame }
TEditorMultiWindowOptionsFrame = class(TAbstractIDEOptionsEditor)
Bevel1: TBevel;
Bevel1a: TBevel;
Bevel2a: TBevel;
Bevel2: TBevel;
chkHideSingleTab: TCheckBox;
lblAccessTypeDesc: TLabel;
lblMultiWinTabSection: TLabel;
listAccessType: TCheckListBox;
AccessTypePanel: TPanel;
lblEditActivationOrderSection: TLabel;
lblAccessOrder: TLabel;
lblAccessType: TLabel;
Panel1: TPanel;
radioAccessOrderEdit: TRadioButton;
radioAccessOrderWin: TRadioButton;
Panel2: TPanel;
Splitter1: TSplitter;
procedure listAccessTypeClickCheck(Sender: TObject);
procedure listAccessTypeKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure radioAccessOrderEditChange(Sender: TObject);
private
{ private declarations }
FMultiWinEditAccessOrder: TEditorOptionsEditAccessOrderList;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
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}
{ TEditorMultiWindowOptionsFrame }
procedure TEditorMultiWindowOptionsFrame.listAccessTypeClickCheck(Sender: TObject);
var
i: Integer;
begin
i := listAccessType.ItemIndex;
lblAccessTypeDesc.Caption := FMultiWinEditAccessOrder[i].Desc;
for i := 0 to FMultiWinEditAccessOrder.Count - 1 do begin
if FMultiWinEditAccessOrder[i].IsFallback then
listAccessType.Checked[i] := True;
FMultiWinEditAccessOrder[i].Enabled := listAccessType.Checked[i];
end;
end;
procedure TEditorMultiWindowOptionsFrame.listAccessTypeKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
listAccessTypeClickCheck(Sender);
end;
procedure TEditorMultiWindowOptionsFrame.radioAccessOrderEditChange(Sender: TObject);
begin
if radioAccessOrderEdit.Checked then
FMultiWinEditAccessOrder.SearchOrder := eoeaOrderByEditFocus;
if radioAccessOrderWin.Checked then
FMultiWinEditAccessOrder.SearchOrder := eoeaOrderByWindowFocus;
end;
constructor TEditorMultiWindowOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FMultiWinEditAccessOrder := TEditorOptionsEditAccessOrderList.Create;
end;
destructor TEditorMultiWindowOptionsFrame.Destroy;
begin
FreeAndNil(FMultiWinEditAccessOrder);
inherited Destroy;
end;
function TEditorMultiWindowOptionsFrame.GetTitle: String;
begin
Result := dlgMultiWinOptions;
end;
procedure TEditorMultiWindowOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
lblMultiWinTabSection.Caption := dlgMultiWinTabGroup;
lblEditActivationOrderSection.Caption := dlgMultiWinAccessGroup;
lblAccessOrder.Caption := dlgMultiWinAccessOrder;
radioAccessOrderEdit.Caption := dlgMultiWinAccessOrderEdit;
radioAccessOrderWin.Caption := dlgMultiWinAccessOrderWin;
lblAccessType.Caption := dlgMultiWinAccessType;
chkHideSingleTab.Caption := dlgHideSingleTabInNotebook;
end;
procedure TEditorMultiWindowOptionsFrame.ReadSettings(
AOptions: TAbstractIDEOptions);
var
i: Integer;
begin
with TEditorOptions(AOptions) do begin
chkHideSingleTab.Checked := HideSingleTabInWindow;
end;
FMultiWinEditAccessOrder.Assign(TEditorOptions(AOptions).MultiWinEditAccessOrder);
radioAccessOrderEdit.Checked := FMultiWinEditAccessOrder.SearchOrder = eoeaOrderByEditFocus;
radioAccessOrderWin.Checked := FMultiWinEditAccessOrder.SearchOrder = eoeaOrderByWindowFocus;
listAccessType.Clear;
for i := 0 to FMultiWinEditAccessOrder.Count - 1 do begin
listAccessType.Items.Add(FMultiWinEditAccessOrder[i].Caption);
listAccessType.Checked[i] := FMultiWinEditAccessOrder[i].Enabled;
end;
listAccessType.ItemIndex := 0;
listAccessTypeClickCheck(nil);
end;
procedure TEditorMultiWindowOptionsFrame.WriteSettings(
AOptions: TAbstractIDEOptions);
begin
TEditorOptions(AOptions).MultiWinEditAccessOrder.Assign(FMultiWinEditAccessOrder);
with TEditorOptions(AOptions) do begin
HideSingleTabInWindow := chkHideSingleTab.Checked;
end;
end;
class function TEditorMultiWindowOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TEditorOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupEditor, TEditorMultiWindowOptionsFrame, EdtOptionsMultiWindow);
end.

View File

@ -1417,6 +1417,14 @@ resourcestring
//dlgCodeToolsTab = 'Code Tools';
lisAutomaticFeatures = 'Automatic features';
dlgMultiWinOptions = 'Multi Window';
dlgMultiWinTabGroup = 'Tabs:';
dlgMultiWinAccessGroup = 'Find jump target editor:';
dlgMultiWinAccessOrder = 'Order to use for editors matching the same criteria';
dlgMultiWinAccessOrderEdit = 'Most recent focused editor for this file';
dlgMultiWinAccessOrderWin = 'Editor (for file) in most recent focused window';
dlgMultiWinAccessType = 'Priority list of criteria to choose an editor:';
dlgDividerOnOff = 'Draw divider';
dlgDividerDrawDepth = 'Draw divider level';
dlgDividerTopColor = 'Line color';
@ -1522,6 +1530,51 @@ resourcestring
dlgAddHiAttrGroupGutter = 'Gutter';
dlgAddHiAttrGroupSyncroEdit = 'Syncron Edit';
dlgAddHiAttrGroupTemplateEdit = 'Template Edit';
dlgEditAccessCaptionLockedInView = 'Locked, if text in view';
dlgEditAccessCaptionUnLockedInSoftView = 'Unlocked, if text in centered view';
dlgEditAccessCaptionUnLocked = 'Unlocked';
dlgEditAccessCaptionUnLockedOpenNewInOldWin = 'New tab in existing window';
dlgEditAccessCaptionUnLockedOpenNewInNewWin = 'New tab in new window';
dlgEditAccessCaptionIgnLockedOldEdit = 'Ignore Locks, longest unused editor';
dlgEditAccessCaptionIgnLockedOnlyActEdit = 'Ignore Locks, if editor is current';
dlgEditAccessCaptionIgnLockedOnlyActWin = 'Ignore Locks, if editor in current window';
dlgEditAccessCaptionUnLockedOpenNewInAnyWin = 'New tab, existing or new window';
dlgEditAccessDescLockedInView =
'This option will use a locked (and only a locked) Editor, '+
'which does not need to scroll in order to display the target jump point'+
'(target jump point is already in visible screen area)';
dlgEditAccessDescUnLockedInSoftView =
'This option will use a not locked Editor, '+
'which does not need to scroll in order to display the target jump point'+
'(target jump point is already in visible screen center area, excluding 2-5 lines at the top/bottom)';
dlgEditAccessDescUnLocked =
'This option will use any not locked Editor';
dlgEditAccessDescUnLockedOpenNewInOldWin =
'This option will open a new Tab in an existing (and only in an existing) Window, '+
'if no unlocked tab is found. '+
'A tab is only opened if a window exists, that has not yet an editor for the target file';
dlgEditAccessDescUnLockedOpenNewInNewWin =
'This option will open a new Tab in a new (and always in a new) Window, '+
'if no unlocked tab is found. '+
'This option will always succeed, further options are never tested';
dlgEditAccessDescIgnLockedOldEdit =
'This option will use the longest unused editor for the file, '+
'even if it is locked and/or needs scrolling. '+
'This always looks at the editor, never the window, to find the longest unused. ' +
'This option will always succeed, further options are never tested';
dlgEditAccessDescIgnLockedOnlyActEdit =
'This option will check if the current active editor has the target file '+
'and if it is, it will use the current editor, even if it is locked and/or needs scrolling.';
dlgEditAccessDescIgnLockedOnlyActWin =
'This option will check if there is an editorfor the target file in the current window'+
'and if there is, it will use this editor, even if it is locked and/or needs scrolling.';
dlgEditAccessDescUnLockedOpenNewInAnyWin =
'This option will open a new Tab in an existing or new Window, '+
'if no unlocked tab is found. '+
'This option will always succeed, further options are never tested';
lisClearKeyMapping = 'Clear Key Mapping';

View File

@ -113,6 +113,7 @@ uses
editor_mouseaction_options_advanced, editor_color_options,
editor_codetools_options, editor_codefolding_options,
editor_general_misc_options, editor_dividerdraw_options,
editor_multiwindow_options,
codetools_general_options, codetools_codecreation_options,
codetools_classcompletion_options, atom_checkboxes_options,
codetools_wordpolicy_options, codetools_linesplitting_options,
@ -9047,47 +9048,154 @@ end;
function TMainIDE.GetAvailableUnitEditorInfo(AnUnitInfo: TUnitInfo;
ACaretPoint: TPoint; WantedTopLine: integer = -1): TUnitEditorInfo;
function EditorMatches(AEditInfo: TUnitEditorInfo;
AAccess: TEditorOptionsEditAccessOrderEntry; ALockRun: Integer = 0): Boolean;
var
AEdit: TSourceEditor;
begin
AEdit := TSourceEditor(AEditInfo.EditorComponent);
Result := False;
case AAccess.SearchLocked of
eoeaIgnoreLock: ;
eoeaLockedOnly: if not AEdit.IsLocked then exit;
eoeaUnlockedOnly: if AEdit.IsLocked then exit;
eoeaLockedFirst: if (not AEdit.IsLocked) and (ALockRun = 0) then exit;
eoeaLockedLast: if (AEdit.IsLocked) and (ALockRun = 0) then exit;
end;
case AAccess.SearchInView of
eoeaIgnoreInView: ;
eoeaInViewOnly: if not AEdit.IsCaretOnScreen(ACaretPoint, False) then exit;
eoeaInViewSoftCenterOnly: if not AEdit.IsCaretOnScreen(ACaretPoint, True) then exit;
end;
Result := True;
end;
function AvailSrcWindowIndex: Integer;
var
i: Integer;
begin
Result := -1;
i := 0;
if AnUnitInfo.OpenEditorInfoCount > 0 then
while (i < SourceEditorManager.SourceWindowCount) and
(SourceEditorManager.SourceWindowByLastFocused[i].IndexOfEditorInShareWith
(TSourceEditor(AnUnitInfo.OpenEditorInfo[0].EditorComponent)) >= 0)
do
inc(i);
if i < SourceEditorManager.SourceWindowCount then
Result := SourceEditorManager.IndexOfSourceWindow(SourceEditorManager.SourceWindowByLastFocused[i]);
end;
var
i: Integer;
i, j, w, LockRun: Integer;
Access: TEditorOptionsEditAccessOrderEntry;
begin
Result := nil;
if AnUnitInfo.OpenEditorInfoCount = 0 then
exit;
// find caret on screen, rather than last focused
i := 0;
while (i < AnUnitInfo.OpenEditorInfoCount) do begin
Result := AnUnitInfo.OpenEditorInfo[i];
if TSourceEditor(Result.EditorComponent).IsCaretOnScreen(ACaretPoint,
not TSourceEditor(Result.EditorComponent).IsLocked)
or (TSourceEditor(Result.EditorComponent).TopLine = WantedTopLine)
then
exit;
inc(i);
if AnUnitInfo.OpenEditorInfoCount = 0 then exit;
for i := 0 to EditorOpts.MultiWinEditAccessOrder.Count - 1 do begin
Access := EditorOpts.MultiWinEditAccessOrder[i];
if not Access.Enabled then continue;
LockRun := 1;
if Access.SearchLocked in [eoeaLockedFirst, eoeaLockedLast] then LockRun := 0;
repeat
case Access.RealSearchOrder of
eoeaOrderByEditFocus, eoeaOrderByListPref:
begin
for j := 0 to AnUnitInfo.OpenEditorInfoCount - 1 do
if EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
end;
eoeaOrderByWindowFocus:
begin
for w := 0 to SourceEditorManager.SourceWindowCount - 1 do begin
for j := 0 to AnUnitInfo.OpenEditorInfoCount - 1 do
if (TSourceEditor(AnUnitInfo.OpenEditorInfo[j].EditorComponent).SourceNotebook
= SourceEditorManager.SourceWindowByLastFocused[w])
and EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
if Result <> nil then break;
end;
end;
eoeaOrderByOldestEditFocus:
begin
for j := AnUnitInfo.OpenEditorInfoCount - 1 downto 0 do
if EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
end;
eoeaOrderByOldestWindowFocus:
begin
for w := SourceEditorManager.SourceWindowCount - 1 downto 0 do begin
for j := 0 to AnUnitInfo.OpenEditorInfoCount - 1 do
if (TSourceEditor(AnUnitInfo.OpenEditorInfo[j].EditorComponent).SourceNotebook
= SourceEditorManager.SourceWindowByLastFocused[w])
and EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
if Result <> nil then break;
end;
end;
eoeaOnlyCurrentEdit:
begin
LockRun := 1;
for j := 0 to AnUnitInfo.OpenEditorInfoCount - 1 do
if (AnUnitInfo.OpenEditorInfo[j].EditorComponent = SourceEditorManager.ActiveEditor)
and EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
end;
eoeaOnlyCurrentWindow:
begin
LockRun := 1;
for j := 0 to AnUnitInfo.OpenEditorInfoCount - 1 do
if (TSourceEditor(AnUnitInfo.OpenEditorInfo[j].EditorComponent).SourceNotebook
= SourceEditorManager.ActiveSourceWindow)
and EditorMatches(AnUnitInfo.OpenEditorInfo[j], Access) then begin
Result := AnUnitInfo.OpenEditorInfo[j];
break;
end;
end;
end;
inc(LockRun);
until (LockRun > 1) or (Result <> nil);
if (Result = nil) then
case Access.SearchOpenNew of
eoeaNoNewTab: ;
eoeaNewTabInExistingWindowOnly:
begin
w := AvailSrcWindowIndex;
if w >= 0 then
if DoOpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo, -1, w, []) = mrOk then
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
end;
eoeaNewTabInNewWindowOnly:
begin
if DoOpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo,
-1, SourceEditorManager.SourceWindowCount, []) = mrOk
then
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
end;
eoeaNewTabInExistingOrNewWindow:
begin
w := AvailSrcWindowIndex;
if w < 0 then w := SourceEditorManager.SourceWindowCount;
if DoOpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo, -1, w, []) = mrOk then
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
end;
end;
if Result <> nil then
break;
end;
// find unlocked
i := 0;
while (i < AnUnitInfo.OpenEditorInfoCount) do begin
Result := AnUnitInfo.OpenEditorInfo[i];
if (not TSourceEditor(Result.EditorComponent).IsLocked) or
TSourceEditor(Result.EditorComponent).IsCaretOnScreen(ACaretPoint)
then
exit;
inc(i);
end;
// open new copy
i := 0;
if AnUnitInfo.OpenEditorInfoCount > 0 then
while (i < SourceEditorManager.SourceWindowCount) and
(SourceEditorManager.SourceWindowByLastFocused[i].IndexOfEditorInShareWith
(TSourceEditor(AnUnitInfo.OpenEditorInfo[0].EditorComponent)) >= 0)
do
inc(i);
if i < SourceEditorManager.SourceWindowCount then
i := SourceEditorManager.IndexOfSourceWindow(SourceEditorManager.SourceWindowByLastFocused[i]);
if DoOpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo, -1, i, []) = mrOk then
Result := AnUnitInfo.OpenEditorInfo[0]
else
Result := nil;
if Result = nil then // should never happen
Result := AnUnitInfo.OpenEditorInfo[0];
end;
function TMainIDE.LoadIDECodeBuffer(var ACodeBuffer: TCodeBuffer;

View File

@ -3897,7 +3897,7 @@ begin
NewPageName:=Format('%s:%d', [FPageName, (p+1) mod 10])
else
NewPageName:=FPageName;
if IsLocked then NewPageName:='%'+NewPageName;
if IsLocked then NewPageName:='#'+NewPageName;
if Modified then NewPageName:='*'+NewPageName;
if SourceNotebook.NoteBookPages[p] <> NewPageName then begin
SourceNotebook.NoteBookPages[p] := NewPageName;

View File

@ -180,6 +180,7 @@ const
EdtOptionsCodeFolding = 700;
EdtOptionsCodeFoldingMouse = 701;
EdtOptionsDrawDivider = 800;
EdtOptionsMultiWindow = 900;
GroupCodetools = 300;
CdtOptionsGeneral = 100;