IDE/SourceEditor/Packages: Using SourceEditorManager / Removed all references to single instance "var SourceNotebook" (for multi-window handling)

git-svn-id: trunk@24113 -
This commit is contained in:
martin 2010-03-20 15:12:33 +00:00
parent 2105de444c
commit 9040201c83
23 changed files with 884 additions and 770 deletions

View File

@ -43,10 +43,11 @@ const
type
{ TEditorToolbar }
TEditorToolbar = class(TObject)
private
FJumpHandler: TJumpHandler;
W: TForm;
TB: TToolbar;
PM: TPopupMenu;
CfgButton: TToolButton;
@ -56,6 +57,7 @@ type
protected
procedure AddButton(AMenuItem: TIDEMenuItem);
procedure PositionAtEnd(AToolbar: TToolbar; AButton: TToolButton);
procedure SourceWindowCreated(Sender: TObject);
public
constructor Create;
destructor Destroy; override;
@ -137,27 +139,28 @@ begin
inherited Destroy;
end;
procedure TEditorToolbar.InitEditorToolBar;
procedure TEditorToolbar.SourceWindowCreated(Sender: TObject);
var
T: TJumpType;
begin
if not Assigned(W) and Assigned(SourceEditorManagerIntf.ActiveSourceWindow) then
begin
{$note Todo, hook SourceEditorManager to detect open/close forms}
W := SourceEditorManagerIntf.ActiveSourceWindow; // TODO: each window
TB := nil;
CfgButton := nil;
CreateEditorToolBar(W, TB);
if assigned(TB) then exit; // TODO: handle multiply Windows
CreateEditorToolBar(TSourceEditorWindowInterface(Sender), TB);
PM := TPopupMenu.Create(W);
PM := TPopupMenu.Create(TSourceEditorWindowInterface(Sender));
for T := Low(TJumpType) to High(TJumpType) do
PM.Items.Add(CreateJumpItem(T,W));
end;
PM.Items.Add(CreateJumpItem(T, TSourceEditorWindowInterface(Sender)));
AddStaticItems;
AddCustomItems;
end;
procedure TEditorToolbar.InitEditorToolBar;
begin
TB := nil;
CfgButton := nil;
SourceEditorManagerIntf.RegisterChangeEvent(semWindowCreate, @SourceWindowCreated);
end;
procedure TEditorToolbar.AddButton(AMenuItem: TIDEMenuItem);
var
B: TToolButton;

View File

@ -84,7 +84,7 @@ begin
Result := Tool.CleanPosToCaretAndTopLine(Node.StartPos, NewCodePos,NewTopLine);
if Result then
Result := LazarusIDE.DoOpenFileAndJumpToPos(NewCodePos.Code.Filename
,Point(NewCodePos.X,NewCodePos.Y), NewTopLine, -1
,Point(NewCodePos.X,NewCodePos.Y), NewTopLine, -1,-1
,[ofRegularFile,ofUseCache]) = mrOk;
if Result then
begin

View File

@ -111,7 +111,7 @@ var
begin
// Set up as desired. Maybe create config settings;
Flags := [ofOnlyIfExists, ofAddToRecent, ofUseCache];
LazarusIDE.DoOpenEditorFile(AFileName, 0, Flags);
LazarusIDE.DoOpenEditorFile(AFileName, 0, 0, Flags);
end;
procedure TFileBrowserController.DoLoadLayout(Sender: TObject);

View File

@ -1117,7 +1117,7 @@ begin
DebugLn(['TH2PasDialog.Convert LazarusIDE.DoSaveProject failed']);
exit;
end;
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1,-1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
Result:=Converter.Execute;
if Result<>mrOk then begin

View File

@ -346,7 +346,7 @@ begin
if nm = '' then nm := SourceFile;
end else
nm := SourceFile;
LazarusIDE.DoOpenFileAndJumpToPos(nm, Point(1, Line), -1, -1, [ofOnlyIfExists, ofRegularFile]);
LazarusIDE.DoOpenFileAndJumpToPos(nm, Point(1, Line), -1, -1, -1, [ofOnlyIfExists, ofRegularFile]);
end;
procedure IDEMenuClicked(Sender: TObject);

View File

@ -154,7 +154,7 @@ begin
if HasDirective then exit;
// open the file in the source editor
if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Point(1,Line),-1,-1,
if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Point(1,Line),-1,-1,-1,
[ofOnlyIfExists,ofRegularFile,ofUseCache,ofDoNotLoadResource])<>mrOk then
begin
DebugLn(['THideFPCHintWorker.Execute open failed: ',Filename]);

View File

@ -73,7 +73,7 @@ begin
then begin
// jump
if LazarusIDE.DoOpenFileAndJumpToPos(NewCodePos.Code.Filename,
Point(NewCodePos.X,NewCodePos.Y),NewTopLine,-1,
Point(NewCodePos.X,NewCodePos.Y),NewTopLine,-1,-1,
[ofRegularFile,ofUseCache])=mrOk
then
Ok:=true;

View File

@ -168,7 +168,7 @@ function ParseCode(CodeBuf: TCodeBuffer; out ACodeTool: TCodeTool): boolean;
// commits any editor changes to the codetools, parses the unit
// and if there is a syntax error, tells the IDE jump to it
begin
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
if not CodeToolBoss.Explore(CodeBuf,ACodeTool,false) then begin
LazarusIDE.DoJumpToCodeToolBossError;
Result:=false;

View File

@ -279,7 +279,7 @@ begin
end;
LazarusIDE.DoOpenFileAndJumpToPos(NewCode.Filename,Point(NewX,NewY),
NewTopLine,-1,[]);
NewTopLine,-1,-1,[]);
finally
CodeToolBoss.FreeListOfPCodeXYPosition(NewList);
end;

View File

@ -1001,7 +1001,7 @@ begin
end;
// get nice unit name
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(-1, -1) then begin
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(nil) then begin
DebugLn(['TCodeBrowserView.UseUnitInSrcEditor LazarusIDE.'
+'SaveSourceEditorChangesToCodeCache failed']);
exit;
@ -2645,7 +2645,7 @@ begin
and (Node.CodePos.Code.Filename<>'') then begin
Node.CodePos.Code.AbsoluteToLineCol(Node.CodePos.P,Line,Column);
LazarusIDE.DoOpenFileAndJumpToPos(Node.CodePos.Code.Filename,
Point(Column,Line),-1,-1,[ofOnlyIfExists]);
Point(Column,Line),-1,-1,-1,[ofOnlyIfExists]);
end;
end;
end;
@ -3160,7 +3160,7 @@ begin
exit;
end;
if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Caret,-1,-1,OpnFlagsPlainFile
if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Caret,-1,-1,-1,OpnFlagsPlainFile
)<>mrOk
then exit;

View File

@ -415,7 +415,7 @@ begin
Parser.EnableMacros := Attributes.IndexOfName(CodeTemplateEnableMacros)>=0;
Parser.Indent := StringOfChar(' ', IndentLen);
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
if not Parser.SubstituteCodeMacros(SrcEdit) then exit;
s:=AEditor.Lines[p.y-1];

View File

