Ide/Project; SourceEditor: Start introducing SourceEditorManager (for multi-window handling)

git-svn-id: trunk@24039 -
This commit is contained in:
martin 2010-03-16 14:11:58 +00:00
parent a921ba21c8
commit ad943cb7a3
3 changed files with 592 additions and 228 deletions

View File

@ -1343,7 +1343,7 @@ begin
FreeAndNil(MessagesView);
FreeThenNil(AnchorDesigner);
FreeThenNil(ObjectInspector1);
FreeThenNil(SourceNotebook);
FreeThenNil(SourceEditorManagerIntf);
// disconnect handlers
Application.RemoveAllHandlersOfObject(Self);
@ -1888,33 +1888,33 @@ end;
procedure TMainIDE.SetupSourceNotebook;
begin
SourceNotebook := TSourceNotebook.Create(OwningComponent);
SourceNotebook.OnActivate := @OnSrcNoteBookActivated;
SourceNotebook.OnAddJumpPoint := @OnSrcNoteBookAddJumpPoint;
SourceNotebook.OnCloseClicked := @OnSrcNotebookFileClose;
SourceNotebook.OnClickLink := @OnSrcNoteBookClickLink;
SourceNotebook.OnMouseLink := @OnSrcNoteBookMouseLink;
SourceNotebook.OnGetIndent := @OnSrcNoteBookGetIndent;
SourceNotebook.OnCurrentCodeBufferChanged:=@OnSrcNotebookCurCodeBufferChanged;
SourceNotebook.OnDeleteLastJumpPoint := @OnSrcNotebookDeleteLastJumPoint;
SourceNotebook.OnEditorVisibleChanged := @OnSrcNotebookEditorVisibleChanged;
SourceNotebook.OnEditorChanged := @OnSrcNotebookEditorChanged;
SourceNotebook.OnEditorPropertiesClicked := @mnuEnvEditorOptionsClicked;
SourceNotebook.OnFindDeclarationClicked := @OnSrcNotebookFindDeclaration;
SourceNotebook.OnInitIdentCompletion :=@OnSrcNotebookInitIdentCompletion;
SourceNotebook.OnInsertTodoClicked := @mnuEditInsertTodo;
SourceNotebook.OnShowCodeContext :=@OnSrcNotebookShowCodeContext;
SourceNotebook.OnJumpToHistoryPoint := @OnSrcNotebookJumpToHistoryPoint;
SourceNotebook.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor;
SourceNotebook.OnProcessUserCommand := @OnProcessIDECommand;
SourceNotebook.OnReadOnlyChanged := @OnSrcNotebookReadOnlyChanged;
SourceNotebook.OnShowHintForSource := @OnSrcNotebookShowHintForSource;
SourceNotebook.OnShowUnitInfo := @OnSrcNoteBookShowUnitInfo;
SourceNotebook.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit;
SourceNotebook.OnToggleObjectInspClicked:= @OnSrcNotebookToggleObjectInsp;
SourceNotebook.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
SourceNotebook.OnShowSearchResultsView := @OnSrcNotebookShowSearchResultsView;
SourceNotebook.OnPopupMenu := @OnSrcNoteBookPopupMenu;
TSourceEditorManager.Create(OwningComponent);
SourceEditorManager.OnWindowActivate := @OnSrcNoteBookActivated;
SourceEditorManager.OnAddJumpPoint := @OnSrcNoteBookAddJumpPoint;
SourceEditorManager.OnCloseClicked := @OnSrcNotebookFileClose;
SourceEditorManager.OnClickLink := @OnSrcNoteBookClickLink;
SourceEditorManager.OnMouseLink := @OnSrcNoteBookMouseLink;
SourceEditorManager.OnGetIndent := @OnSrcNoteBookGetIndent;
SourceEditorManager.OnCurrentCodeBufferChanged:=@OnSrcNotebookCurCodeBufferChanged;
SourceEditorManager.OnDeleteLastJumpPoint := @OnSrcNotebookDeleteLastJumPoint;
SourceEditorManager.OnEditorVisibleChanged := @OnSrcNotebookEditorVisibleChanged;
SourceEditorManager.OnEditorChanged := @OnSrcNotebookEditorChanged;
SourceEditorManager.OnEditorPropertiesClicked := @mnuEnvEditorOptionsClicked;
SourceEditorManager.OnFindDeclarationClicked := @OnSrcNotebookFindDeclaration;
SourceEditorManager.OnInitIdentCompletion :=@OnSrcNotebookInitIdentCompletion;
SourceEditorManager.OnInsertTodoClicked := @mnuEditInsertTodo;
SourceEditorManager.OnShowCodeContext :=@OnSrcNotebookShowCodeContext;
SourceEditorManager.OnJumpToHistoryPoint := @OnSrcNotebookJumpToHistoryPoint;
SourceEditorManager.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor;
SourceEditorManager.OnProcessUserCommand := @OnProcessIDECommand;
SourceEditorManager.OnReadOnlyChanged := @OnSrcNotebookReadOnlyChanged;
SourceEditorManager.OnShowHintForSource := @OnSrcNotebookShowHintForSource;
SourceEditorManager.OnShowUnitInfo := @OnSrcNoteBookShowUnitInfo;
SourceEditorManager.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit;
SourceEditorManager.OnToggleObjectInspClicked:= @OnSrcNotebookToggleObjectInsp;
SourceEditorManager.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
SourceEditorManager.OnShowSearchResultsView := @OnSrcNotebookShowSearchResultsView;
SourceEditorManager.OnPopupMenu := @OnSrcNoteBookPopupMenu;
DebugBoss.ConnectSourceNotebookEvents;
// connect search menu to sourcenotebook
@ -3918,7 +3918,7 @@ begin
// save shortcuts to editor options
EnvironmentOptions.ExternalTools.SaveShortCuts(EditorOpts.KeyMap);
EditorOpts.Save;
SourceNotebook.ReloadEditorOptions;
SourceEditorManager.ReloadEditorOptions;
UpdateCustomToolsInMenu;
end;
end;
@ -4219,7 +4219,7 @@ begin
end;
if IDEOptionsDialog.ShowModal = mrOk then begin
IDEOptionsDialog.WriteAll;
SourceNotebook.ReloadEditorOptions;
SourceEditorManager.ReloadEditorOptions;
end;
finally
IDEOptionsDialog.Free;
@ -4335,7 +4335,7 @@ end;
procedure TMainIDE.DoEditorOptionsAfterWrite(Sender: TObject);
begin
Project1.UpdateAllSyntaxHighlighter;
SourceNotebook.ReloadEditorOptions;
SourceEditorManager.ReloadEditorOptions;
ReloadMenuShortCuts;
end;
@ -4491,7 +4491,7 @@ end;
procedure TMainIDE.mnuEnvCodeTemplatesClicked(Sender: TObject);
begin
if ShowCodeTemplateDialog=mrOk then
SourceNotebook.ReloadEditorOptions;
SourceEditorManager.ReloadEditorOptions;
end;
procedure TMainIDE.mnuEnvCodeToolsDefinesEditorClicked(Sender: TObject);

