mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 19:47:02 +01:00
IDE, IDEIntf: changes needed for new packagetabs package.
git-svn-id: trunk@50493 -
This commit is contained in:
parent
06f6ac8e1f
commit
f1f1c7225c
@ -358,6 +358,7 @@ type
|
||||
function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract;
|
||||
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
|
||||
AProject: TLazProject): TModalResult;
|
||||
function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract;
|
||||
|
||||
// configs
|
||||
class function GetPrimaryConfigPath: String; virtual; abstract;
|
||||
|
||||
@ -15,7 +15,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileUtil, Laz2_XMLCfg, LCLType, Forms, Controls,
|
||||
Graphics, ProjectIntf, IDECommands;
|
||||
ComCtrls, Graphics, ProjectIntf, IDECommands;
|
||||
|
||||
type
|
||||
TSourceMarklingType = (
|
||||
@ -85,6 +85,8 @@ type
|
||||
function GetLines: TStrings; virtual; abstract;
|
||||
function GetLineText: string; virtual; abstract;
|
||||
function GetModified: Boolean; virtual; abstract;
|
||||
function GetPageCaption: string; virtual; abstract;
|
||||
function GetPageName: string; virtual; abstract;
|
||||
function GetReadOnly: Boolean; virtual; abstract;
|
||||
function GetSelection: string; virtual; abstract;
|
||||
function GetSelEnd: Integer; virtual; abstract;
|
||||
@ -152,6 +154,13 @@ type
|
||||
function GetProjectFile: TLazProjectFile; virtual; abstract;
|
||||
procedure UpdateProjectFile; virtual; abstract;
|
||||
function GetDesigner(LoadForm: boolean): TIDesigner; virtual; abstract;
|
||||
|
||||
// editor commands
|
||||
procedure DoEditorExecuteCommand(EditorCommand: word); virtual; abstract;
|
||||
|
||||
// move/copy to another SourceEditorWindow
|
||||
procedure MoveToWindow(AWindowIndex: Integer); virtual; abstract;
|
||||
procedure CopyToWindow(AWindowIndex: Integer); virtual; abstract;
|
||||
public
|
||||
property BlockBegin: TPoint read GetBlockBegin write SetBlockBegin;
|
||||
property BlockEnd: TPoint read GetBlockEnd write SetBlockEnd;
|
||||
@ -162,6 +171,8 @@ type
|
||||
property FileName: string read GetFileName;
|
||||
property Lines: TStrings read GetLines write SetLines;// the whole file
|
||||
property CurrentLineText: string read GetLineText write SetLineText;// source of current line
|
||||
property PageCaption: string read GetPageCaption;// the beatified unit name with modifiers ('*', '#') as it is shown in tab caption
|
||||
property PageName: string read GetPageName;// the beatified unit name
|
||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly;
|
||||
property Selection: string read GetSelection write SetSelection;
|
||||
property SelEnd: Integer read GetSelEnd write SetSelEnd;
|
||||
@ -205,12 +216,21 @@ type
|
||||
function GetCompletionPlugins(Index: integer): TSourceEditorCompletionPlugin; virtual; abstract;
|
||||
function GetItems(Index: integer): TSourceEditorInterface; virtual; abstract;
|
||||
procedure SetActiveEditor(const AValue: TSourceEditorInterface); virtual; abstract;
|
||||
function GetWindowID: Integer; virtual; abstract;
|
||||
public
|
||||
procedure IncUpdateLock; virtual; abstract;
|
||||
procedure DecUpdateLock; virtual; abstract;
|
||||
function IndexOfEditorInShareWith(AnOtherEditor: TSourceEditorInterface): Integer; virtual; abstract;
|
||||
function SourceEditorIntfWithFilename(const Filename: string): TSourceEditorInterface; virtual; abstract;
|
||||
property ActiveEditor: TSourceEditorInterface read GetActiveEditor write SetActiveEditor;
|
||||
function Count: integer; virtual; abstract;
|
||||
property Items[Index: integer]: TSourceEditorInterface read GetItems; default;
|
||||
property ActiveCompletionPlugin: TSourceEditorCompletionPlugin read GetActiveCompletionPlugin;
|
||||
// The number in the Form.Caption minus 1 (0-based), if multiple Win are open
|
||||
property WindowID: Integer read GetWindowID;
|
||||
// Editor Page Caption update
|
||||
procedure AddUpdateEditorPageCaptionHandler(AEvent: TNotifyEvent; const AsLast: Boolean = True); virtual; abstract;
|
||||
procedure RemoveUpdateEditorPageCaptionHandler(AEvent: TNotifyEvent); virtual; abstract;
|
||||
end;
|
||||
|
||||
TsemChangeReason = (
|
||||
@ -259,11 +279,15 @@ type
|
||||
virtual; abstract;
|
||||
function GetMarklingProducers(Index: integer): TSourceMarklingProducer;
|
||||
virtual; abstract;
|
||||
function GetShowTabs: Boolean; virtual; abstract;
|
||||
procedure SetShowTabs(const AShowTabs: Boolean); virtual; abstract;
|
||||
function GetTabPosition: TTabPosition; virtual; abstract;
|
||||
public
|
||||
// List of SourceEditorWindows
|
||||
function SourceWindowWithEditor(const AEditor: TSourceEditorInterface): TSourceEditorWindowInterface;
|
||||
virtual; abstract;
|
||||
function IndexOfSourceWindowWithID(const AnID: Integer): Integer; virtual; abstract;
|
||||
procedure ShowActiveWindowOnTop(Focus: Boolean = False); virtual; abstract;
|
||||
function SourceWindowCount: integer; virtual; abstract;
|
||||
property SourceWindows[Index: integer]: TSourceEditorWindowInterface
|
||||
read GetSourceWindows;
|
||||
@ -316,6 +340,8 @@ type
|
||||
procedure UnregisterMarklingProducer(aProducer: TSourceMarklingProducer); virtual; abstract;
|
||||
procedure InvalidateMarklingsOfAllFiles(aProducer: TSourceMarklingProducer); virtual; abstract;
|
||||
procedure InvalidateMarklings(aProducer: TSourceMarklingProducer; aFilename: string); virtual; abstract;
|
||||
property ShowTabs: Boolean read GetShowTabs write SetShowTabs;
|
||||
property TabPosition: TTabPosition read GetTabPosition;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
@ -721,6 +721,7 @@ type
|
||||
function DoResetToolStatus(AFlags: TResetToolFlags): boolean; override;
|
||||
|
||||
// files/units
|
||||
function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; override;
|
||||
function DoNewFile(NewFileDescriptor: TProjectFileDescriptor;
|
||||
var NewFilename: string; NewSource: string;
|
||||
NewFlags: TNewFlags; NewOwner: TObject): TModalResult; override;
|
||||
@ -6246,6 +6247,12 @@ begin
|
||||
Result:=SourceFileMgr.AddActiveUnitToProject;
|
||||
end;
|
||||
|
||||
function TMainIDE.DoAddUnitToProject(AEditor: TSourceEditorInterface
|
||||
): TModalResult;
|
||||
begin
|
||||
Result := SourceFileMgr.AddUnitToProject(AEditor);
|
||||
end;
|
||||
|
||||
function TMainIDE.DoRemoveFromProjectDialog: TModalResult;
|
||||
Begin
|
||||
Result:=SourceFileMgr.RemoveFromProjectDialog;
|
||||
|
||||
@ -275,7 +275,6 @@ type
|
||||
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
||||
function GetSource: TStrings;
|
||||
procedure SetIsLocked(const AValue: Boolean);
|
||||
procedure SetPageName(const AValue: string);
|
||||
procedure UpdateExecutionSourceMark;
|
||||
procedure UpdatePageName;
|
||||
procedure SetSource(Value: TStrings);
|
||||
@ -294,6 +293,10 @@ type
|
||||
procedure UnbindEditor;
|
||||
|
||||
procedure UpdateIfDefNodeStates(Force: Boolean = False);
|
||||
protected
|
||||
function GetPageCaption: string; override;
|
||||
function GetPageName: string; override;
|
||||
procedure SetPageName(const AValue: string);
|
||||
protected
|
||||
procedure DoMultiCaretBeforeCommand(Sender: TObject; ACommand: TSynEditorCommand;
|
||||
var AnAction: TSynMultiCaretCommandAction; var {%H-}AFlags: TSynMultiCaretCommandFlags);
|
||||
@ -431,7 +434,9 @@ type
|
||||
procedure ShowSmartHintForSourceAtCursor;
|
||||
|
||||
// editor commands
|
||||
procedure DoEditorExecuteCommand(EditorCommand: word);
|
||||
procedure DoEditorExecuteCommand(EditorCommand: word); override;
|
||||
procedure MoveToWindow(AWindowIndex: Integer); override;
|
||||
procedure CopyToWindow(AWindowIndex: Integer); override;
|
||||
|
||||
// used to get the word at the mouse cursor
|
||||
function GetWordFromCaret(const ACaretPos: TPoint): String;
|
||||
@ -515,7 +520,7 @@ type
|
||||
property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown;
|
||||
property OnKeyUp: TKeyEvent read FOnKeyUp write FOnKeyUp;
|
||||
property Owner: TComponent read FAOwner;
|
||||
property PageName: string read FPageName write SetPageName;
|
||||
property PageName: string read GetPageName write SetPageName;
|
||||
property PopupMenu: TPopupMenu read FPopUpMenu write SetPopUpMenu;
|
||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly;
|
||||
property Source: TStrings read GetSource write SetSource;
|
||||
@ -645,6 +650,7 @@ type
|
||||
FHistoryList: TFPList; // list of TSourceEditor page order for when a window closes
|
||||
FHistoryDlg: TBrowseEditorTabHistoryDialog;
|
||||
FStopBtnIdx: Integer;
|
||||
FOnEditorPageCaptionUpdate: TMethodList;
|
||||
private
|
||||
FUpdateTabAndPageTimer: TTimer;
|
||||
FWindowID: Integer;
|
||||
@ -681,6 +687,7 @@ type
|
||||
procedure NoteBookDeletePage(APageIndex: Integer);
|
||||
procedure UpdateTabsAndPageTitle;
|
||||
procedure UpdateTabsAndPageTimeReached(Sender: TObject);
|
||||
procedure CallOnEditorPageCaptionUpdate(Sender: TObject);
|
||||
protected
|
||||
function NoteBookIndexOfPage(APage: TTabSheet): Integer;
|
||||
procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
|
||||
@ -700,6 +707,7 @@ type
|
||||
procedure DoClose(var CloseAction: TCloseAction); override;
|
||||
procedure DoShow; override;
|
||||
procedure DoHide; override;
|
||||
function GetWindowID: Integer; override;
|
||||
protected
|
||||
function GetActiveCompletionPlugin: TSourceEditorCompletionPlugin; override;
|
||||
function GetCompletionPlugins(Index: integer): TSourceEditorCompletionPlugin; override;
|
||||
@ -763,6 +771,9 @@ type
|
||||
procedure BeginAutoFocusLock;
|
||||
procedure EndAutoFocusLock;
|
||||
|
||||
public
|
||||
procedure AddUpdateEditorPageCaptionHandler(AEvent: TNotifyEvent; const AsLast: Boolean = True); override;
|
||||
procedure RemoveUpdateEditorPageCaptionHandler(AEvent: TNotifyEvent); override;
|
||||
protected
|
||||
procedure CloseTabClicked(Sender: TObject);
|
||||
procedure CloseClicked(Sender: TObject; CloseOthers: Boolean = False);
|
||||
@ -809,7 +820,7 @@ type
|
||||
function FindSourceEditorWithEditorComponent(EditorComp: TComponent): TSourceEditor;
|
||||
function GetActiveSE: TSourceEditor; { $note deprecate and use SetActiveEditor}
|
||||
procedure CheckCurrentCodeBufferChanged;
|
||||
function IndexOfEditorInShareWith(AnOtherEditor: TSourceEditor): Integer;
|
||||
function IndexOfEditorInShareWith(AnOtherEditor: TSourceEditorInterface): Integer; override;
|
||||
procedure MoveEditor(OldPageIndex, NewPageIndex: integer);
|
||||
procedure MoveEditor(OldPageIndex, NewWindowIndex, NewPageIndex: integer);
|
||||
|
||||
@ -823,12 +834,10 @@ type
|
||||
procedure CloseFile(APageIndex:integer);
|
||||
procedure FocusEditor;
|
||||
function GetCapabilities: TCTabControlCapabilities;
|
||||
procedure IncUpdateLock;
|
||||
procedure DecUpdateLock;
|
||||
procedure IncUpdateLock; override;
|
||||
procedure DecUpdateLock; override;
|
||||
public
|
||||
property Editors[Index:integer]:TSourceEditor read GetEditors; // !!! not ordered for PageIndex
|
||||
// The number in the Form.Caption minus 1 (0-based), if multiple Win are open
|
||||
property WindowID: Integer read FWindowID;
|
||||
// forwarders to the FNotebook
|
||||
property PageIndex: Integer read GetPageIndex write SetPageIndex;
|
||||
property PageCount: Integer read GetPageCount;
|
||||
@ -872,6 +881,7 @@ type
|
||||
FActiveEditorLock: Integer;
|
||||
FAutoFocusLock: Integer;
|
||||
FUpdateFlags: TSrcEditManagerUpdateFlags;
|
||||
FShowTabs: Boolean;
|
||||
procedure FreeSourceWindows;
|
||||
function GetActiveSourceWindowIndex: integer;
|
||||
function GetSourceWindowByLastFocused(Index: Integer): TSourceEditorWindowInterface;
|
||||
@ -895,6 +905,9 @@ type
|
||||
procedure SyncMessageWnd(Sender: TObject);
|
||||
procedure DoWindowShow(AWindow: TSourceNotebook);
|
||||
procedure DoWindowHide(AWindow: TSourceNotebook);
|
||||
function GetShowTabs: Boolean; override;
|
||||
procedure SetShowTabs(const AShowTabs: Boolean); override;
|
||||
function GetTabPosition: TTabPosition; override;
|
||||
public
|
||||
procedure BeginAutoFocusLock;
|
||||
procedure EndAutoFocusLock;
|
||||
@ -961,7 +974,7 @@ type
|
||||
public
|
||||
procedure IncUpdateLock;
|
||||
procedure DecUpdateLock;
|
||||
procedure ShowActiveWindowOnTop(Focus: Boolean = False);
|
||||
procedure ShowActiveWindowOnTop(Focus: Boolean = False); override;
|
||||
private
|
||||
FMacroRecorder: TIdeEditorMacro;
|
||||
FOnCurrentCodeBufferChanged: TNotifyEvent;
|
||||
@ -3582,6 +3595,11 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.MoveToWindow(AWindowIndex: Integer);
|
||||
begin
|
||||
SourceNotebook.MoveEditor(PageIndex, AWindowIndex, -1)
|
||||
end;
|
||||
|
||||
function TSourceEditor.GetSharedValues: TSourceEditorSharedValuesBase;
|
||||
begin
|
||||
Result := FSharedValues;
|
||||
@ -5134,7 +5152,7 @@ end;
|
||||
procedure TSourceEditor.UpdatePageName;
|
||||
var
|
||||
p: Integer;
|
||||
NewPageName: String;
|
||||
NewPageCaption: String;
|
||||
begin
|
||||
if SourceNotebook.FUpdateLock > 0 then begin
|
||||
include(SourceNotebook.FUpdateFlags, ufPageNames);
|
||||
@ -5143,14 +5161,15 @@ begin
|
||||
p:=SourceNotebook.FindPageWithEditor(Self);
|
||||
if EditorOpts.ShowTabNumbers and (p < 10) then
|
||||
// Number pages 1, ..., 9, 0 -- according to Alt+N hotkeys.
|
||||
NewPageName:=Format('%s:%d', [FPageName, (p+1) mod 10])
|
||||
NewPageCaption:=Format('%s:%d', [FPageName, (p+1) mod 10])
|
||||
else
|
||||
NewPageName:=FPageName;
|
||||
if IsLocked then NewPageName:='#'+NewPageName;
|
||||
if Modified then NewPageName:='*'+NewPageName;
|
||||
if SourceNotebook.NoteBookPages[p] <> NewPageName then begin
|
||||
SourceNotebook.NoteBookPages[p] := NewPageName;
|
||||
NewPageCaption:=FPageName;
|
||||
if IsLocked then NewPageCaption:='#'+NewPageCaption;
|
||||
if Modified then NewPageCaption:='*'+NewPageCaption;
|
||||
if SourceNotebook.NoteBookPages[p] <> NewPageCaption then begin
|
||||
SourceNotebook.NoteBookPages[p] := NewPageCaption;
|
||||
SourceNotebook.UpdateTabsAndPageTitle;
|
||||
SourceNotebook.CallOnEditorPageCaptionUpdate(Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -5918,6 +5937,11 @@ begin
|
||||
DebugBoss.LineInfo.RemoveNotification(FLineInfoNotification);
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.CopyToWindow(AWindowIndex: Integer);
|
||||
begin
|
||||
SourceNotebook.CopyEditor(PageIndex, AWindowIndex, -1)
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.LineInfoNotificationChange(const ASender: TObject; const ASource: String);
|
||||
begin
|
||||
if ASource = FileName then begin
|
||||
@ -6068,6 +6092,22 @@ begin
|
||||
Result := GetWordFromCaret(ACaretPos);
|
||||
end;
|
||||
|
||||
function TSourceEditor.GetPageCaption: string;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
I := SourceNotebook.FindPageWithEditor(Self);
|
||||
if I >= 0 then
|
||||
Result := SourceNotebook.NoteBookPages[I]
|
||||
else
|
||||
Result := FPageName;
|
||||
end;
|
||||
|
||||
function TSourceEditor.GetPageName: string;
|
||||
begin
|
||||
Result := FPageName;
|
||||
end;
|
||||
|
||||
function TSourceEditor.GetOperandAtCurrentCaret: String;
|
||||
var
|
||||
CaretPos: TPoint;
|
||||
@ -6182,6 +6222,7 @@ begin
|
||||
FSrcEditsSortedForFilenames := TAvgLvlTree.Create(@CompareSrcEditIntfWithFilename);
|
||||
|
||||
FHistoryDlg := TBrowseEditorTabHistoryDialog.CreateNew(Self);
|
||||
FOnEditorPageCaptionUpdate := TMethodList.Create;
|
||||
|
||||
OnDropFiles := @SourceNotebookDropFiles;
|
||||
AllowDropFiles:=true;
|
||||
@ -6220,6 +6261,7 @@ begin
|
||||
Editors[i].Free;
|
||||
FreeAndNil(FSourceEditorList);
|
||||
FreeAndNil(FHistoryList);
|
||||
FreeAndNil(FOnEditorPageCaptionUpdate);
|
||||
FreeAndNil(FSrcEditsSortedForFilenames);
|
||||
|
||||
Application.RemoveOnDeactivateHandler(@OnApplicationDeactivate);
|
||||
@ -6265,7 +6307,12 @@ Begin
|
||||
else
|
||||
Options:=Options-[nboShowCloseButtons];
|
||||
MultiLine := EditorOpts.MultiLineTab;
|
||||
TabPosition := EditorOpts.TabPosition;
|
||||
if Manager<>nil then
|
||||
ShowTabs := Manager.ShowTabs
|
||||
else
|
||||
ShowTabs := True;
|
||||
if ShowTabs then
|
||||
TabPosition := EditorOpts.TabPosition;
|
||||
OnChange := @NotebookPageChanged;
|
||||
OnCloseTabClicked := @CloseTabClicked;
|
||||
OnMouseDown:=@NotebookMouseDown;
|
||||
@ -6768,6 +6815,11 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.CallOnEditorPageCaptionUpdate(Sender: TObject);
|
||||
begin
|
||||
FOnEditorPageCaptionUpdate.CallNotifyEvents(Sender);
|
||||
end;
|
||||
|
||||
function TSourceNotebook.GetNoteBookPage(Index: Integer): TTabSheet;
|
||||
begin
|
||||
if FNotebook.Visible then
|
||||
@ -6803,6 +6855,11 @@ begin
|
||||
Result := -1
|
||||
end;
|
||||
|
||||
function TSourceNotebook.GetWindowID: Integer;
|
||||
begin
|
||||
Result := FWindowID;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.SetPageIndex(AValue: Integer);
|
||||
begin
|
||||
if (fPageIndex = AValue) and (FNotebook.PageIndex = AValue) then begin
|
||||
@ -6981,6 +7038,12 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.RemoveUpdateEditorPageCaptionHandler(
|
||||
AEvent: TNotifyEvent);
|
||||
begin
|
||||
FOnEditorPageCaptionUpdate.Remove(TMethod(AEvent));
|
||||
end;
|
||||
|
||||
function TSourceNotebook.AddContextPopupMenuItem(const NewCaption: string;
|
||||
const NewEnabled: boolean; const NewOnClick: TNotifyEvent): TIDEMenuItem;
|
||||
begin
|
||||
@ -6989,6 +7052,12 @@ begin
|
||||
Result.Enabled:=NewEnabled;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.AddUpdateEditorPageCaptionHandler(
|
||||
AEvent: TNotifyEvent; const AsLast: Boolean);
|
||||
begin
|
||||
FOnEditorPageCaptionUpdate.Add(TMethod(AEvent), AsLast);
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
Procedure TSourceNotebook.EditorChanged
|
||||
Params: Sender: TObject
|
||||
@ -7055,12 +7124,13 @@ begin
|
||||
Manager.DoWindowHide(Self);
|
||||
end;
|
||||
|
||||
function TSourceNotebook.IndexOfEditorInShareWith(AnOtherEditor: TSourceEditor): Integer;
|
||||
function TSourceNotebook.IndexOfEditorInShareWith(
|
||||
AnOtherEditor: TSourceEditorInterface): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to EditorCount - 1 do
|
||||
if Editors[i].IsSharedWith(AnOtherEditor) then
|
||||
if Editors[i].IsSharedWith(AnOtherEditor as TSourceEditor) then
|
||||
exit(i);
|
||||
Result := -1;
|
||||
end;
|
||||
@ -7232,6 +7302,7 @@ begin
|
||||
if FUpdateLock = 0 then begin
|
||||
FUpdateFlags := [];
|
||||
DebugLn(SRCED_LOCK, ['TSourceNotebook.IncUpdateLockInternal']);
|
||||
FPageIndex := PageIndex;
|
||||
end;
|
||||
inc(FUpdateLock);
|
||||
end;
|
||||
@ -7329,7 +7400,7 @@ begin
|
||||
FNotebook.ShowTabs := False;
|
||||
end else begin
|
||||
Caption := FBaseCaption;
|
||||
FNotebook.ShowTabs := True;
|
||||
FNotebook.ShowTabs := (Manager=nil) or Manager.ShowTabs;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -7352,7 +7423,7 @@ begin
|
||||
if State = dsDragLeave then
|
||||
FUpdateTabAndPageTimer.Enabled := True
|
||||
else if Source is TExtendedNotebook then
|
||||
FNotebook.ShowTabs := True;
|
||||
FNotebook.ShowTabs := (Manager=nil) or Manager.ShowTabs;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.DragCanceled;
|
||||
@ -8363,7 +8434,7 @@ begin
|
||||
if State = dsDragLeave then
|
||||
FUpdateTabAndPageTimer.Enabled := True
|
||||
else if Source is TExtendedNotebook then
|
||||
FNotebook.ShowTabs := True;
|
||||
FNotebook.ShowTabs := (Manager=nil) or Manager.ShowTabs;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.NotebookEndDrag(Sender, Target: TObject; X, Y: Integer);
|
||||
@ -8580,7 +8651,10 @@ Begin
|
||||
else
|
||||
FNoteBook.Options:=FNoteBook.Options-[nboShowCloseButtons];
|
||||
FNoteBook.MultiLine := EditorOpts.MultiLineTab;
|
||||
FNotebook.TabPosition := EditorOpts.TabPosition;
|
||||
if FNotebook.ShowTabs then
|
||||
FNotebook.TabPosition := EditorOpts.TabPosition
|
||||
else
|
||||
FNotebook.TabPosition := tpTop;
|
||||
|
||||
Exclude(States,snWarnedFont);
|
||||
CheckFont;
|
||||
@ -8955,6 +9029,11 @@ begin
|
||||
ActiveSourceWindow := SourceWindows[AValue];
|
||||
end;
|
||||
|
||||
procedure TSourceEditorManagerBase.SetShowTabs(const AShowTabs: Boolean);
|
||||
begin
|
||||
FShowTabs := AShowTabs;
|
||||
end;
|
||||
|
||||
function TSourceEditorManagerBase.GetActiveSourceWindow: TSourceEditorWindowInterface;
|
||||
begin
|
||||
Result := FActiveWindow;
|
||||
@ -8988,6 +9067,11 @@ begin
|
||||
Result := TSourceEditorWindowInterface(FSourceWindowList[Index]);
|
||||
end;
|
||||
|
||||
function TSourceEditorManagerBase.GetTabPosition: TTabPosition;
|
||||
begin
|
||||
Result := EditorOpts.TabPosition;
|
||||
end;
|
||||
|
||||
procedure TSourceEditorManagerBase.DoWindowFocused(AWindow: TSourceNotebook);
|
||||
begin
|
||||
FChangeNotifyLists[semWindowFocused].CallNotifyEvents(FActiveWindow);
|
||||
@ -9197,6 +9281,11 @@ begin
|
||||
Result.BottomRight := AnEditor.ClientToScreen(AnEditor.RowColumnToPixels(Point(EndColumn+1, PhysRow+1)));
|
||||
end;
|
||||
|
||||
function TSourceEditorManagerBase.GetShowTabs: Boolean;
|
||||
begin
|
||||
Result := FShowTabs;
|
||||
end;
|
||||
|
||||
function TSourceEditorManagerBase.GetMarklingProducers(Index: integer
|
||||
): TSourceMarklingProducer;
|
||||
begin
|
||||
@ -9379,6 +9468,7 @@ begin
|
||||
if EditorMacroForRecording = nil then
|
||||
EditorMacroForRecording := FMacroRecorder;
|
||||
|
||||
FShowTabs := True;
|
||||
FUpdateFlags := [];
|
||||
FAutoFocusLock := 0;
|
||||
for i := low(TsemChangeReason) to high(TsemChangeReason) do
|
||||
|
||||
@ -208,6 +208,7 @@ type
|
||||
Files: TStringList; MultiSelect: boolean;
|
||||
var MultiSelectCheckedState: Boolean): TModalResult;
|
||||
|
||||
function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult;
|
||||
function AddActiveUnitToProject: TModalResult;
|
||||
function RemoveFromProjectDialog: TModalResult;
|
||||
function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
||||
@ -1674,6 +1675,144 @@ begin
|
||||
MainIDE.SaveEnvironment;
|
||||
end;
|
||||
|
||||
function TLazSourceFileManager.AddUnitToProject(
|
||||
const AEditor: TSourceEditorInterface): TModalResult;
|
||||
var
|
||||
ActiveSourceEditor: TSourceEditor;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
s, ShortUnitName, LFMFilename, LFMType, LFMComponentName,
|
||||
LFMClassName: string;
|
||||
OkToAdd: boolean;
|
||||
Owners: TFPList;
|
||||
i: Integer;
|
||||
APackage: TLazPackage;
|
||||
MsgResult: TModalResult;
|
||||
LFMCode: TCodeBuffer;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
if AEditor<>nil then
|
||||
begin
|
||||
ActiveSourceEditor := AEditor as TSourceEditor;
|
||||
if not MainIDE.BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[ctfUseGivenSourceEditor]) then exit;
|
||||
end else
|
||||
begin
|
||||
ActiveSourceEditor:=nil;
|
||||
if not MainIDE.BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
||||
end;
|
||||
if (ActiveUnitInfo=nil) then exit;
|
||||
if ActiveUnitInfo.IsPartOfProject then begin
|
||||
if not ActiveUnitInfo.IsVirtual then
|
||||
s:=Format(lisTheFile, [ActiveUnitInfo.Filename])
|
||||
else
|
||||
s:=Format(lisTheFile, [ActiveSourceEditor.PageName]);
|
||||
s:=Format(lisisAlreadyPartOfTheProject, [s]);
|
||||
IDEMessageDialog(lisInformation, s, mtInformation, [mbOk]);
|
||||
exit;
|
||||
end;
|
||||
if not ActiveUnitInfo.IsVirtual then
|
||||
s:='"'+ActiveUnitInfo.Filename+'"'
|
||||
else
|
||||
s:='"'+ActiveSourceEditor.PageName+'"';
|
||||
if (ActiveUnitInfo.SrcUnitName<>'')
|
||||
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.SrcUnitName,true,ActiveUnitInfo)>=0) then
|
||||
begin
|
||||
IDEMessageDialog(lisInformation, Format(
|
||||
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
||||
mtInformation, [mbOk]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
Owners:=PkgBoss.GetPossibleOwnersOfUnit(ActiveUnitInfo.Filename,[]);
|
||||
try
|
||||
if (Owners<>nil) then begin
|
||||
for i:=0 to Owners.Count-1 do begin
|
||||
if TObject(Owners[i]) is TLazPackage then begin
|
||||
APackage:=TLazPackage(Owners[i]);
|
||||
MsgResult:=IDEQuestionDialog(lisAddPackageRequirement,
|
||||
Format(lisTheUnitBelongsToPackage, [APackage.IDAsString]),
|
||||
mtConfirmation, [mrYes, lisAddPackageToProject2,
|
||||
mrIgnore, lisAddUnitNotRecommended, mrCancel],'');
|
||||
case MsgResult of
|
||||
mrYes:
|
||||
begin
|
||||
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||
exit;
|
||||
end;
|
||||
mrIgnore: ;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Owners.Free;
|
||||
end;
|
||||
|
||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
||||
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
||||
begin
|
||||
// ask user to apply naming conventions
|
||||
Result:=RenameUnitLowerCase(ActiveUnitInfo,true);
|
||||
if Result=mrIgnore then Result:=mrOk;
|
||||
if Result<>mrOk then begin
|
||||
DebugLn('AddActiveUnitToProject A RenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
||||
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
||||
then begin
|
||||
OkToAdd:=True;
|
||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
||||
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
||||
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
||||
if OkToAdd then begin
|
||||
ActiveUnitInfo.IsPartOfProject:=true;
|
||||
Project1.Modified:=true;
|
||||
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
||||
then begin
|
||||
ActiveUnitInfo.ReadUnitNameFromSource(false);
|
||||
ShortUnitName:=ActiveUnitInfo.CreateUnitName;
|
||||
if (ShortUnitName<>'') then begin
|
||||
if CodeToolBoss.AddUnitToMainUsesSection(Project1.MainUnitInfo.Source,ShortUnitName,'')
|
||||
then
|
||||
Project1.MainUnitInfo.Modified:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if Project1.AutoCreateForms
|
||||
and (pfMainUnitHasCreateFormStatements in Project1.Flags)
|
||||
and FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||
begin
|
||||
UpdateUnitInfoResourceBaseClass(ActiveUnitInfo,true);
|
||||
if ActiveUnitInfo.ResourceBaseClass in [pfcbcForm,pfcbcDataModule] then
|
||||
begin
|
||||
LFMFilename:=ActiveUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(ActiveUnitInfo.Filename,true);
|
||||
if LoadCodeBuffer(LFMCode,LFMFilename,[lbfUpdateFromDisk],false)=mrOk then
|
||||
begin
|
||||
// read lfm header
|
||||
ReadLFMHeader(LFMCode.Source,LFMType,LFMComponentName,LFMClassName);
|
||||
if (LFMComponentName<>'')
|
||||
and (LFMClassName<>'') then begin
|
||||
if IDEMessageDialog(lisAddToStartupComponents,
|
||||
Format(lisShouldTheComponentBeAutoCreatedWhenTheApplicationS, [
|
||||
LFMComponentName]),
|
||||
mtInformation,[mbYes,mbNo])=mrYes then
|
||||
begin
|
||||
Project1.AddCreateFormToProjectFile(LFMClassName,LFMComponentName);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazSourceFileManager.UpdateSourceNames;
|
||||
var
|
||||
i: integer;
|
||||
@ -3324,133 +3463,8 @@ begin
|
||||
end;
|
||||
|
||||
function TLazSourceFileManager.AddActiveUnitToProject: TModalResult;
|
||||
var
|
||||
ActiveSourceEditor: TSourceEditor;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
s, ShortUnitName, LFMFilename, LFMType, LFMComponentName,
|
||||
LFMClassName: string;
|
||||
OkToAdd: boolean;
|
||||
Owners: TFPList;
|
||||
i: Integer;
|
||||
APackage: TLazPackage;
|
||||
MsgResult: TModalResult;
|
||||
LFMCode: TCodeBuffer;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
ActiveSourceEditor:=nil;
|
||||
if not MainIDE.BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
||||
if (ActiveUnitInfo=nil) then exit;
|
||||
if ActiveUnitInfo.IsPartOfProject then begin
|
||||
if not ActiveUnitInfo.IsVirtual then
|
||||
s:=Format(lisTheFile, [ActiveUnitInfo.Filename])
|
||||
else
|
||||
s:=Format(lisTheFile, [ActiveSourceEditor.PageName]);
|
||||
s:=Format(lisisAlreadyPartOfTheProject, [s]);
|
||||
IDEMessageDialog(lisInformation, s, mtInformation, [mbOk]);
|
||||
exit;
|
||||
end;
|
||||
if not ActiveUnitInfo.IsVirtual then
|
||||
s:='"'+ActiveUnitInfo.Filename+'"'
|
||||
else
|
||||
s:='"'+ActiveSourceEditor.PageName+'"';
|
||||
if (ActiveUnitInfo.SrcUnitName<>'')
|
||||
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.SrcUnitName,true,ActiveUnitInfo)>=0) then
|
||||
begin
|
||||
IDEMessageDialog(lisInformation, Format(
|
||||
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
||||
mtInformation, [mbOk]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
Owners:=PkgBoss.GetPossibleOwnersOfUnit(ActiveUnitInfo.Filename,[]);
|
||||
try
|
||||
if (Owners<>nil) then begin
|
||||
for i:=0 to Owners.Count-1 do begin
|
||||
if TObject(Owners[i]) is TLazPackage then begin
|
||||
APackage:=TLazPackage(Owners[i]);
|
||||
MsgResult:=IDEQuestionDialog(lisAddPackageRequirement,
|
||||
Format(lisTheUnitBelongsToPackage, [APackage.IDAsString]),
|
||||
mtConfirmation, [mrYes, lisAddPackageToProject2,
|
||||
mrIgnore, lisAddUnitNotRecommended, mrCancel],'');
|
||||
case MsgResult of
|
||||
mrYes:
|
||||
begin
|
||||
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||
exit;
|
||||
end;
|
||||
mrIgnore: ;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Owners.Free;
|
||||
end;
|
||||
|
||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
||||
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
||||
begin
|
||||
// ask user to apply naming conventions
|
||||
Result:=RenameUnitLowerCase(ActiveUnitInfo,true);
|
||||
if Result=mrIgnore then Result:=mrOk;
|
||||
if Result<>mrOk then begin
|
||||
DebugLn('AddActiveUnitToProject A RenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
||||
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
||||
then begin
|
||||
OkToAdd:=True;
|
||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
||||
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
||||
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
||||
if OkToAdd then begin
|
||||
ActiveUnitInfo.IsPartOfProject:=true;
|
||||
Project1.Modified:=true;
|
||||
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
||||
then begin
|
||||
ActiveUnitInfo.ReadUnitNameFromSource(false);
|
||||
ShortUnitName:=ActiveUnitInfo.CreateUnitName;
|
||||
if (ShortUnitName<>'') then begin
|
||||
if CodeToolBoss.AddUnitToMainUsesSection(Project1.MainUnitInfo.Source,ShortUnitName,'')
|
||||
then
|
||||
Project1.MainUnitInfo.Modified:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if Project1.AutoCreateForms
|
||||
and (pfMainUnitHasCreateFormStatements in Project1.Flags)
|
||||
and FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||
begin
|
||||
UpdateUnitInfoResourceBaseClass(ActiveUnitInfo,true);
|
||||
if ActiveUnitInfo.ResourceBaseClass in [pfcbcForm,pfcbcDataModule] then
|
||||
begin
|
||||
LFMFilename:=ActiveUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(ActiveUnitInfo.Filename,true);
|
||||
if LoadCodeBuffer(LFMCode,LFMFilename,[lbfUpdateFromDisk],false)=mrOk then
|
||||
begin
|
||||
// read lfm header
|
||||
ReadLFMHeader(LFMCode.Source,LFMType,LFMComponentName,LFMClassName);
|
||||
if (LFMComponentName<>'')
|
||||
and (LFMClassName<>'') then begin
|
||||
if IDEMessageDialog(lisAddToStartupComponents,
|
||||
Format(lisShouldTheComponentBeAutoCreatedWhenTheApplicationS, [
|
||||
LFMComponentName]),
|
||||
mtInformation,[mbYes,mbNo])=mrYes then
|
||||
begin
|
||||
Project1.AddCreateFormToProjectFile(LFMClassName,LFMComponentName);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := AddUnitToProject(nil);
|
||||
end;
|
||||
|
||||
function TLazSourceFileManager.RemoveFromProjectDialog: TModalResult;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user