From 97caca883213a47c4ca849d9355054d85e646dc6 Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 5 Jun 2011 18:34:11 +0000 Subject: [PATCH] DBG, SourceEditor: Prevent moving focus for auto continue breakpoints git-svn-id: trunk@31101 - --- ide/main.pp | 131 +++++++++++++++++++++++--------------------- ide/sourceeditor.pp | 24 +++++++- 2 files changed, 91 insertions(+), 64 deletions(-) diff --git a/ide/main.pp b/ide/main.pp index 9aa1e5e425..4c1273ca47 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -14876,71 +14876,76 @@ begin exit; end; - if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then - GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo); - - if AddJumpPoint and (ActiveUnitInfo <> nil) and (ActiveSrcEdit <> nil) - then begin - if (NewSource<>ActiveUnitInfo.Source) - or (ActiveSrcEdit.EditorComponent.CaretX<>NewX) - or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then - SourceEditorManager.AddJumpPointClicked(Self); - end; - - if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source) - then begin - // jump to other file -> open it - ActiveUnitInfo := Project1.UnitInfoWithFilename(NewSource.Filename); - AnEditorInfo := nil; - if ActiveUnitInfo <> nil then - AnEditorInfo := GetAvailableUnitEditorInfo(ActiveUnitInfo, Point(NewX,NewY), NewTopLine); - if AnEditorInfo <> nil then begin - SourceEditorManager.ActiveEditor := TSourceEditor(AnEditorInfo.EditorComponent); - Result := mrOK; - end - else - Result:=DoOpenEditorFile(NewSource.Filename,-1,-1, - [ofOnlyIfExists,ofRegularFile,ofDoNotLoadResource]); - if Result<>mrOk then begin - UpdateSourceNames; - exit; - end; - NewSrcEdit := SourceEditorManager.ActiveEditor; - end - else begin - AnEditorInfo := GetAvailableUnitEditorInfo(ActiveUnitInfo, Point(NewX,NewY), NewTopLine); - if AnEditorInfo <> nil then begin - NewSrcEdit := TSourceEditor(AnEditorInfo.EditorComponent); - SourceEditorManager.ActiveEditor := NewSrcEdit; - end - else - NewSrcEdit:=ActiveSrcEdit; - end; - if NewX<1 then NewX:=1; - if NewY<1 then NewY:=1; - //debugln(['[TMainIDE.DoJumpToCodePos] ',NewX,',',NewY,',',NewTopLine]); + SourceEditorManager.BeginAutoFocusLock; try - NewSrcEdit.BeginUpdate; - NewSrcEdit.EditorComponent.MoveLogicalCaretIgnoreEOL(Point(NewX,NewY)); - if not NewSrcEdit.IsLocked then begin - if NewTopLine < 1 then - NewSrcEdit.CenterCursor(True) - else - NewSrcEdit.TopLine:=NewTopLine; - end; - //DebugLn('TMainIDE.DoJumpToCodePos NewY=',dbgs(NewY),' ',dbgs(TopLine),' ',dbgs(NewTopLine)); - with NewSrcEdit.EditorComponent do - LeftChar:=Max(NewX - (CharsInWindow * 4 div 5), 1); - finally - NewSrcEdit.EndUpdate; - end; - if MarkLine then - NewSrcEdit.ErrorLine := NewY; + if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then + GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo); - if FocusEditor then - SourceEditorManager.ShowActiveWindowOnTop(True); - UpdateSourceNames; - Result:=mrOk; + if AddJumpPoint and (ActiveUnitInfo <> nil) and (ActiveSrcEdit <> nil) + then begin + if (NewSource<>ActiveUnitInfo.Source) + or (ActiveSrcEdit.EditorComponent.CaretX<>NewX) + or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then + SourceEditorManager.AddJumpPointClicked(Self); + end; + + if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source) + then begin + // jump to other file -> open it + ActiveUnitInfo := Project1.UnitInfoWithFilename(NewSource.Filename); + AnEditorInfo := nil; + if ActiveUnitInfo <> nil then + AnEditorInfo := GetAvailableUnitEditorInfo(ActiveUnitInfo, Point(NewX,NewY), NewTopLine); + if AnEditorInfo <> nil then begin + SourceEditorManager.ActiveEditor := TSourceEditor(AnEditorInfo.EditorComponent); + Result := mrOK; + end + else + Result:=DoOpenEditorFile(NewSource.Filename,-1,-1, + [ofOnlyIfExists,ofRegularFile,ofDoNotLoadResource]); + if Result<>mrOk then begin + UpdateSourceNames; + exit; + end; + NewSrcEdit := SourceEditorManager.ActiveEditor; + end + else begin + AnEditorInfo := GetAvailableUnitEditorInfo(ActiveUnitInfo, Point(NewX,NewY), NewTopLine); + if AnEditorInfo <> nil then begin + NewSrcEdit := TSourceEditor(AnEditorInfo.EditorComponent); + SourceEditorManager.ActiveEditor := NewSrcEdit; + end + else + NewSrcEdit:=ActiveSrcEdit; + end; + if NewX<1 then NewX:=1; + if NewY<1 then NewY:=1; + //debugln(['[TMainIDE.DoJumpToCodePos] ',NewX,',',NewY,',',NewTopLine]); + try + NewSrcEdit.BeginUpdate; + NewSrcEdit.EditorComponent.MoveLogicalCaretIgnoreEOL(Point(NewX,NewY)); + if not NewSrcEdit.IsLocked then begin + if NewTopLine < 1 then + NewSrcEdit.CenterCursor(True) + else + NewSrcEdit.TopLine:=NewTopLine; + end; + //DebugLn('TMainIDE.DoJumpToCodePos NewY=',dbgs(NewY),' ',dbgs(TopLine),' ',dbgs(NewTopLine)); + with NewSrcEdit.EditorComponent do + LeftChar:=Max(NewX - (CharsInWindow * 4 div 5), 1); + finally + NewSrcEdit.EndUpdate; + end; + if MarkLine then + NewSrcEdit.ErrorLine := NewY; + + if FocusEditor then + SourceEditorManager.ShowActiveWindowOnTop(True); + UpdateSourceNames; + Result:=mrOk; + finally + SourceEditorManager.EndAutoFocusLock; + end; end; {------------------------------------------------------------------------------- diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index c20512d9b5..f238cab45d 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -822,6 +822,7 @@ type FSourceWindowByFocusList: TFPList; FUpdateLock: Integer; FActiveEditorLock: Integer; + FAutoFocusLock: Integer; FUpdateFlags: set of (ufMgrActiveEditorChanged, ufShowWindowOnTop, ufShowWindowOnTopFocus); procedure FreeSourceWindows; function GetActiveSourceWindowIndex: integer; @@ -843,6 +844,9 @@ type function GetUniqueSourceEditors(Index: integer): TSourceEditorInterface; override; function GetMarklingProducers(Index: integer): TSourceMarklingProducer; override; public + procedure BeginAutoFocusLock; + procedure EndAutoFocusLock; + function HasAutoFocusLock: Boolean; // Windows function SourceWindowWithEditor(const AEditor: TSourceEditorInterface): TSourceEditorWindowInterface; override; @@ -6965,7 +6969,9 @@ Begin TempEditor.EditorComponent.CaretXY := CaretXY; TempEditor.EditorComponent.TopLine := TopLine; end; - if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) then + if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) and + not(Manager.HasAutoFocusLock) + then begin {$IFDEF VerboseFocus} debugln('TSourceNotebook.NotebookPageChanged BEFORE SetFocus ', @@ -7826,6 +7832,21 @@ begin Result:=TSourceMarklingProducer(fProducers[Index]); end; +procedure TSourceEditorManagerBase.BeginAutoFocusLock; +begin + inc(FAutoFocusLock); +end; + +procedure TSourceEditorManagerBase.EndAutoFocusLock; +begin + dec(FAutoFocusLock); +end; + +function TSourceEditorManagerBase.HasAutoFocusLock: Boolean; +begin + Result := FAutoFocusLock > 0; +end; + function TSourceEditorManagerBase.GetActiveCompletionPlugin: TSourceEditorCompletionPlugin; begin Result := FActiveCompletionPlugin; @@ -7955,6 +7976,7 @@ var h: TSrcEditMangerHandlerType; begin FUpdateFlags := []; + FAutoFocusLock := 0; for i := low(TsemChangeReason) to high(TsemChangeReason) do FChangeNotifyLists[i] := TMethodList.Create; for h:=low(FHandlers) to high(FHandlers) do