View File

@ -216,6 +216,7 @@ type
FSourceDirectoryReferenced: boolean;
FSourceDirNeedReference: boolean;
fLastDirectoryReferenced: string;
FWindowIndex: integer;
function GetHasResources:boolean;
function GetModified: boolean;
@ -244,6 +245,7 @@ type
procedure SetSource(ABuffer: TCodeBuffer);
procedure SetUnitName(const NewUnitName:string);
procedure SetUserReadOnly(const NewValue: boolean);
procedure SetWindowIndex(const AValue: integer);
protected
function GetFileName: string; override;
procedure SetFilename(const AValue: string); override;
@ -340,7 +342,9 @@ type
property CustomHighlighter: boolean
read fCustomHighlighter write fCustomHighlighter;
property Directives: TStrings read FDirectives write SetDirectives;
property EditorIndex: integer read fEditorIndex write SetEditorIndex;
property EditorIndex: integer read FEditorIndex write SetEditorIndex;
property WindowIndex: integer read FWindowIndex write SetWindowIndex;
property EditorComponent: TSourceEditorInterface
read FEditorComponent write SetEditorComponent;
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
@ -998,7 +1002,9 @@ end;
function CompareUnitInfoWithEditorIndex(Unit1, Unit2: TUnitInfo): integer;
begin
Result:=Unit1.EditorIndex-Unit2.EditorIndex;
Result := Unit1.WindowIndex - Unit2.WindowIndex;
if Result = 0 then
Result := Unit1.EditorIndex - Unit2.EditorIndex;
end;
{------------------------------------------------------------------------------
@ -1154,6 +1160,8 @@ begin
fCursorPos.Y := -1;
fCustomHighlighter := false;
fEditorIndex := -1;
FWindowIndex := -1;
fFilename := '';
fFileReadOnly := false;
fHasResources := false;
@ -1251,6 +1259,8 @@ begin
XMLConfig.SetDeleteValue(Path+'CursorPos/Y',fCursorPos.Y,-1);
XMLConfig.SetDeleteValue(Path+'TopLine/Value',fTopLine,-1);
XMLConfig.SetDeleteValue(Path+'EditorIndex/Value',fEditorIndex,-1);
XMLConfig.SetDeleteValue(Path+'WindowIndex/Value',FWindowIndex,-1);
XMLConfig.SetDeleteValue(Path+'UsageCount/Value',RoundToInt(fUsageCount),-1);
FBookmarks.SaveToXMLConfig(XMLConfig,Path+'Bookmarks/');
XMLConfig.SetDeleteValue(Path+'Loaded/Value',fLoaded,false);
@ -1306,6 +1316,8 @@ begin
CursorPos:=Point(XMLConfig.GetValue(Path+'CursorPos/X',-1),
XMLConfig.GetValue(Path+'CursorPos/Y',-1));
EditorIndex:=XMLConfig.GetValue(Path+'EditorIndex/Value',-1);
WindowIndex:=XMLConfig.GetValue(Path+'WindowIndex/Value',-1);
Loaded:=XMLConfig.GetValue(Path+'Loaded/Value',false);
fUserReadOnly:=XMLConfig.GetValue(Path+'ReadOnly/Value',false);
@ -1804,8 +1816,10 @@ end;
procedure TUnitInfo.SetEditorComponent(const AEditor: TSourceEditorInterface);
begin
if FEditorComponent = AEditor then exit;
if AEditor = nil then
if AEditor = nil then begin
EditorIndex := -1;
WindowIndex := -1;
end;
FEditorComponent := AEditor;
UpdateList(uilWithEditorIndex, FEditorComponent <> nil);
if AEditor <> nil then
@ -1835,6 +1849,13 @@ begin
SessionModified:=true;
end;
procedure TUnitInfo.SetWindowIndex(const AValue: integer);
begin
if FWindowIndex = AValue then exit;
FWindowIndex := AValue;
SessionModified := true;
end;
procedure TUnitInfo.SetFileReadOnly(const AValue: Boolean);
begin
if fFileReadOnly=AValue then exit;

File diff suppressed because it is too large Load Diff