@ -42,21 +42,19 @@ interface
uses
Classes, SysUtils, Math, Forms, Controls, Buttons, StdCtrls, FileUtil,
LazarusIDEStrConsts, EditorOptions, IDEWindowIntf, LCLType,
InputHistory, DiffPatch, ExtCtrls, Dialogs, SynEdit, IDEContextHelpEdit;
InputHistory, DiffPatch, ExtCtrls, Dialogs, SynEdit, IDEContextHelpEdit,
SourceEditor;
type
TOnGetDiffFile = procedure(TextID: integer; OnlySelection: boolean;
var Source: string) of object;
{ TDiffFile }
TDiffFile = class
public
Name: string;
ID: integer;
Editor: TSourceEditor;
SelectionAvailable: boolean;
constructor Create(const NewName: string; NewID: integer;
constructor Create(const NewName: string; NewEditor: TSourceEditor;
NewSelectionAvailable: boolean);
end;
@ -110,7 +108,6 @@ type
procedure Text1ComboboxChange(Sender: TObject);
procedure Text2ComboboxChange(Sender: TObject);
private
FOnGetDiffFile: TOnGetDiffFile;
fDiffNeedsUpdate: boolean;
FLockCount: integer;
procedure SetupComponents;
@ -130,13 +127,9 @@ type
function GetDiffOptions: TTextDiffFlags;
procedure BeginUpdate;
procedure EndUpdate;
public
property OnGetDiffFile: TOnGetDiffFile
read FOnGetDiffFile write FOnGetDiffFile;
end;
function ShowDiffDialog(Files: TDiffFiles; Text1Index: integer;
OnGetDiffFile: TOnGetDiffFile;
function ShowDiffDialog(Text1Index: integer;
var OpenDiffInEditor: boolean; var Diff: string): TModalResult;
const
@ -152,16 +145,23 @@ implementation
{$R *.lfm}
function ShowDiffDialog(Files: TDiffFiles; Text1Index: integer;
OnGetDiffFile: TOnGetDiffFile;
function ShowDiffDialog(Text1Index: integer;
var OpenDiffInEditor: boolean; var Diff: string): TModalResult;
var
DiffDlg: TDiffDlg;
Files: TDiffFiles;
i: Integer;
SrcEdit: TSourceEditor;
begin
Files := TDiffFiles.Create;
for i:=0 to SourceEditorManager.SourceEditorCount - 1 do begin
SrcEdit := SourceEditorManager.SourceEditors[i]; // FindSourceEditorWithPageIndex(i);
Files.Add(TDiffFile.Create(SrcEdit.PageName, SrcEdit, SrcEdit.SelectionAvailable));
end;
OpenDiffInEditor:=false;
DiffDlg:=TDiffDlg.Create(nil);
DiffDlg.BeginUpdate;
DiffDlg.OnGetDiffFile:=OnGetDiffFile;
DiffDlg.Files:=Files;
DiffDlg.SetText1Index(Text1Index);
DiffDlg.Init;
@ -175,6 +175,7 @@ begin
Result:=mrOk;
end;
Files.Free;
DiffDlg.Free;
end;
@ -192,7 +193,7 @@ begin
//only add new files
if Text1ComboBox.Items.IndexOf(dlgOpen.FileName) = -1 then
begin
Files.Add(TDiffFile.Create(dlgOpen.FileName,-1,False));
Files.Add(TDiffFile.Create(dlgOpen.FileName,nil,False));
Text1ComboBox.Items.Add(dlgOpen.FileName);
Text2ComboBox.Items.Add(dlgOpen.FileName);
end;
@ -302,29 +303,33 @@ begin
if (Text1=nil) or (Text2=nil) then begin
DiffSynEdit.Lines.Text:='';
end else begin
if Text1.ID = -1 then
if Text1.Editor = nil then
begin
dat := TStringList.Create;
dat.LoadFromFile(UTF8ToSys(Text1.Name));
Text1Src := dat.Text;
dat.Free;
end
else begin
if (Text1.SelectionAvailable and Text1OnlySelectionCheckBox.Checked) then
Text1Src := Text1.Editor.EditorComponent.SelText
else
OnGetDiffFile(Text1.ID,
Text1.SelectionAvailable and Text1OnlySelectionCheckBox.Checked,
Text1Src);
Text1Src := Text1.Editor.EditorComponent.Lines.Text;
end;
if Text2.ID = -1 then
if Text2.Editor = nil then
begin
dat := TStringList.Create;
dat.LoadFromFile(UTF8ToSys(Text2.Name));
Text2Src := dat.Text;
dat.Free;
end
else begin
if (Text2.SelectionAvailable and Text2OnlySelectionCheckBox.Checked) then
Text2Src := Text2.Editor.EditorComponent.SelText
else
OnGetDiffFile(Text2.ID,
Text2.SelectionAvailable and Text2OnlySelectionCheckBox.Checked,
Text2Src);
Text2Src := Text2.Editor.EditorComponent.Lines.Text;
end;
DiffTxt:=CreateTextDiff(Text1Src,Text2Src,GetDiffOptions,tdoContext);
@ -477,11 +482,11 @@ end;
{ TDiffFile }
constructor TDiffFile.Create(const NewName: string; NewID: integer;
constructor TDiffFile.Create(const NewName: string; NewEditor: TSourceEditor;
NewSelectionAvailable: boolean);
begin
Name:=NewName;
ID:=NewID;
Editor:=NewEditor;
SelectionAvailable:=NewSelectionAvailable;
end;

View File

@ -1028,7 +1028,7 @@ begin
NewSrcFilename:=CleanAndExpandFilename(SrcFilename);
if (NewSrcFilename=SourceFilename) and (CompareCaret(Caret,CaretXY)=0)
and (fChain<>nil) and fChain.IsValid
and (not LazarusIDE.NeedSaveSourceEditorChangesToCodeCache(-1, -1)) then
and (not LazarusIDE.NeedSaveSourceEditorChangesToCodeCache(nil)) then
exit;
FCaretXY:=Caret;
@ -1236,7 +1236,7 @@ begin
exit;
end;
Exclude(FFlags,fpdefCodeCacheNeedsUpdate);
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
end;
procedure TFPDocEditor.ErrorsMemoChange(Sender: TObject);

View File

@ -379,7 +379,7 @@ type
// SourceNotebook events
procedure OnSrcNoteBookActivated(Sender: TObject);
procedure OnSrcNoteBookAddJumpPoint(ACaretXY: TPoint; ATopLine: integer;
APageIndex: integer; DeleteForwardHistory: boolean);
AEditor: TSourceEditor; DeleteForwardHistory: boolean);
procedure OnSrcNoteBookClickLink(Sender: TObject;
Button: TMouseButton; Shift: TShiftstate; X, Y: Integer);
procedure OnSrcNoteBookMouseLink(
@ -403,7 +403,7 @@ type
procedure OnSrcNotebookShowCodeContext(JumpToError: boolean;
out Abort: boolean);
procedure OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint;
var NewTopLine, NewPageIndex: integer; JumpAction: TJumpHistoryAction);
var NewTopLine: integer; var DestEditor: TSourceEditor; JumpAction: TJumpHistoryAction);
procedure OnSrcNotebookReadOnlyChanged(Sender: TObject);
procedure OnSrcNotebookSaveAll(Sender: TObject);
procedure OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
@ -735,28 +735,41 @@ type
var NewFilename: string; const NewSource: string;
NewFlags: TNewFlags; NewOwner: TObject): TModalResult; override;
function DoNewOther: TModalResult;
function DoSaveEditorFile(PageIndex:integer;
Flags: TSaveFlags): TModalResult; override; deprecated;
Flags: TSaveFlags): TModalResult; override;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoSaveEditorFile(AEditor: TSourceEditorInterface;
Flags: TSaveFlags): TModalResult; override;
function DoCloseEditorFile(PageIndex:integer;
Flags: TCloseFlags):TModalResult; override; //deprecated;
Flags: TCloseFlags):TModalResult; override;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoCloseEditorFile(AEditor: TSourceEditorInterface;
Flags: TCloseFlags):TModalResult; override;
function DoCloseEditorFile(const Filename: string;
Flags: TCloseFlags): TModalResult; override;
function DoOpenEditorFile(AFileName: string; PageIndex: integer;
Flags: TOpenFlags): TModalResult; override; //deprecated;
Flags: TOpenFlags): TModalResult; override;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenEditorFile(AFileName:string; PageIndex, WindowIndex: integer;
Flags: TOpenFlags): TModalResult; override;
function DoOpenFileAtCursor(Sender: TObject): TModalResult;
function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
PageIndex: integer; Flags: TOpenFlags): TModalResult; override;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; override;
function DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer;
PageIndex: integer; Flags: TOpenFlags): TModalResult; override;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer;
PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; override;
function DoRevertEditorFile(const Filename: string): TModalResult; override;
function DoOpenComponent(const UnitFilename: string; OpenFlags: TOpenFlags;
CloseFlags: TCloseFlags;
@ -843,6 +856,7 @@ type
out ActiveUnitInfo: TUnitInfo); override;
procedure GetUnitWithPageIndex(PageIndex, WindowIndex: integer;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); override;
deprecated; // deprecated in 0.9.29 March 2010
procedure GetDesignerUnit(ADesigner: TDesigner;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); override;
function GetDesignerWithProjectFile(AFile: TLazProjectFile;
@ -858,7 +872,7 @@ type
procedure GetUnitWithPersistent(APersistent: TPersistent;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); override;
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
IgnorePageIndex: integer): string;
IgnoreEditor: TSourceEditor): string;
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
function GetAncestorLookupRoot(AnUnitInfo: TUnitInfo): TComponent;
procedure UpdateSaveMenuItemsAndButtons(UpdateSaveAll: boolean);
@ -914,10 +928,12 @@ type
AddJumpPoint: boolean; FocusEditor: Boolean = True; MarkLine: Boolean = False): TModalResult; override;
procedure DoJumpToCodeToolBossError; override;
procedure UpdateSourceNames;
function NeedSaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; override; deprecated;
function NeedSaveSourceEditorChangesToCodeCache(PageIndex, WindowIndex: integer): boolean; override;
function SaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; override; deprecated;
function SaveSourceEditorChangesToCodeCache(PageIndex, WindowIndex: integer): boolean; override;
function NeedSaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; override;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function NeedSaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; override;
function SaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; override;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; override;
procedure ApplyCodeToolChanges;
procedure DoJumpToProcedureSection;
procedure DoFindDeclarationAtCursor;
@ -1510,7 +1526,7 @@ begin
if Sender is TObjectInspectorDlg then begin
AnInspector:=TObjectInspectorDlg(Sender);
if FindDeclarationOfOIProperty(AnInspector,nil,Code,Caret,NewTopLine) then
DoOpenFileAndJumpToPos(Code.Filename,Caret,NewTopLine,-1,[]);
DoOpenFileAndJumpToPos(Code.Filename,Caret,NewTopLine,-1,-1,[]);
end;
end;
@ -1939,25 +1955,25 @@ begin
OnSearchAgainClicked := @FindInFilesDialog.InitFromLazSearch;
// connect search menu to sourcenotebook
MainIDEBar.itmSearchFind.OnClick := @SourceNotebook.FindClicked;
MainIDEBar.itmSearchFindNext.OnClick := @SourceNotebook.FindNextClicked;
MainIDEBar.itmSearchFindPrevious.OnClick := @SourceNotebook.FindPreviousClicked;
MainIDEBar.itmSearchFind.OnClick := @SourceEditorManager.FindClicked;
MainIDEBar.itmSearchFindNext.OnClick := @SourceEditorManager.FindNextClicked;
MainIDEBar.itmSearchFindPrevious.OnClick := @SourceEditorManager.FindPreviousClicked;
MainIDEBar.itmSearchFindInFiles.OnClick := @mnuSearchFindInFiles;
MainIDEBar.itmSearchReplace.OnClick := @SourceNotebook.ReplaceClicked;
MainIDEBar.itmIncrementalFind.OnClick := @SourceNotebook.IncrementalFindClicked;
MainIDEBar.itmGotoLine.OnClick := @SourceNotebook.GotoLineClicked;
MainIDEBar.itmJumpBack.OnClick := @SourceNotebook.JumpBackClicked;
MainIDEBar.itmJumpForward.OnClick := @SourceNotebook.JumpForwardClicked;
MainIDEBar.itmAddJumpPoint.OnClick := @SourceNotebook.AddJumpPointClicked;
MainIDEBar.itmJumpHistory.OnClick := @SourceNotebook.ViewJumpHistoryClicked;
MainIDEBar.itmJumpToNextBookmark.OnClick := @SourceNotebook.BookMarkNextClicked;
MainIDEBar.itmJumpToPrevBookmark.OnClick := @SourceNotebook.BookMarkPrevClicked;
MainIDEBar.itmSearchReplace.OnClick := @SourceEditorManager.ReplaceClicked;
MainIDEBar.itmIncrementalFind.OnClick := @SourceEditorManager.IncrementalFindClicked;
MainIDEBar.itmGotoLine.OnClick := @SourceEditorManager.GotoLineClicked;
MainIDEBar.itmJumpBack.OnClick := @SourceEditorManager.JumpBackClicked;
MainIDEBar.itmJumpForward.OnClick := @SourceEditorManager.JumpForwardClicked;
MainIDEBar.itmAddJumpPoint.OnClick := @SourceEditorManager.AddJumpPointClicked;
MainIDEBar.itmJumpHistory.OnClick := @SourceEditorManager.ViewJumpHistoryClicked;
MainIDEBar.itmJumpToNextBookmark.OnClick := @SourceEditorManager.BookMarkNextClicked;
MainIDEBar.itmJumpToPrevBookmark.OnClick := @SourceEditorManager.BookMarkPrevClicked;
MainIDEBar.itmFindBlockStart.OnClick:=@mnuSearchFindBlockStart;
MainIDEBar.itmFindBlockOtherEnd.OnClick:=@mnuSearchFindBlockOtherEnd;
MainIDEBar.itmFindDeclaration.OnClick:=@mnuSearchFindDeclaration;
MainIDEBar.itmOpenFileAtCursor.OnClick:=@mnuOpenFileAtCursorClicked;
SourceNotebook.InitMacros(GlobalMacroList);
SourceEditorManager.InitMacros(GlobalMacroList);
end;
procedure TMainIDE.SetupTransferMacros;
@ -2504,7 +2520,7 @@ end;
procedure TMainIDE.LoadMenuShortCuts;
begin
inherited LoadMenuShortCuts;
SourceNotebook.SetupShortCuts;
SourceEditorManager.SetupShortCuts;
DebugBoss.SetupMainBarShortCuts;
end;
@ -2722,7 +2738,7 @@ end;
procedure TMainIDE.mnuSaveAsClicked(Sender: TObject);
begin
if SourceNoteBook.PageIndex < 0 then exit;
if SourceEditorManager.ActiveEditor = nil then exit;
DoSaveEditorFile(SourceEditorManager.ActiveEditor, [sfSaveAs, sfCheckAmbiguousFiles]);
end;
@ -2789,7 +2805,7 @@ begin
i:=ActiveSrcNoteBook.PageCount-1;
if i=PageIndex then dec(i);
if i<0 then break;
if DoCloseEditorFile(i,[cfSaveFirst])<>mrOk then exit;
if DoCloseEditorFile(ActiveSrcNoteBook.FindSourceEditorWithPageIndex(i),[cfSaveFirst])<>mrOk then exit;
if i<PageIndex then PageIndex:=i;
until false;
end else
@ -3475,7 +3491,7 @@ end;
procedure TMainIDE.mnuViewSourceEditorClicked(Sender: TObject);
begin
SourceNotebook.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
end;
{------------------------------------------------------------------------------}
@ -4196,7 +4212,7 @@ begin
end;
function TMainIDE.CreateSrcEditPageName(const AnUnitName, AFilename: string;
IgnorePageIndex: integer): string;
IgnoreEditor: TSourceEditor): string;
begin
Result:=AnUnitName;
if Result='' then
@ -4205,7 +4221,7 @@ begin
Result:=ExtractFileNameOnly(Result)
else
Result:=ExtractFileName(Result);
Result:=SourceNoteBook.FindUniquePageName(Result,IgnorePageIndex);
Result:=SourceEditorManager.FindUniquePageName(Result,IgnoreEditor);
end;
procedure TMainIDE.OnLoadIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions);
@ -7556,14 +7572,20 @@ var NewSrcEdit: TSourceEditor;
NewErrorLine: LongInt;
NewExecutionLine: LongInt;
FoldState: String;
SrcNotebook: TSourceNotebook;
begin
AFilename:=AnUnitInfo.Filename;
{ $note Todo:remap window index in all unit infos}
if (WindowIndex < 0) or (WindowIndex >= SourceEditorManager.SourceWindowCount) then
SrcNotebook := SourceEditorManager.ActiveOrNewSourceWindow
else
SrcNotebook := SourceEditorManager.SourceWindows[WindowIndex];
// get syntax highlighter type
if not AnUnitInfo.CustomHighlighter then
AnUnitInfo.SyntaxHighlighter:=FilenameToLazSyntaxHighlighter(AFilename);
SourceNotebook.IncUpdateLock;
SrcNotebook.IncUpdateLock;
try
//DebugLn(['TMainIDE.DoOpenFileInSourceEditor Revert=',ofRevert in Flags,' ',AnUnitInfo.Filename,' PageIndex=',PageIndex]);
if (not (ofRevert in Flags)) or (PageIndex<0) then begin
@ -7572,8 +7594,8 @@ begin
// update marks and cursor positions in Project1, so that merging the old
// settings during restoration will work
SaveSourceEditorProjectSpecificSettings;
NewSrcEdit:=SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.Unit_Name,
AFilename,-1),AnUnitInfo.Source,false);
NewSrcEdit:=SrcNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.Unit_Name,
AFilename, nil),AnUnitInfo.Source,false);
NewSrcEdit.EditorComponent.BeginUpdate;
MainIDEBar.itmFileClose.Enabled:=True;
MainIDEBar.itmFileCloseAll.Enabled:=True;
@ -7626,13 +7648,16 @@ begin
NewSrcEdit.EditorComponent.EndUpdate;
AnUnitInfo.Loaded:=true;
finally
SourceNotebook.DecUpdateLock;
SrcNotebook.DecUpdateLock;
end;
// update statusbar and focus editor
if (not (ofProjectLoading in Flags)) then
SourceNotebook.FocusEditor;
SourceNoteBook.UpdateStatusBar;
if (not (ofProjectLoading in Flags)) then begin
SrcNotebook.ShowOnTop;
SrcNotebook.FocusEditor;
end;
SrcNoteBook.UpdateStatusBar;
SrcNotebook.BringToFront;
Result:=mrOk;
end;
@ -7661,10 +7686,11 @@ var
AProject: TProject;
LRSFilename: String;
ResType: TResourceType;
SrcNoteBook: TSourceNotebook;
begin
//debugln('TMainIDE.DoNewEditorFile A NewFilename=',NewFilename);
// empty NewFilename is ok, it will be auto generated
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
// convert macros in filename
if nfConvertMacros in NewFlags then begin
@ -7745,12 +7771,13 @@ begin
if nfOpenInEditor in NewFlags then begin
// open a new sourceeditor
SourceNotebook.NewFile(CreateSrcEditPageName(NewUnitInfo.Unit_Name,
NewUnitInfo.Filename,-1),
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
SrcNoteBook.NewFile(CreateSrcEditPageName(NewUnitInfo.Unit_Name,
NewUnitInfo.Filename, nil),
NewUnitInfo.Source,true);
MainIDEBar.itmFileClose.Enabled:=True;
MainIDEBar.itmFileCloseAll.Enabled:=True;
NewSrcEdit:=SourceNotebook.GetActiveSE;
NewSrcEdit := SrcNoteBook.GetActiveSE;
NewSrcEdit.SyntaxHighlighterType:=NewUnitInfo.SyntaxHighlighter;
NewUnitInfo.EditorComponent := NewSrcEdit;
@ -7925,7 +7952,7 @@ begin
// update codetools cache and collect Modified flags
if not (sfProjectSaving in Flags) then
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
// if this is a new unit then a simple Save becomes a SaveAs
if (not (sfSaveToTestDir in Flags)) and (AnUnitInfo.IsVirtual) then
@ -8057,7 +8084,7 @@ begin
AEditor.Modified:=false;
UpdateSaveMenuItemsAndButtons(not (sfProjectSaving in Flags));
end;
SourceNoteBook.UpdateStatusBar;
TSourceEditor(AEditor).SourceNotebook.UpdateStatusBar;
// fix all references
NewUnitName:='';
@ -8129,7 +8156,7 @@ begin
if AnUnitInfo=nil then begin
// we need to close the page anyway or else we might enter a loop
DebugLn('TMainIDE.DoCloseEditorFile INCONSISTENCY: NO AnUnitInfo');
SourceNoteBook.CloseFile(AnUnitInfo.EditorIndex);
SourceEditorManager.CloseFile(AnUnitInfo.EditorComponent);
Result:=mrOk;
exit;
end;
@ -8179,8 +8206,8 @@ begin
CloseUnitComponent(AnUnitInfo,[]);
// close source editor
SourceNoteBook.CloseFile(AnUnitInfo.EditorIndex);
MainIDEBar.itmFileClose.Enabled:=SourceNoteBook.PageCount > 0;
SourceEditorManager.CloseFile(AnUnitInfo.EditorComponent);
MainIDEBar.itmFileClose.Enabled:=SourceEditorManager.SourceEditorCount > 0;
MainIDEBar.itmFileCloseAll.Enabled:=MainIDEBar.itmFileClose.Enabled;
// free sources
@ -8509,10 +8536,10 @@ begin
MainUnitInfo:=Project1.MainUnitInfo;
// check if main unit is already open in source editor
if (MainUnitInfo.EditorIndex>=0) and (not (ofProjectLoading in Flags)) then
if (MainUnitInfo.EditorComponent <> nil) and (not (ofProjectLoading in Flags)) then
begin
// already loaded -> switch to source editor
SourceNotebook.PageIndex:=MainUnitInfo.EditorIndex;
SourceEditorManager.ActiveEditor := TSourceEditor(MainUnitInfo.EditorComponent);
Result:=mrOk;
exit;
end;
@ -8682,7 +8709,7 @@ begin
AnUnitInfo := Project1.Units[TViewUnitsEntry(UnitList.Objects[i]).ID];
if AnUnitInfo.EditorIndex >= 0 then
begin
SourceNoteBook.PageIndex := AnUnitInfo.EditorIndex;
SourceEditorManager.ActiveEditor := TSourceEditor(AnUnitInfo.EditorComponent);
end else
begin
if Project1.MainUnitInfo = AnUnitInfo then
@ -8701,7 +8728,7 @@ begin
end; { for }
if (AnUnitInfo <> nil) and (not OnlyForms) then
begin
SourceNotebook.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
end;
end; { if ShowViewUnitDlg... }
finally
@ -8815,7 +8842,7 @@ end;
procedure TMainIDE.DoShowFPDocEditor;
begin
SourceNotebook.ShowFPDocEditor;
SourceEditorManager.ShowFPDocEditor;
end;
function TMainIDE.CreateNewUniqueFilename(const Prefix, Ext: string;
@ -9079,13 +9106,21 @@ end;
function TMainIDE.DoOpenFileAndJumpToIdentifier(const AFilename,
AnIdentifier: string; PageIndex: integer; Flags: TOpenFlags): TModalResult;
begin
Result := DoOpenFileAndJumpToIdentifier(AFilename, AnIdentifier, PageIndex,
SourceEditorManager.ActiveSourceWindowIndex, Flags);
end;
function TMainIDE.DoOpenFileAndJumpToIdentifier(const AFilename,
AnIdentifier: string; PageIndex, WindowIndex: integer; Flags: TOpenFlags
): TModalResult;
var
ActiveUnitInfo: TUnitInfo;
ActiveSrcEdit: TSourceEditor;
NewSource: TCodeBuffer;
NewX, NewY, NewTopLine: integer;
begin
Result:=DoOpenEditorFile(AFilename, PageIndex, Flags);
Result:=DoOpenEditorFile(AFilename, PageIndex, WindowIndex, Flags);
if Result<>mrOk then exit;
Result:=mrCancel;
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
@ -9102,12 +9137,20 @@ end;
function TMainIDE.DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer; PageIndex: integer;
Flags: TOpenFlags): TModalResult;
begin
Result := DoOpenFileAndJumpToPos(AFilename, CursorPosition, TopLine, PageIndex,
SourceEditorManager.ActiveSourceWindowIndex, Flags);
end;
function TMainIDE.DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer; PageIndex,
WindowIndex: integer; Flags: TOpenFlags): TModalResult;
var
ActiveUnitInfo, OldActiveUnitInfo: TUnitInfo;
ActiveSrcEdit, OldActiveSrcEdit: TSourceEditor;
begin
GetCurrentUnit(OldActiveSrcEdit,OldActiveUnitInfo);
Result:=DoOpenEditorFile(AFilename, PageIndex, Flags);
Result:=DoOpenEditorFile(AFilename, PageIndex, WindowIndex, Flags);
if Result<>mrOk then exit;
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
if ActiveUnitInfo<>nil then begin
@ -9249,7 +9292,7 @@ begin
exit;
end;
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
{$IFDEF IDE_DEBUG}
DebugLn('TMainIDE.DoSaveProject A SaveAs=',dbgs(sfSaveAs in Flags),' SaveToTestDir=',dbgs(sfSaveToTestDir in Flags),' ProjectInfoFile=',Project1.ProjectInfoFile);
@ -9462,7 +9505,7 @@ begin
Project1:=CreateProjectObject(ProjectDescriptorProgram,
ProjectDescriptorProgram);
LastEditorIndex:=-1;
SourceNoteBook.IncUpdateLock;
SourceEditorManager.IncUpdateLock;
try
Project1.BeginUpdate(true);
try
@ -9504,7 +9547,7 @@ begin
AnUnitInfo:=Project1.FirstUnitWithEditorIndex;
while AnUnitInfo<>nil do begin
if (AnUnitInfo.Loaded)
and (SourceNotebook.FindSourceEditorWithFilename(AnUnitInfo.Filename)=nil)
and (SourceEditorManager.SourceEditorIntfWithFilename(AnUnitInfo.Filename)=nil)
then begin
if (AnUnitInfo.EditorIndex>LastEditorIndex)
and ((AnUnitInfo.EditorIndex<LowestEditorIndex)
@ -9533,7 +9576,7 @@ begin
end;
end;
if ((AnUnitInfo.Filename<>'')
and (SourceNotebook.FindSourceEditorWithFilename(AnUnitInfo.Filename)<>nil))
and (SourceEditorManager.SourceEditorIntfWithFilename(AnUnitInfo.Filename)<>nil))
then begin
// open source was successful (at least the source)
LastEditorIndex:=LowestEditorIndex;
@ -9574,6 +9617,9 @@ begin
// session info is invalid (buggy lps file?) => auto fix
Project1.ActiveWindowIndexAtStart:=0;
end;
if (Project1.ActiveWindowIndexAtStart >= 0) and
(Project1.ActiveWindowIndexAtStart < SourceEditorManager.SourceWindowCount)
then
SourceEditorManager.ActiveSourceWindow :=
SourceEditorManager.SourceWindows[Project1.ActiveWindowIndexAtStart];
@ -9590,7 +9636,7 @@ begin
IDEProtocolOpts.LastProjectLoadingCrashed := False;
Result:=mrOk;
finally
SourceNoteBook.DecUpdateLock;
SourceEditorManager.DecUpdateLock;
if (Result<>mrOk) and (Project1<>nil) then begin
// mark all files, that are left to open as unloaded:
for i:=0 to Project1.UnitCount-1 do begin
@ -10555,7 +10601,7 @@ function TMainIDE.SomethingOfProjectIsModified: boolean;
begin
Result:=(Project1<>nil)
and (Project1.SomethingModified(true,true)
or SourceNotebook.SomethingModified);
or SourceEditorManager.SomethingModified);
end;
function TMainIDE.DoSaveAll(Flags: TSaveFlags): TModalResult;
@ -11243,7 +11289,7 @@ begin
exit;
end;
// load the pascal unit
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
Result:=LoadCodeBuffer(PascalBuf,UnitFilename,[],false);
if Result<>mrOk then exit;
@ -11412,7 +11458,7 @@ begin
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
if (ActiveUnitInfo=nil) or (ActiveUnitInfo.Source=nil)
or (ActiveSrcEdit=nil) then exit;
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
CodeToolBoss.VisibleEditorLines:=ActiveSrcEdit.EditorComponent.LinesInWindow;
if CodeToolBoss.CheckSyntax(ActiveUnitInfo.Source,NewCode,NewX,NewY,
NewTopLine,ErrorMsg) then
@ -11432,10 +11478,11 @@ end;
procedure TMainIDE.GetCurrentUnit(out ActiveSourceEditor:TSourceEditor;
out ActiveUnitInfo:TUnitInfo);
begin
GetUnitWithPageIndex(
SourceEditorManager.ActiveSourceWindow.PageIndex,
SourceEditorManager.ActiveSourceWindowIndex, ActiveSourceEditor,
ActiveUnitInfo);
ActiveSourceEditor := SourceEditorManager.ActiveEditor;
if ActiveSourceEditor=nil then
ActiveUnitInfo:=nil
else
ActiveUnitInfo := Project1.UnitWithEditorComponent(ActiveSourceEditor);
end;
procedure TMainIDE.GetUnitWithPageIndex(PageIndex, WindowIndex:integer;
@ -11849,7 +11896,7 @@ var
begin
// hide hints
Application.HideHint;
SourceNotebook.HideHint;
SourceEditorManager.HideHint;
// hide designer forms
HideUnmodifiedDesigners;
@ -11971,16 +12018,16 @@ procedure TMainIDE.DoShowSourceOfActiveDesignerForm;
var
ActiveUnitInfo: TUnitInfo;
begin
if SourceNoteBook.PageCount = 0 then exit;
if SourceEditorManager.SourceEditorCount = 0 then exit;
if FLastFormActivated <> nil then begin
ActiveUnitInfo:= Project1.UnitWithComponent(
TDesigner(FLastFormActivated.Designer).LookupRoot);
if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.EditorIndex >= 0) then
if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.EditorComponent <> nil) then
begin
SourceNotebook.PageIndex:= ActiveUnitInfo.EditorIndex;
SourceEditorManager.ActiveEditor := TSourceEditor(ActiveUnitInfo.EditorComponent);
end;
end;
SourceEditorManager.ActiveSourceWindow.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
FDisplayState:= dsSource;
end;
@ -12000,7 +12047,7 @@ begin
MacroLName:=lowercase(MacroName);
Handled:=true;
if MacroLName='save' then begin
if (SourceNoteBook<>nil) and (SourceNoteBook.PageCount > 0) then
if (SourceEditorManager<>nil) and (SourceEditorManager.SourceEditorCount > 0) then
Abort:=(DoSaveEditorFile(SourceEditorManager.ActiveEditor,
[sfCheckAmbiguousFiles]) <> mrOk);
s:='';
@ -12108,17 +12155,15 @@ begin
Result:=(DoOpenEditorFile(SearchedFilename,-1,-1,OpenFlags)=mrOk);
if Result then begin
// set caret position
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
SrcEdit:=SourceEditorManager.ActiveEditor;
if LogCaretXY.Y>SrcEdit.EditorComponent.Lines.Count then
LogCaretXY.Y:=SrcEdit.EditorComponent.Lines.Count;
TopLine:=LogCaretXY.Y-(SrcEdit.EditorComponent.LinesInWindow div 2);
if TopLine<1 then TopLine:=1;
if FocusEditor then begin
//SourceNotebook.BringToFront;
MessagesView.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.FocusEditor;
SourceEditorManager.ShowActiveWindowOnTop(True);
end;
SrcEdit.EditorComponent.LogicalCaretXY:=LogCaretXY;
SrcEdit.EditorComponent.TopLine:=TopLine;
@ -12210,17 +12255,15 @@ begin
Result:=(DoOpenEditorFile(SearchedFilename,-1,-1,OpenFlags)=mrOk);
if Result then begin
// set caret position
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
SrcEdit:=SourceEditorManager.ActiveEditor;
if LogCaretXY.Y>SrcEdit.EditorComponent.Lines.Count then
LogCaretXY.Y:=SrcEdit.EditorComponent.Lines.Count;
TopLine:=LogCaretXY.Y-(SrcEdit.EditorComponent.LinesInWindow div 2);
if TopLine<1 then TopLine:=1;
if FocusEditor then begin
//SourceNotebook.BringToFront;
SearchResultsView.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.FocusEditor;
SourceEditorManager.ShowActiveWindowOnTop(True);
end;
SrcEdit.EditorComponent.LogicalCaretXY:=LogCaretXY;
SrcEdit.EditorComponent.TopLine:=TopLine;
@ -12266,7 +12309,7 @@ begin
// the sourcenotebook is more interesting than the messages
// TODO: don't do this when messages content intersect the editor content
SourceNotebook.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
end;
//set the event here for the selectionchanged event
@ -12286,7 +12329,7 @@ begin
ALayout.Apply;
if not WasVisible then
// the sourcenotebook is more interesting than the messages
SourceNotebook.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
//set the event here for the selectionchanged event
if not assigned(SearchresultsView.OnSelectionChanged) then
@ -12294,20 +12337,24 @@ begin
end;
procedure TMainIDE.DoArrangeSourceEditorAndMessageView(PutOnTop: boolean);
var
SrcNoteBook: TSourceNotebook;
begin
DoShowMessagesView;
if SourceEditorManager.SourceWindowCount = 0 then exit;
SrcNoteBook := SourceEditorManager.SourceWindows[0];
if (iwpDefault = EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(
nmiwSourceNoteBookName).WindowPlacement)
and ((SourceNotebook.Top + SourceNotebook.Height) > MessagesView.Top)
and ((SrcNoteBook.Top + SrcNoteBook.Height) > MessagesView.Top)
and (MessagesView.Parent = nil) then
SourceNotebook.Height := Max(50,Min(SourceNotebook.Height,
MessagesView.Top-SourceNotebook.Top));
SrcNoteBook.Height := Max(50,Min(SrcNoteBook.Height,
MessagesView.Top-SrcNoteBook.Top));
if PutOnTop then
begin
if MessagesView.Parent = nil then
MessagesView.ShowOnTop;
SourceNotebook.ShowOnTop;
SourceEditorManager.ShowActiveWindowOnTop(False);
end;
end;
@ -12717,7 +12764,7 @@ begin
MarkUnitsModifiedUsingSubComponent(TComponent(APersistent));
// remember cursor position
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
// remove component definition from owner source
OwnerClassName:=CurDesigner.LookupRoot.ClassName;
@ -12744,7 +12791,7 @@ begin
if SrcEdit <> nil then
begin
SrcEdit.Modified := True;
SourceNotebook.UpdateStatusBar;
SrcEdit.SourceNotebook.UpdateStatusBar;
{$IFDEF VerboseDesignerModified}
DumpStack;
{$ENDIF}
@ -12798,7 +12845,7 @@ end;
procedure TMainIDE.UnitDependenciesViewAccessingSources(Sender: TObject);
begin
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
end;
function TMainIDE.UnitDependenciesViewGetProjectMainFilename(Sender: TObject
@ -13079,7 +13126,7 @@ begin
end;
end;
// lock all editors
SourceNoteBook.LockAllEditorsInSourceChangeCache;
SourceEditorManager.LockAllEditorsInSourceChangeCache;
end;
procedure TMainIDE.OnAfterCodeToolBossApplyChanges(Manager: TCodeToolManager);
@ -13104,7 +13151,7 @@ begin
if MsgResult=mrAbort then break;
end;
end;
SourceNoteBook.UnlockAllEditorsInSourceChangeCache;
SourceEditorManager.UnlockAllEditorsInSourceChangeCache;
end;
function TMainIDE.OnCodeToolBossSearchUsedUnit(const SrcFilename: string;
@ -13349,40 +13396,38 @@ end;
function TMainIDE.SaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean;
begin
Result := SaveSourceEditorChangesToCodeCache(PageIndex,
SourceEditorManager.ActiveSourceWindowIndex);
Result := SaveSourceEditorChangesToCodeCache(
SourceEditorManager.ActiveSourceWindow.FindSourceEditorWithPageIndex(PageIndex));
end;
function TMainIDE.SaveSourceEditorChangesToCodeCache(PageIndex,
WindowIndex: integer): boolean;
function TMainIDE.SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean;
// save all open sources to code tools cache
var i,j: integer;
procedure SaveChanges(APageIndex, AWindowIndex: integer);
procedure SaveChanges(SaveEditor: TSourceEditorInterface);
var
SrcEdit: TSourceEditor;
AnUnitInfo: TUnitInfo;
begin
GetUnitWithPageIndex(APageIndex, AWindowIndex,SrcEdit,AnUnitInfo);
if (SrcEdit<>nil) and (AnUnitInfo<>nil) then
AnUnitInfo := Project1.UnitWithEditorComponent(SaveEditor);
if (AnUnitInfo<>nil) then
begin
SaveSourceEditorChangesToCodeCache:=true;
if SrcEdit.NeedsUpdateCodeBuffer then
if SaveEditor.NeedsUpdateCodeBuffer then
begin
SrcEdit.UpdateCodeBuffer;
SaveEditor.UpdateCodeBuffer;
AnUnitInfo.Modified:=true;
end;
end;
end;
var
i: integer;
begin
Result:=false;
if PageIndex<0 then begin
for i:=0 to SourceEditorManager.SourceWindowCount - 1 do
for j:=0 to SourceEditorManager.SourceWindows[i].PageCount - 1 do
SaveChanges(j, i);
if AEditor = nil then begin
for i:=0 to SourceEditorManager.SourceEditorCount - 1 do
SaveChanges(SourceEditorManager.SourceEditors[i]);
end else begin
SaveChanges(PageIndex, WindowIndex);
SaveChanges(AEditor);
end;
end;
@ -13405,7 +13450,7 @@ begin
debugln('TMainIDE.BeginCodeTool impossible ',dbgs(ord(ToolStatus)));
exit;
end;
if (not (ctfSourceEditorNotNeeded in Flags)) and (SourceNoteBook.PageCount=0)
if (not (ctfSourceEditorNotNeeded in Flags)) and (SourceEditorManager.SourceEditorCount=0)
then begin
DebugLn('TMainIDE.BeginCodeTool no editor');
exit;
@ -13422,7 +13467,7 @@ begin
and ((ActiveSrcEdit=nil) or (ActiveUnitInfo=nil)) then exit;
// init codetools
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
if ActiveSrcEdit<>nil then begin
CodeToolBoss.VisibleEditorLines:=ActiveSrcEdit.EditorComponent.LinesInWindow;
CodeToolBoss.TabWidth:=ActiveSrcEdit.EditorComponent.TabWidth;
@ -13472,7 +13517,7 @@ begin
if (NewSource<>ActiveUnitInfo.Source)
or (ActiveSrcEdit.EditorComponent.CaretX<>NewX)
or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
end;
if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source)
@ -13503,11 +13548,8 @@ begin
if MarkLine then
NewSrcEdit.ErrorLine := NewY;
if FocusEditor
then begin
SourceEditorManager.ActiveSourceWindow.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.FocusEditor;
end;
if FocusEditor then
SourceEditorManager.ShowActiveWindowOnTop(True);
UpdateSourceNames;
Result:=mrOk;
end;
@ -13521,12 +13563,14 @@ end;
-------------------------------------------------------------------------------}
procedure TMainIDE.UpdateSourceNames;
var
PageIndex: integer;
i: integer;
AnUnitInfo: TUnitInfo;
SourceName, PageName: string;
AEditor: TSourceEditor;
begin
for PageIndex:=0 to SourceNotebook.PageCount-1 do begin
AnUnitInfo:=Project1.UnitWithEditorIndex(PageIndex);
for i:=0 to SourceEditorManager.SourceEditorCount-1 do begin
AEditor := SourceEditorManager.SourceEditors[i];
AnUnitInfo := Project1.UnitWithEditorComponent(AEditor);
if AnUnitInfo=nil then continue;
if FilenameIsPascalUnit(AnUnitInfo.Filename) then begin
SourceName:=CodeToolBoss.GetCachedSourceName(AnUnitInfo.Source);
@ -13534,30 +13578,29 @@ begin
AnUnitInfo.ReadUnitNameFromSource(true);
end else
SourceName:='';
PageName:=CreateSrcEditPageName(SourceName,AnUnitInfo.Filename,PageIndex);
SourceNotebook.FindSourceEditorWithPageIndex(PageIndex).PageName:=PageName;
PageName:=CreateSrcEditPageName(SourceName, AnUnitInfo.Filename, AEditor);
AEditor.PageName := PageName;
end;
end;
function TMainIDE.NeedSaveSourceEditorChangesToCodeCache(PageIndex: integer
): boolean;
begin
Result := NeedSaveSourceEditorChangesToCodeCache(PageIndex,
SourceEditorManager.ActiveSourceWindowIndex);
Result := NeedSaveSourceEditorChangesToCodeCache(
SourceEditorManager.ActiveSourceWindow.FindSourceEditorWithPageIndex(PageIndex));
end;
function TMainIDE.NeedSaveSourceEditorChangesToCodeCache(PageIndex,
WindowIndex: integer): boolean;
function TMainIDE.NeedSaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean;
// check if any open source needs to be saved to code tools cache
var i, j: integer;
function NeedSave(APageIndex, AWindowIndex: integer): boolean;
var
SrcEdit: TSourceEditor;
i: integer;
function NeedSave(SaveEditor: TSourceEditorInterface): boolean;
var
AnUnitInfo: TUnitInfo;
begin
GetUnitWithPageIndex(APageIndex, AWindowIndex,SrcEdit,AnUnitInfo);
if (SrcEdit<>nil) and (AnUnitInfo<>nil) and SrcEdit.NeedsUpdateCodeBuffer then
AnUnitInfo := Project1.UnitWithEditorComponent(SaveEditor);
if (AnUnitInfo<>nil) and SaveEditor.NeedsUpdateCodeBuffer then
Result:=true
else
Result:=false;
@ -13565,12 +13608,11 @@ var i, j: integer;
begin
Result:=true;
if PageIndex<0 then begin
for i:=0 to SourceEditorManager.SourceWindowCount - 1 do
for j:=0 to SourceEditorManager.SourceWindows[i].PageCount - 1 do
if NeedSave(j, i) then exit;
if AEditor = nil then begin
for i := 0 to SourceEditorManager.SourceEditorCount - 1 do
if NeedSave(SourceEditorManager.SourceEditors[i]) then exit;
end else begin
if NeedSave(PageIndex, WindowIndex) then exit;
if NeedSave(AEditor) then exit;
end;
Result:=false;
end;
@ -13640,7 +13682,7 @@ begin
ErrorCaret:=Point(CodeToolBoss.ErrorColumn,CodeToolBoss.ErrorLine);
ErrorFilename:=CodeToolBoss.ErrorCode.Filename;
ErrorTopLine:=CodeToolBoss.ErrorTopLine;
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
OpenFlags:=[ofOnlyIfExists,ofUseCache];
if CodeToolBoss.ErrorCode.IsVirtual then
Include(OpenFlags,ofVirtualFile);
@ -13648,13 +13690,12 @@ begin
then begin
ActiveSrcEdit:=SourceEditorManager.ActiveEditor;
MessagesView.ShowOnTop;
SourceEditorManager.ActiveSourceWindow.ShowOnTop;
with ActiveSrcEdit.EditorComponent do begin
LogicalCaretXY:=ErrorCaret;
if ErrorTopLine>0 then
TopLine:=ErrorTopLine;
end;
SourceEditorManager.ActiveSourceWindow.FocusEditor;
SourceEditorManager.ShowActiveWindowOnTop(True);
SourceEditorManager.ClearErrorLines;
ActiveSrcEdit.ErrorLine:=ErrorCaret.Y;
end;
@ -14241,20 +14282,16 @@ var
ActiveUnitInfo: TUnitInfo;
OpenDiffInEditor: boolean;
DiffText: string;
Files: TDiffFiles;
NewDiffFilename: String;
begin
Result:=mrCancel;
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
if ActiveSrcEdit=nil then exit;
Files:=SourceNoteBook.GetDiffFiles;
Result:=ShowDiffDialog(Files,ActiveSrcEdit.PageIndex,
@SourceNotebook.GetSourceText,
Result:=ShowDiffDialog(ActiveSrcEdit.PageIndex,
OpenDiffInEditor,DiffText);
Files.Free;
if OpenDiffInEditor then begin
NewDiffFilename:=CreateSrcEditPageName('','diff.txt',-1);
NewDiffFilename:=CreateSrcEditPageName('','diff.txt', nil);
Result:=DoNewEditorFile(FileDescriptorText,NewDiffFilename,DiffText,
[nfOpenInEditor]);
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
@ -14356,19 +14393,18 @@ end;
procedure TMainIDE.JumpHistoryViewSelectionChanged(sender : TObject);
begin
SourceNotebook.HistoryJump(self, jhaViewWindow);
SourceNoteBook.ShowOnTop;
SourceNotebook.FocusEditor;
SourceEditorManager.HistoryJump(self, jhaViewWindow);
SourceEditorManager.ShowActiveWindowOnTop(True);
end;
Procedure TMainIDE.OnSrcNotebookEditorVisibleChanged(Sender: TObject);
var
ActiveUnitInfo: TUnitInfo;
begin
if SourceNotebook.PageCount = 0 then Exit;
if SourceEditorManager.SourceEditorCount = 0 then Exit;
ActiveUnitInfo :=
Project1.UnitWithEditorIndex(SourceNotebook.PageIndex);
Project1.UnitWithEditorComponent(SourceEditorManager.ActiveEditor);
if ActiveUnitInfo = nil then Exit;
UpdateSaveMenuItemsAndButtons(false);
@ -14381,13 +14417,13 @@ end;
//this is fired when the editor is focused, changed, ?. Anything that causes the status change
procedure TMainIDE.OnSrcNotebookEditorChanged(Sender: TObject);
begin
if SourceNotebook.PageCount = 0 then Exit;
if SourceEditorManager.SourceEditorCount = 0 then Exit;
UpdateSaveMenuItemsAndButtons(false);
end;
procedure TMainIDE.OnSrcNotebookCurCodeBufferChanged(Sender: TObject);
begin
if SourceNotebook.PageCount = 0 then Exit;
if SourceEditorManager.SourceEditorCount = 0 then Exit;
if CodeExplorerView<>nil then CodeExplorerView.CurrentCodeBufferChanged;
end;
@ -14812,7 +14848,7 @@ begin
debugln('TMainIDE.OnDesignerViewLFM ',AnUnitInfo.Filename);
OnDesignerCloseQuery(Sender);
DoOpenEditorFile(ChangeFileExt(AnUnitInfo.Filename, '.lfm'),
AnUnitInfo.EditorIndex+1,[]);
AnUnitInfo.EditorIndex+1, AnUnitInfo.WindowIndex, []);
end;
procedure TMainIDE.OnDesignerSaveAsXML(Sender: TObject);
@ -14883,7 +14919,7 @@ begin
end;
Procedure TMainIDE.OnSrcNoteBookAddJumpPoint(ACaretXY: TPoint;
ATopLine: integer; APageIndex: integer; DeleteForwardHistory: boolean);
ATopLine: integer; AEditor: TSourceEditor; DeleteForwardHistory: boolean);
{off $DEFINE VerboseJumpHistory}
var
ActiveUnitInfo: TUnitInfo;
@ -14893,7 +14929,7 @@ begin
writeln('');
writeln('[TMainIDE.OnSrcNoteBookAddJumpPoint] A Line=',ACaretXY.Y,' Col=',ACaretXY.X,' DeleteForwardHistory=',DeleteForwardHistory,' Count=',Project1.JumpHistory.Count,',HistoryIndex=',Project1.JumpHistory.HistoryIndex);
{$ENDIF}
ActiveUnitInfo:=Project1.UnitWithEditorIndex(APageIndex);
ActiveUnitInfo:=Project1.UnitWithEditorComponent(AEditor);
if (ActiveUnitInfo=nil) then exit;
NewJumpPoint:=TProjectJumpHistoryPosition.Create(ActiveUnitInfo.Filename,
ACaretXY,ATopLine);
@ -14919,7 +14955,7 @@ begin
end;
Procedure TMainIDE.OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint;
var NewTopLine, NewPageIndex: integer; JumpAction: TJumpHistoryAction);
var NewTopLine: integer; var DestEditor: TSourceEditor; JumpAction: TJumpHistoryAction);
{ How the HistoryIndex works:
When the user jumps around each time an item is added to the history list
@ -14943,7 +14979,7 @@ var DestIndex, UnitIndex: integer;
CursorPoint, NewJumpPoint: TProjectJumpHistoryPosition;
JumpHistory : TProjectJumpHistory;
begin
NewPageIndex:=-1;
DestEditor := nil;
NewCaretXY.Y:=-1;
JumpHistory:=Project1.JumpHistory;
@ -15005,7 +15041,7 @@ begin
JumpHistory.HistoryIndex:=DestIndex;
NewCaretXY:=DestJumpPoint.CaretXY;
NewTopLine:=DestJumpPoint.TopLine;
NewPageIndex:=Project1.Units[UnitIndex].EditorIndex;
DestEditor:=TSourceEditor(Project1.Units[UnitIndex].EditorComponent);
{$IFDEF VerboseJumpHistory}
writeln('[TMainIDE.OnSrcNotebookJumpToHistoryPoint] Result Line=',NewCaretXY.Y,' Col=',NewCaretXY.X);
{$ENDIF}
@ -15434,7 +15470,6 @@ end;
procedure TMainIDE.DoSwitchToFormSrc(ADesigner: TDesigner;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
var i: integer;
begin
ActiveSourceEditor:=nil;
ActiveUnitInfo:=nil;
@ -15446,15 +15481,12 @@ begin
Project1.UnitWithComponent(TComponent(GlobalDesignHook.LookupRoot))
else
ActiveUnitInfo:=nil;
if (ActiveUnitInfo<>nil) then begin
i:=ActiveUnitInfo.EditorIndex;
if (i>=0) then begin
SourceNoteBook.PageIndex:=i;
if (ActiveUnitInfo<>nil) and (ActiveUnitInfo.EditorComponent <> nil) then begin
SourceEditorManagerIntf.ActiveEditor := ActiveUnitInfo.EditorComponent;
GetCurrentUnit(ActiveSourceEditor,ActiveUnitInfo);
exit;
end;
end;
end;
function TMainIDE.GetDesignerFormOfSource(AnUnitInfo: TUnitInfo; LoadForm: boolean
): TCustomForm;
@ -15799,7 +15831,7 @@ begin
then exit;
// remember cursor position
SourceNotebook.AddJumpPointClicked(Self);
SourceEditorManager.AddJumpPointClicked(Self);
// add needed package to required packages
if ADesigner.LookupRoot.ComponentCount>0 then
@ -16256,7 +16288,7 @@ begin
//DebugLn(['TMainIDE.DoReplaceUnitUse ',Files.Text]);
// commit source editor to codetools
SaveSourceEditorChangesToCodeCache(-1, -1);
SaveSourceEditorChangesToCodeCache(nil);
// load or create old unit
OldCode:=CodeToolBoss.LoadFile(OldFilename,true,false);
@ -16328,6 +16360,7 @@ var
DockingAllowed: Boolean;
NewHeight: Integer;
NewBounds: TRect;
SrcNoteBook: TSourceNotebook;
begin
if (ALayout=nil) or (ALayout.Form=nil) then exit;
// debugln('TMainIDE.OnApplyWindowLayout ',ALayout.Form.Name,' ',ALayout.Form.Classname,' ',IDEWindowPlacementNames[ALayout.WindowPlacement],' ',ALayout.CustomCoordinatesAreValid,' ',ALayout.Left,' ',ALayout.Top,' ',ALayout.Width,' ',ALayout.Height);
@ -16427,8 +16460,12 @@ begin
ALayout.Form.SetBounds(200,150,400,300);
nmiwMessagesViewName:
begin
ALayout.Form.SetBounds(250,SourceNotebook.Top+SourceNotebook.Height+30,
if SourceEditorManager.SourceWindowCount > 0 then begin
SrcNoteBook := SourceEditorManager.SourceWindows[0];
ALayout.Form.SetBounds(250,SrcNoteBook.Top+SrcNoteBook.Height+30,
Max(50,Screen.Width-300),80);
end else
ALayout.Form.SetBounds(250,Screen.Height - 110, Max(50,Screen.Width-300),80);
end;
else
if ALayout.FormID=DefaultObjectInspectorName then begin

View File

@ -145,6 +145,7 @@ type
out ActiveUnitInfo: TUnitInfo); virtual; abstract;
procedure GetUnitWithPageIndex(PageIndex, WindowIndex: integer;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); virtual; abstract;
deprecated; // deprecated in 0.9.29 March 2010
procedure GetDesignerUnit(ADesigner: TDesigner;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); virtual; abstract;
procedure GetObjectInspectorUnit(

View File

@ -114,7 +114,7 @@ begin
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
if not CodeToolBoss.RemoveUnitFromAllUsesSections(CodeBuf,UnneededUnitname)
then begin
LazarusIDE.DoJumpToCodeToolBossError;
@ -229,7 +229,7 @@ begin
end;
end;
end;
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
if not CodeToolBoss.FindUnitInAllUsesSections(CodeBuf,MissingUnitname,
NamePos,InPos)
then begin
@ -366,7 +366,7 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
exit;
end;
LazarusIDE.DoOpenFileAndJumpToPos(NewCode.Filename,Point(NewX,NewY),
NewTopLine,-1,[]);
NewTopLine,-1,-1,[]);
end;
begin
@ -458,7 +458,7 @@ begin
DebugLn(['TQuickFixClassWithAbstractMethods.Execute Declaration at ',NewCode.Filename,' ',NewX,',',NewY]);
if LazarusIDE.DoOpenFileAndJumpToPos(NewCode.Filename,
Point(NewX,NewY),NewTopLine,-1,[])<>mrOk
Point(NewX,NewY),NewTopLine,-1,-1,[])<>mrOk
then begin
DebugLn(['TQuickFixClassWithAbstractMethods.Execute failed opening ',NewCode.Filename]);
exit;

View File

@ -138,7 +138,7 @@ begin
if frm.ModalResult = mrOK then // we need to jump
begin
LazarusIDE.DoOpenFileAndJumpToPos(frm.Caret.Code.Filename,
Point(frm.Caret.X, frm.Caret.Y), frm.NewTopLine, -1,
Point(frm.Caret.X, frm.Caret.Y), frm.NewTopLine, -1,-1,
[ofRegularFile,ofUseCache]);
end;
finally

View File

@ -362,7 +362,7 @@ var
GetSrcEditPos;
if LazarusIDE.DoOpenFileAndJumpToPos(TheFileName,SrcEditStartPos,
-1,-1,[ofUseCache,ofDoNotLoadResource,ofVirtualFile,ofRegularFile])
-1,-1,-1,[ofUseCache,ofDoNotLoadResource,ofVirtualFile,ofRegularFile])
<>mrOk then
begin
DoAbort;

