diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index f940e601a7..a3e17b80cc 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -302,12 +302,16 @@ type var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer): boolean; + // get code context + //function FindCodeContext(Code: TCodeBuffer; X,Y: integer; + // out CodeContext: TCodeContext): boolean; + // gather identifiers (i.e. all visible) function GatherIdentifiers(Code: TCodeBuffer; X,Y: integer): boolean; function GetIdentifierAt(Code: TCodeBuffer; X,Y: integer; var Identifier: string): boolean; function IdentItemCheckHasChilds(IdentItem: TIdentifierListItem): boolean; - + // rename identifier function FindReferences(IdentifierCode: TCodeBuffer; X, Y: integer; TargetCode: TCodeBuffer; SkipComments: boolean; diff --git a/ide/main.pp b/ide/main.pp index b61768d89c..e7b4a1a22b 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -315,6 +315,8 @@ type procedure OnSrcNotebookFindDeclaration(Sender: TObject); procedure OnSrcNotebookInitIdentCompletion(Sender: TObject; JumpToError: boolean; out Handled, Abort: boolean); + procedure OnSrcNotebookShowCodeContext(JumpToError: boolean; + out Abort: boolean); procedure OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint; var NewTopLine, NewPageIndex: integer; JumpAction: TJumpHistoryAction); procedure OnSrcNotebookMovingPage(Sender: TObject; @@ -734,6 +736,7 @@ type procedure DoFindDeclarationAtCaret(const LogCaretXY: TPoint); function DoFindRenameIdentifier(Rename: boolean): TModalResult; function DoInitIdentCompletion(JumpToError: boolean): boolean; + function DoShowCodeContext(JumpToError: boolean): boolean; procedure DoCompleteCodeAtCursor; procedure DoExtractProcFromSelection; function DoCheckSyntax: TModalResult; @@ -1428,6 +1431,7 @@ begin SourceNotebook.OnEditorPropertiesClicked := @mnuEnvEditorOptionsClicked; SourceNotebook.OnFindDeclarationClicked := @OnSrcNotebookFindDeclaration; SourceNotebook.OnInitIdentCompletion :=@OnSrcNotebookInitIdentCompletion; + SourceNotebook.OnShowCodeContext :=@OnSrcNotebookShowCodeContext; SourceNotebook.OnJumpToHistoryPoint := @OnSrcNotebookJumpToHistoryPoint; SourceNotebook.OnMovingPage := @OnSrcNotebookMovingPage; SourceNotebook.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor; @@ -2161,6 +2165,12 @@ begin Abort:=not DoInitIdentCompletion(JumpToError); end; +procedure TMainIDE.OnSrcNotebookShowCodeContext( + JumpToError: boolean; out Abort: boolean); +begin + Abort:=not DoShowCodeContext(JumpToError); +end; + Procedure TMainIDE.OnSrcNotebookSaveAll(Sender: TObject); begin mnuSaveAllClicked(Sender); @@ -10377,6 +10387,26 @@ begin {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoInitIdentCompletion B');{$ENDIF} end; +function TMainIDE.DoShowCodeContext(JumpToError: boolean): boolean; +var + ActiveSrcEdit: TSourceEditor; + ActiveUnitInfo: TUnitInfo; +begin + if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit; + {$IFDEF IDE_DEBUG} + writeln(''); + writeln('[TMainIDE.DoShowCodeContext] ************'); + {$ENDIF} + {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoShowCodeContext A');{$ENDIF} + Result:=false; //ShowCodeContext(ActiveUnitInfo.Source,ActiveSrcEdit.EditorComponent); + if not Result then begin + if JumpToError then + DoJumpToCodeToolBossError; + exit; + end; + {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoShowCodeContext B');{$ENDIF} +end; + procedure TMainIDE.DoGoToPascalBlockOtherEnd; var ActiveSrcEdit: TSourceEditor; ActiveUnitInfo: TUnitInfo; diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index 71c2d0c991..6e1b2f6621 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -192,7 +192,6 @@ type procedure OnCodeBufferChanged(Sender: TSourceLog; SrcLogEntry: TSourceLogEntry); procedure StartIdentCompletion(JumpToError: boolean); - procedure StartShowCodeContext(JumpToError: boolean); procedure LinesInserted(sender: TObject; FirstLine,Count: Integer); procedure LinesDeleted(sender: TObject; FirstLine,Count: Integer); @@ -328,6 +327,8 @@ type out Handled, Abort: boolean) of object; TSrcEditPopupMenuEvent = procedure(AddMenuItemProc: TAddMenuItemProc ) of object; + TOnShowCodeContext = procedure(JumpToError: boolean; + out Abort: boolean) of object; TSourceNotebookState = (snIncrementalFind, snIncrementalSearching); TSourceNotebookStates = set of TSourceNotebookState; @@ -445,6 +446,7 @@ type FActiveEditKeyBGColor: TColor; FActiveEditSymbolFGColor: TColor; FActiveEditSymbolBGColor: TColor; + FOnShowCodeContext: TOnShowCodeContext; // PopupMenu procedure BuildPopupMenu; @@ -585,8 +587,10 @@ type function FIFCreateSearchForm(ADialog:TLazFindInFilesDialog): TSearchForm; procedure DoFindInFiles(ASearchForm: TSearchForm); + // goto line number procedure GotoLineClicked(Sender: TObject); + // history jumping procedure HistoryJump(Sender: TObject; CloseAction: TJumpHistoryAction); procedure JumpBackClicked(Sender: TObject); procedure JumpForwardClicked(Sender: TObject); @@ -594,8 +598,10 @@ type procedure DeleteLastJumpPointClicked(Sender: TObject); procedure ViewJumpHistoryClicked(Sender: TObject); + // hints procedure ActivateHint(const ScreenPos: TPoint; const TheHint: string); procedure HideHint; + procedure StartShowCodeContext(JumpToError: boolean); Procedure NewFile(const NewShortName: String; ASource: TCodeBuffer; FocusIt: boolean); @@ -644,6 +650,8 @@ type read FOnFindDeclarationClicked write FOnFindDeclarationClicked; property OnInitIdentCompletion: TOnInitIdentCompletion read FOnInitIdentCompletion write FOnInitIdentCompletion; + property OnShowCodeContext: TOnShowCodeContext + read FOnShowCodeContext write FOnShowCodeContext; property OnJumpToHistoryPoint: TOnJumpToHistoryPoint read FOnJumpToHistoryPoint write FOnJumpToHistoryPoint; property OnMovingPage: TOnMovingPage read FOnMovingPage write FOnMovingPage; @@ -1190,7 +1198,7 @@ Begin StartIdentCompletion(true); ecShowCodeContext : - StartShowCodeContext(true); + SourceNoteBook.StartShowCodeContext(true); ecWordCompletion : if not TCustomSynEdit(Sender).ReadOnly then begin @@ -1950,11 +1958,6 @@ begin aCompletion.Execute(TextS2,P.X,P.Y); end; -procedure TSourceEditor.StartShowCodeContext(JumpToError: boolean); -begin - -end; - procedure TSourceEditor.IncreaseIgnoreCodeBufferLock; begin inc(FIgnoreCodeBufferLock); @@ -4309,6 +4312,15 @@ begin FHintWindow.Visible:=false; end; +procedure TSourceNotebook.StartShowCodeContext(JumpToError: boolean); +var + Abort: boolean; +begin + if OnShowCodeContext<>nil then begin + OnShowCodeContext(JumpToError,Abort); + end; +end; + Procedure TSourceNotebook.BookMarkSetClicked(Sender: TObject); // popup menu: set bookmark clicked var @@ -5026,7 +5038,7 @@ Begin ecSetMarker0..ecSetMarker9: begin - BookMarkSet(Command - ecSetMarker0); + BookMarkSet(Command - ecSetMarker0); Key:=0; end;