File diff suppressed because it is too large Load Diff

View File

@ -559,7 +559,7 @@ begin
if Assigned(OnOpenFile) then
OnOpenFile(Self,CurFilename,TheLine)
else
LazarusIDE.DoOpenFileAndJumpToPos(CurFilename,Point(1,TheLine),-1,-1,
LazarusIDE.DoOpenFileAndJumpToPos(CurFilename,Point(1,TheLine),-1,-1,-1,
[ofOnlyIfExists,ofRegularFile,ofVirtualFile,ofDoNotLoadResource]);
end;
end;
@ -619,7 +619,7 @@ begin
//DebugLn(['TfrmTodo.acRefreshExecute MainSourceFilename=',MainSourceFilename]);
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1,-1);
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
Screen.Cursor:=crHourGlass;
Owners:=nil;

View File

@ -183,24 +183,34 @@ type
var NewFilename: string; const NewSource: string;
NewFlags: TNewFlags; NewOwner: TObject): TModalResult; virtual; abstract;
function DoSaveEditorFile(PageIndex:integer;
Flags: TSaveFlags): TModalResult; virtual; abstract; deprecated;
Flags: TSaveFlags): TModalResult; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoSaveEditorFile(AEditor: TSourceEditorInterface;
Flags: TSaveFlags): TModalResult; virtual; abstract;
function DoCloseEditorFile(PageIndex:integer;
Flags: TCloseFlags):TModalResult; virtual; abstract; deprecated;
Flags: TCloseFlags):TModalResult; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoCloseEditorFile(AEditor: TSourceEditorInterface;
Flags: TCloseFlags):TModalResult; virtual; abstract;
function DoCloseEditorFile(const Filename: string;
Flags: TCloseFlags): TModalResult; virtual; abstract;
function DoOpenEditorFile(AFileName:string; PageIndex: integer;
Flags: TOpenFlags): TModalResult; virtual; abstract; deprecated;
Flags: TOpenFlags): TModalResult; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenEditorFile(AFileName:string; PageIndex, WindowIndex: integer;
Flags: TOpenFlags): TModalResult; virtual; abstract;
function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
PageIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
function DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer;
PageIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with WindowIndex'{$ENDIF}; // deprecated in 0.9.29 March 2010
function DoOpenFileAndJumpToPos(const AFilename: string;
const CursorPosition: TPoint; TopLine: integer;
PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
function DoRevertEditorFile(const Filename: string): TModalResult; virtual; abstract;
function DoOpenComponent(const UnitFilename: string; OpenFlags: TOpenFlags;
CloseFlags: TCloseFlags;
@ -236,10 +246,12 @@ type
function BeginCodeTools: boolean; virtual; abstract;
procedure DoJumpToCodeToolBossError; virtual; abstract;
function NeedSaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; virtual; abstract; deprecated;
function NeedSaveSourceEditorChangesToCodeCache(PageIndex, WindowIndex: integer): boolean; virtual; abstract;
function SaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; virtual; abstract; deprecated; // true if something was saved
function SaveSourceEditorChangesToCodeCache(PageIndex, WindowIndex: integer): boolean; virtual; abstract; // true if something was saved
function NeedSaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; virtual; abstract;
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function NeedSaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract;
function SaveSourceEditorChangesToCodeCache(PageIndex: integer): boolean; virtual; abstract; // true if something was saved
deprecated {$IFDEF VER2_5}'use method with EditorObject'{$ENDIF}; // deprecated in 0.9.29 March 2010
function SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract; // true if something was saved
property OpenEditorsOnCodeToolChange: boolean read FOpenEditorsOnCodeToolChange
write FOpenEditorsOnCodeToolChange;

View File

@ -176,27 +176,37 @@ type
function GetItems(Index: integer): TSourceEditorInterface; virtual; abstract;
procedure SetActiveEditor(const AValue: TSourceEditorInterface); virtual; abstract;
public
function SourceEditorIntfWithFilename(const Filename: string): TSourceEditorInterface; deprecated;
function SourceEditorIntfWithFilename(const Filename: string): TSourceEditorInterface;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
property ActiveEditor: TSourceEditorInterface
read GetActiveEditor write SetActiveEditor;
function Count: integer; virtual; abstract;
property Items[Index: integer]: TSourceEditorInterface read GetItems; default;
function GetEditorControlSettings(EditControl: TControl): boolean; virtual; abstract; deprecated;
function GetHighlighterSettings(Highlighter: TObject): boolean; virtual; abstract; deprecated;
procedure ClearErrorLines; virtual; abstract; deprecated;
function GetEditorControlSettings(EditControl: TControl): boolean; virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
function GetHighlighterSettings(Highlighter: TObject): boolean; virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
procedure ClearErrorLines; virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
property CompletionBoxPosition: integer read GetCompletionBoxPosition;
procedure DeactivateCompletionForm; virtual; abstract;
property ActiveCompletionPlugin: TSourceEditorCompletionPlugin read GetActiveCompletionPlugin;
// CompletionPlugin list moves to Manager
function CompletionPluginCount: integer; virtual; abstract; deprecated;
function CompletionPluginCount: integer; virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
property CompletionPlugins[Index: integer]: TSourceEditorCompletionPlugin
read GetCompletionPlugins; deprecated;
procedure RegisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract; deprecated;
procedure UnregisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract; deprecated;
read GetCompletionPlugins;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
procedure RegisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
procedure UnregisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract;
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
end;
TsemChangeReason = (semWindowCreate, semWindowDestroy);
TSourceEditorManagerInterface = class(TComponent)
protected
function GetActiveSourceWindow: TSourceEditorWindowInterface; virtual; abstract;
@ -246,10 +256,14 @@ type
property CompletionBoxPosition: integer read GetCompletionBoxPosition;
procedure RegisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract;
procedure UnregisterCompletionPlugin(Plugin: TSourceEditorCompletionPlugin); virtual; abstract;
public
procedure RegisterChangeEvent(AReason: TsemChangeReason; AHandler: TNotifyEvent); virtual; abstract;
procedure UnRegisterChangeEvent(AReason: TsemChangeReason; AHandler: TNotifyEvent); virtual; abstract;
end;
function SourceEditorWindow: TSourceEditorWindowInterface; // Returns the active window
deprecated {$IFDEF VER2_5}'use SourceEditorManagerIntf'{$ENDIF}; // deprecated in 0.9.29 March 2010
var
SourceEditorManagerIntf: TSourceEditorManagerInterface= nil; // set by the IDE

View File

@ -567,7 +567,7 @@ begin
Filename:=PkgFile.Filename;
MainIDE.DoOpenFileAndJumpToIdentifier(
Filename,PkgComponent.ComponentClass.ClassName,
-1, // open page somewhere
-1, -1, // open page somewhere
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofConvertMacros]);
end;
end;
@ -1060,7 +1060,7 @@ var
OldUnitName:=OldPkgName;
NewUnitName:=APackage.Name;
if (OldUnitName<>NewUnitName) then begin
MainIDEInterface.SaveSourceEditorChangesToCodeCache(-1, -1);
MainIDEInterface.SaveSourceEditorChangesToCodeCache(nil);
if CodeToolBoss.RenameUsedUnit(
AProject.MainUnitInfo.Source,OldUnitName,NewUnitName,'')
then
@ -1598,7 +1598,7 @@ begin
// create default values
TheUnitName:='';
HasRegisterProc:=false;
MainIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
MainIDE.SaveSourceEditorChangesToCodeCache(nil);
CodeBuffer:=CodeToolBoss.LoadFile(ExpFilename,true,false);
if CodeBuffer<>nil then begin
TheUnitName:=CodeToolBoss.GetSourceName(CodeBuffer,false);
@ -1723,7 +1723,7 @@ begin
and (AProject.MainUnitInfo<>nil) then begin
//debugln('TPkgManager.AddUnitToProjectMainUsesSection B ',AnUnitName);
if (AnUnitName<>'') then begin
MainIDEInterface.SaveSourceEditorChangesToCodeCache(-1, -1);
MainIDEInterface.SaveSourceEditorChangesToCodeCache(nil);
if CodeToolBoss.AddUnitToMainUsesSection(
AProject.MainUnitInfo.Source,AnUnitName,AnUnitInFilename)
then
@ -2521,7 +2521,7 @@ begin
if Result<>mrOk then exit;
// save editor files to codetools
MainIDE.SaveSourceEditorChangesToCodeCache(-1, -1);
MainIDE.SaveSourceEditorChangesToCodeCache(nil);
// save package
if (psfSaveAs in Flags) then begin
@ -4210,7 +4210,7 @@ begin
if (Project1.MainUnitID>=0)
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin
MainIDEInterface.SaveSourceEditorChangesToCodeCache(-1, -1);
MainIDEInterface.SaveSourceEditorChangesToCodeCache(nil);
ShortUnitName:=ADependency.PackageName;
//debugln('TPkgManager.OnProjectInspectorRemoveDependency B ShortUnitName="',ShortUnitName,'"');
if (ShortUnitName<>'') then begin