diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index 69459ac2bd..58905b1b01 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -190,6 +190,11 @@ type function FindDeclaration(Code: TCodeBuffer; X,Y: integer; var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer): boolean; + + // find include directive + function FindEnclosingIncludeDirective(Code: TCodeBuffer; X,Y: integer; + var NewCode: TCodeBuffer; + var NewX, NewY, NewTopLine: integer): boolean; // functions for events in the object inspector function GetCompatiblePublishedMethods(Code: TCodeBuffer; @@ -647,6 +652,34 @@ writeln('TCodeToolManager.FindDeclaration END '); {$ENDIF} end; +function TCodeToolManager.FindEnclosingIncludeDirective(Code: TCodeBuffer; X, + Y: integer; var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer + ): boolean; +var + CursorPos: TCodeXYPosition; + NewPos: TCodeXYPosition; +begin + Result:=false; +{$IFDEF CTDEBUG} +writeln('TCodeToolManager.FindEnclosingIncludeDirective A ',Code.Filename,' x=',x,' y=',y); +{$ENDIF} + if not InitCurCodeTool(Code) then exit; + CursorPos.X:=X; + CursorPos.Y:=Y; + CursorPos.Code:=Code; + try + Result:=FCurCodeTool.FindEnclosingIncludeDirective(CursorPos, + NewPos,NewTopLine); + if Result then begin + NewX:=NewPos.X; + NewY:=NewPos.Y; + NewCode:=NewPos.Code; + end; + except + on e: Exception do Result:=HandleException(e); + end; +end; + function TCodeToolManager.FindBlockCounterPart(Code: TCodeBuffer; X, Y: integer; var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer ): boolean; diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index 52aec60294..3b4c121d30 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -199,6 +199,9 @@ type function LinkCount: integer; function LinkIndexAtCleanPos(ACleanPos: integer): integer; function LinkSize(Index: integer): integer; + function FindFirstSiblingLink(LinkIndex: integer): integer; + function FindParentLink(LinkIndex: integer): integer; + function CleanedSrc: string; function CursorToCleanPos(ACursorPos: integer; ACode: pointer; var ACleanPos: integer): integer; // 0=valid CleanPos @@ -206,10 +209,12 @@ type // 1=CursorPos beyond scanned code function CleanedPosToCursor(ACleanedPos: integer; var ACursorPos: integer; var ACode: Pointer): boolean; + function WholeRangeIsWritable(CleanStartPos, CleanEndPos: integer): boolean; procedure FindCodeInRange(CleanStartPos, CleanEndPos: integer; UniqueSortedCodeList: TList); procedure DeleteRange(CleanStartPos,CleanEndPos: integer); + property OnGetSource: TOnGetSource read FOnGetSource write FOnGetSource; property OnLoadSource: TOnLoadSource read FOnLoadSource write FOnLoadSource; property OnDeleteSource: TOnDeleteSource @@ -469,6 +474,47 @@ begin Result:=CleanedLen-Links[Index].CleanedPos; end; +function TLinkScanner.FindFirstSiblingLink(LinkIndex: integer): integer; +{ find link of the start of the code + e.g. The resulting link SrcPos is always 1 + if LinkIndex is in the main code, the result will be 0 + if LinkIndex is in an include file, the result will be the first link of + the include file. If the include file is included multiple times, it is + treated as if they are different files. + + ToDo: if include file include itself, directly or indirectly +} +var + LastIndex: integer; +begin + Result:=LinkIndex; + if LinkIndex>=0 then begin + LastIndex:=LinkIndex; + while (Result>=0) do begin + if Links[Result].Code=Links[LinkIndex].Code then begin + if Links[Result].SrcPos>Links[LastIndex].SrcPos then begin + // the include file was (in-)directly included by itself + // -> skip + Result:=FindParentLink(Result); + end else if Links[Result].SrcPos=1 then begin + // start found + exit; + end; + LastIndex:=Result; + end else + dec(Result); + end; + end; +end; + +function TLinkScanner.FindParentLink(LinkIndex: integer): integer; +// a parent link is the link of the include directive +// or in other words: the link in front of the first sibling link +begin + Result:=FindFirstSiblingLink(LinkIndex); + if Result>=0 then dec(Result); +end; + function TLinkScanner.LinkIndexAtCleanPos(ACleanPos: integer): integer; var l,r,m: integer; begin diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index a74b7b015d..3e13f59cda 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -62,7 +62,7 @@ type function GetSourceName: string; function RenameSource(const NewName: string; SourceChangeCache: TSourceChangeCache): boolean; - + // uses sections function FindUnitInUsesSection(UsesNode: TCodeTreeNode; const UpperUnitName: string; @@ -128,6 +128,10 @@ type var NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; function GuessUnclosedBlock(CursorPos: TCodeXYPosition; var NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; + + // include directives + function FindEnclosingIncludeDirective(CursorPos: TCodeXYPosition; + var NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; end; @@ -1151,7 +1155,26 @@ writeln('TStandardCodeTool.GuessUnclosedBlock A CursorPos=',CursorPos.X,',',Curs BuildBlockKeyWordFuncList; if ReadTilGuessedUnclosedBlock(CleanCursorPos,false) then Result:=CleanPosToCaretAndTopLine(CurPos.StartPos,NewPos,NewTopLine); - WriteDebugTreeReport; + //WriteDebugTreeReport; +end; + +function TStandardCodeTool.FindEnclosingIncludeDirective( + CursorPos: TCodeXYPosition; var NewPos: TCodeXYPosition; + var NewTopLine: integer): boolean; +var + CleanCursorPos, LinkIndex, NewCleanPos: integer; +begin + Result:=false; + BuildTreeAndGetCleanPos(false,CursorPos,CleanCursorPos); + LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos); + LinkIndex:=Scanner.FindParentLink(LinkIndex); + if LinkIndex<0 then + // this is no include file + exit; + NewPos.Code:=TCodeBuffer(Scanner.Links[LinkIndex].Code); + // calculate the directive end bracket + NewCleanPos:=Scanner.Links[LinkIndex].CleanedPos+Scanner.LinkSize(LinkIndex)-1; + Result:=CleanPosToCaretAndTopLine(NewCleanPos,NewPos,NewTopLine); end; function TStandardCodeTool.ReadTilGuessedUnclosedBlock( diff --git a/ide/keymapping.pp b/ide/keymapping.pp index 0c6aae34c6..825275347c 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -34,104 +34,105 @@ const These values can change from version to version, so DO NOT save them to file! } - ecFind = ecUserFirst + 1; - ecFindAgain = ecUserFirst + 2; - ecFindNext = ecFindAgain; - ecReplace = ecUserFirst + 3; + ecFind = ecUserFirst + 1; + ecFindAgain = ecUserFirst + 2; + ecFindNext = ecFindAgain; + ecReplace = ecUserFirst + 3; ecFindProcedureDefinition = ecUserFirst + 4; - ecFindProcedureMethod = ecUserFirst + 5; - ecGotoLineNumber = ecUserFirst + 6; + ecFindProcedureMethod = ecUserFirst + 5; + ecGotoLineNumber = ecUserFirst + 6; - ecNextEditor = ecUserFirst + 7; - ecPrevEditor = ecUserFirst + 8; + ecNextEditor = ecUserFirst + 7; + ecPrevEditor = ecUserFirst + 8; - ecPeriod = ecUserFirst + 9; + ecPeriod = ecUserFirst + 9; - ecFindPrevious = ecUserFirst + 10; - ecFindInFiles = ecUserFirst + 11; - ecJumpBack = ecUserFirst + 12; - ecJumpForward = ecUserFirst + 13; - ecAddJumpPoint = ecUserFirst + 14; - ecViewJumpHistory = ecUserFirst + 15; + ecFindPrevious = ecUserFirst + 10; + ecFindInFiles = ecUserFirst + 11; + ecJumpBack = ecUserFirst + 12; + ecJumpForward = ecUserFirst + 13; + ecAddJumpPoint = ecUserFirst + 14; + ecViewJumpHistory = ecUserFirst + 15; - ecFindDeclaration = ecUserFirst + 20; - ecFindBlockOtherEnd = ecUserFirst + 21; - ecFindBlockStart = ecUserFirst + 22; - ecOpenFileAtCursor = ecUserFirst + 23; + ecFindDeclaration = ecUserFirst + 20; + ecFindBlockOtherEnd = ecUserFirst + 21; + ecFindBlockStart = ecUserFirst + 22; + ecOpenFileAtCursor = ecUserFirst + 23; + ecGotoIncludeDirective = ecUserFirst + 24; - ecWordCompletion = ecUserFirst + 100; - ecCompleteCode = ecUserFirst + 101; - ecIdentCompletion = ecUserFirst + 102; - ecSyntaxCheck = ecUserFirst + 103; - ecGuessUnclosedBlock = ecUserFirst + 104; + ecWordCompletion = ecUserFirst + 100; + ecCompleteCode = ecUserFirst + 101; + ecIdentCompletion = ecUserFirst + 102; + ecSyntaxCheck = ecUserFirst + 103; + ecGuessUnclosedBlock = ecUserFirst + 104; - ecNew = ecUserFirst + 201; - ecNewUnit = ecUserFirst + 202; - ecNewForm = ecUserFirst + 203; - ecOpen = ecUserFirst + 204; - ecSave = ecUserFirst + 205; - ecSaveAs = ecUserFirst + 206; - ecSaveAll = ecUserFirst + 207; - ecClose = ecUserFirst + 208; - ecCloseAll = ecUserFirst + 209; - ecQuit = ecUserFirst + 210; + ecNew = ecUserFirst + 201; + ecNewUnit = ecUserFirst + 202; + ecNewForm = ecUserFirst + 203; + ecOpen = ecUserFirst + 204; + ecSave = ecUserFirst + 205; + ecSaveAs = ecUserFirst + 206; + ecSaveAll = ecUserFirst + 207; + ecClose = ecUserFirst + 208; + ecCloseAll = ecUserFirst + 209; + ecQuit = ecUserFirst + 210; - ecJumpToEditor = ecUserFirst + 300; - ecToggleFormUnit = ecUserFirst + 301; - ecToggleObjectInsp = ecUserFirst + 302; - ecToggleProjectExpl = ecUserFirst + 303; - ecToggleCodeExpl = ecUserFirst + 304; - ecToggleMessages = ecUserFirst + 305; - ecToggleWatches = ecUserFirst + 306; - ecToggleBreakPoints = ecUserFirst + 307; - ecToggleDebuggerOut = ecUserFirst + 308; - ecViewUnits = ecUserFirst + 309; - ecViewForms = ecUserFirst + 310; - ecToggleLocals = ecUserFirst + 311; + ecJumpToEditor = ecUserFirst + 300; + ecToggleFormUnit = ecUserFirst + 301; + ecToggleObjectInsp = ecUserFirst + 302; + ecToggleProjectExpl = ecUserFirst + 303; + ecToggleCodeExpl = ecUserFirst + 304; + ecToggleMessages = ecUserFirst + 305; + ecToggleWatches = ecUserFirst + 306; + ecToggleBreakPoints = ecUserFirst + 307; + ecToggleDebuggerOut = ecUserFirst + 308; + ecViewUnits = ecUserFirst + 309; + ecViewForms = ecUserFirst + 310; + ecToggleLocals = ecUserFirst + 311; - ecBuild = ecUserFirst + 400; - ecRun = ecUserFirst + 401; - ecPause = ecUserFirst + 402; - ecStepInto = ecUserFirst + 403; - ecStepOver = ecUserFirst + 404; - ecRunToCursor = ecUserFirst + 405; - ecStopProgram = ecUserFirst + 406; - ecBuildAll = ecUserFirst + 407; - ecBuildLazarus = ecUserFirst + 408; + ecBuild = ecUserFirst + 400; + ecRun = ecUserFirst + 401; + ecPause = ecUserFirst + 402; + ecStepInto = ecUserFirst + 403; + ecStepOver = ecUserFirst + 404; + ecRunToCursor = ecUserFirst + 405; + ecStopProgram = ecUserFirst + 406; + ecBuildAll = ecUserFirst + 407; + ecBuildLazarus = ecUserFirst + 408; - ecExtToolFirst = ecUserFirst + 500; - ecExtToolLast = ecUserFirst + 599; + ecExtToolFirst = ecUserFirst + 500; + ecExtToolLast = ecUserFirst + 599; - ecNewProject = ecUserFirst + 700; - ecOpenProject = ecUserFirst + 701; - ecSaveProject = ecUserFirst + 702; - ecSaveProjectAs = ecUserFirst + 703; - ecAddCurUnitToProj = ecUserFirst + 704; - ecRemoveFromProj = ecUserFirst + 705; - ecViewProjectSource = ecUserFirst + 706; - ecProjectOptions = ecUserFirst + 707; + ecNewProject = ecUserFirst + 700; + ecOpenProject = ecUserFirst + 701; + ecSaveProject = ecUserFirst + 702; + ecSaveProjectAs = ecUserFirst + 703; + ecAddCurUnitToProj = ecUserFirst + 704; + ecRemoveFromProj = ecUserFirst + 705; + ecViewProjectSource = ecUserFirst + 706; + ecProjectOptions = ecUserFirst + 707; - ecRunParameters = ecUserFirst + 800; - ecCompilerOptions = ecUserFirst + 801; - ecExtToolSettings = ecUserFirst + 802; - ecConfigBuildLazarus = ecUserFirst + 803; - ecEnvironmentOptions = ecUserFirst + 804; - ecEditorOptions = ecUserFirst + 805; - ecCodeToolsOptions = ecUserFirst + 806; - ecCodeToolsDefinesEd = ecUserFirst + 807; + ecRunParameters = ecUserFirst + 800; + ecCompilerOptions = ecUserFirst + 801; + ecExtToolSettings = ecUserFirst + 802; + ecConfigBuildLazarus = ecUserFirst + 803; + ecEnvironmentOptions = ecUserFirst + 804; + ecEditorOptions = ecUserFirst + 805; + ecCodeToolsOptions = ecUserFirst + 806; + ecCodeToolsDefinesEd = ecUserFirst + 807; - ecAboutLazarus = ecUserFirst + 900; + ecAboutLazarus = ecUserFirst + 900; - ecGotoEditor1 = ecUserFirst + 2000; - ecGotoEditor2 = ecGotoEditor1 + 1; - ecGotoEditor3 = ecGotoEditor2 + 1; - ecGotoEditor4 = ecGotoEditor3 + 1; - ecGotoEditor5 = ecGotoEditor4 + 1; - ecGotoEditor6 = ecGotoEditor5 + 1; - ecGotoEditor7 = ecGotoEditor6 + 1; - ecGotoEditor8 = ecGotoEditor7 + 1; - ecGotoEditor9 = ecGotoEditor8 + 1; - ecGotoEditor0 = ecGotoEditor9 + 1; + ecGotoEditor1 = ecUserFirst + 2000; + ecGotoEditor2 = ecGotoEditor1 + 1; + ecGotoEditor3 = ecGotoEditor2 + 1; + ecGotoEditor4 = ecGotoEditor3 + 1; + ecGotoEditor5 = ecGotoEditor4 + 1; + ecGotoEditor6 = ecGotoEditor5 + 1; + ecGotoEditor7 = ecGotoEditor6 + 1; + ecGotoEditor8 = ecGotoEditor7 + 1; + ecGotoEditor9 = ecGotoEditor8 + 1; + ecGotoEditor0 = ecGotoEditor9 + 1; type @@ -452,7 +453,8 @@ begin ecAddJumpPoint: Result:='add jump point'; ecViewJumpHistory: Result:='view jump history'; ecOpenFileAtCursor: Result:='open file at cursor'; - + ecGotoIncludeDirective: Result:='goto to include directive of current include file'; + // view menu ecToggleFormUnit: Result:= 'switch between form and source'; ecToggleObjectInsp: Result:= 'view object inspector'; @@ -1041,6 +1043,16 @@ begin // selection C:=Categories[AddCategory('CursorMoving','Cursor moving commands')]; + Add(C,'Move cursor word left',ecWordLeft, VK_LEFT, [ssCtrl],VK_UNKNOWN,[]); + Add(C,'Move cursor word right',ecWordRight, VK_RIGHT, [ssCtrl],VK_UNKNOWN,[]); + Add(C,'Move cursor to line start',ecLineStart, VK_HOME, [],VK_UNKNOWN,[]); + Add(C,'Move cursor to line end',ecLineEnd, VK_END, [],VK_UNKNOWN,[]); + Add(C,'Move cursor up one page',ecPageUp, VK_PRIOR, [],VK_UNKNOWN,[]); + Add(C,'Move cursor down one page',ecPageDown, VK_NEXT, [],VK_UNKNOWN,[]); + Add(C,'Move cursor left one page',ecPageLeft,VK_UNKNOWN,[],VK_UNKNOWN,[]); + Add(C,'Move cursor right one page',ecPageRight,VK_UNKNOWN,[],VK_UNKNOWN,[]); + Add(C,'Move cursor to top of page',ecPageTop, VK_PRIOR, [ssCtrl],VK_UNKNOWN,[]); + Add(C,'Move cursor to bottom of page',ecPageBottom, VK_NEXT, [ssCtrl],VK_UNKNOWN,[]); Add(C,'Move cursor to absolute beginning',ecEditorTop,VK_HOME,[ssCtrl],VK_UNKNOWN,[]); Add(C,'Move cursor to absolute end',ecEditorBottom,VK_END,[ssCtrl],VK_UNKNOWN,[]); @@ -1125,6 +1137,7 @@ begin Add(C,'Find declaration',ecFindDeclaration,VK_UNKNOWN,[],VK_UNKNOWN,[]); Add(C,'Find block other end',ecFindBlockOtherEnd,VK_UNKNOWN,[],VK_UNKNOWN,[]); Add(C,'Find block start',ecFindBlockStart,VK_UNKNOWN,[],VK_UNKNOWN,[]); + Add(C,'Goto include directive',ecGotoIncludeDirective,VK_UNKNOWN,[],VK_UNKNOWN,[]); // source notebook C:=Categories[AddCategory('SourceNotebook','Source Notebook commands')]; @@ -1175,8 +1188,8 @@ begin Add(C,'Open project',ecOpenProject,VK_F11,[ssCtrl],VK_UNKNOWN,[]); Add(C,'Save project',ecSaveProject,VK_UNKNOWN,[],VK_UNKNOWN,[]); Add(C,'Save project as',ecSaveProjectAs,VK_UNKNOWN,[],VK_UNKNOWN,[]); - Add(C,'add active unit to project',ecAddCurUnitToProj,VK_F11,[ssShift],VK_UNKNOWN,[]); - Add(C,'remove active unit from project',ecRemoveFromProj,VK_UNKNOWN,[],VK_UNKNOWN,[]); + Add(C,'Add active unit to project',ecAddCurUnitToProj,VK_F11,[ssShift],VK_UNKNOWN,[]); + Add(C,'Remove active unit from project',ecRemoveFromProj,VK_UNKNOWN,[],VK_UNKNOWN,[]); Add(C,'View project source',ecViewProjectSource,VK_UNKNOWN,[],VK_UNKNOWN,[]); Add(C,'View project options',ecProjectOptions,VK_F11,[ssShift,ssCtrl],VK_UNKNOWN,[]); diff --git a/ide/main.pp b/ide/main.pp index 632f9242f2..118ee25a38 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -61,7 +61,6 @@ type procedure mnuNewUnitClicked(Sender : TObject); procedure mnuNewFormClicked(Sender : TObject); procedure mnuOpenClicked(Sender : TObject); - procedure mnuOpenFileAtCursorClicked(Sender : TObject); procedure mnuSaveClicked(Sender : TObject); procedure mnuSaveAsClicked(Sender : TObject); procedure mnuSaveAllClicked(Sender : TObject); @@ -74,6 +73,9 @@ type procedure mnuSearchFindBlockStart(Sender: TObject); procedure mnuSearchFindDeclaration(Sender: TObject); procedure mnuSearchOpenFileAtCursor(Sender: TObject); + procedure mnuFindDeclarationClicked(Sender : TObject); + procedure mnuOpenFileAtCursorClicked(Sender : TObject); + procedure mnuGotoIncludeDirectiveClicked(Sender : TObject); // edit menu procedure mnuEditUndoClicked(Sender: TObject); @@ -134,8 +136,7 @@ type procedure OpenFileDownArrowClicked(Sender : TObject); procedure ControlClick(Sender : TObject); - procedure mnuFindDeclarationClicked(Sender : TObject); - + // SourceNotebook events Procedure OnSrcNoteBookActivated(Sender : TObject); Procedure OnSrcNoteBookAddJumpPoint(ACaretXY: TPoint; ATopLine: integer; @@ -268,7 +269,7 @@ type function DoOpenUnknownFile(const AFileName:string; Flags: TOpenFlags; var NewUnitInfo: TUnitInfo): TModalResult; procedure DoRestoreBookMarks(AnUnitInfo: TUnitInfo; ASrcEdit:TSourceEditor); - function DoOpenFileInSourceNoteBook(AnUnitInfo: TUnitInfo; + function DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult; function DoLoadLFM(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult; @@ -294,7 +295,7 @@ type SaveFirst: boolean):TModalResult; function DoOpenEditorFile(const AFileName:string; Flags: TOpenFlags): TModalResult; override; - function DoOpenFileAtCursor(Sender: TObject):TModalResult; + function DoOpenFileAtCursor(Sender: TObject): TModalResult; function DoSaveAll: TModalResult; function DoOpenMainUnit(ProjectLoading: boolean): TModalResult; function DoViewUnitsAndForms(OnlyForms: boolean): TModalResult; @@ -360,6 +361,7 @@ type procedure DoGoToPascalBlockOtherEnd; procedure DoGoToPascalBlockStart; procedure DoJumpToGuessedUnclosedBlock(FindNext: boolean); + procedure DoGotoIncludeDirective; procedure SaveIncludeLinks; // methods for debugging, compiling and external tools @@ -1320,6 +1322,12 @@ begin itmOpenFileAtCursor.Name:='itmOpenFileAtCursor'; itmOpenFileAtCursor.Caption := 'Open filename at cursor'; mnuSearch.add(itmOpenFileAtCursor); + + itmGotoIncludeDirective := TMenuItem.Create(nil); + itmGotoIncludeDirective.Name:='itmGotoIncludeDirective'; + itmGotoIncludeDirective.Caption := 'Goto include directive'; + itmGotoIncludeDirective.OnClick:=@mnuGotoIncludeDirectiveClicked; + mnuSearch.add(itmGotoIncludeDirective); end; procedure TMainIDE.SetupViewMenu; @@ -1714,6 +1722,11 @@ begin DoOpenFileAtCursor(Sender); end; +procedure TMainIDE.mnuGotoIncludeDirectiveClicked(Sender : TObject); +begin + DoGotoIncludeDirective; +end; + procedure TMainIDE.mnuSaveClicked(Sender : TObject); begin if SourceNoteBook.NoteBook=nil then exit; @@ -1728,8 +1741,7 @@ end; procedure TMainIDE.mnuSaveAllClicked(Sender : TObject); begin - if SourceNoteBook.NoteBook=nil then exit; - DoSaveAll; + DoSaveAll; end; procedure TMainIDE.mnuCloseClicked(Sender : TObject); @@ -1818,6 +1830,9 @@ begin ecFindBlockStart: DoGoToPascalBlockStart; + + ecGotoIncludeDirective: + DoGotoIncludeDirective; ecCompleteCode: DoCompleteCodeAtCursor; @@ -3188,7 +3203,7 @@ begin Project1.ProjectInfoFile); end; -function TMainIDE.DoOpenFileInSourceNoteBook(AnUnitInfo: TUnitInfo; +function TMainIDE.DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult; var NewSrcEdit: TSourceEditor; NewPageName, AFilename: string; @@ -5548,6 +5563,28 @@ writeln('[TMainIDE.DoGoToPascalBlockEnd] ************'); DoJumpToCodeToolBossError; end; +procedure TMainIDE.DoGotoIncludeDirective; +var ActiveSrcEdit: TSourceEditor; + ActiveUnitInfo: TUnitInfo; + NewSource: TCodeBuffer; + NewX, NewY, NewTopLine: integer; +begin + if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,false) then exit; +{ $IFDEF IDE_DEBUG} +writeln(''); +writeln('[TMainIDE.DoGotoIncludeDirective] ************'); +{ $ENDIF} + if CodeToolBoss.FindEnclosingIncludeDirective(ActiveUnitInfo.Source, + ActiveSrcEdit.EditorComponent.CaretX, + ActiveSrcEdit.EditorComponent.CaretY, + NewSource,NewX,NewY,NewTopLine) then + begin + DoJumpToCodePos(ActiveSrcEdit, ActiveUnitInfo, + NewSource, NewX, NewY, NewTopLine, false); + end else + DoJumpToCodeToolBossError; +end; + procedure TMainIDE.SaveIncludeLinks; var AFilename: string; begin @@ -6095,6 +6132,7 @@ begin itmFindBlockStart.ShortCut:=CommandToShortCut(ecFindBlockStart); itmFindDeclaration.ShortCut:=CommandToShortCut(ecFindDeclaration); itmOpenFileAtCursor.ShortCut:=CommandToShortCut(ecOpenFileAtCursor); + itmGotoIncludeDirective.ShortCut:=CommandToShortCut(ecGotoIncludeDirective); itmViewInspector.ShortCut:=CommandToShortCut(ecToggleObjectInsp); itmViewProject.ShortCut:=CommandToShortCut(ecToggleProjectExpl); @@ -6174,6 +6212,9 @@ end. { ============================================================================= $Log$ + Revision 1.263 2002/03/28 11:49:48 lazarus + MG: added search function: Goto Include Directive + Revision 1.262 2002/03/28 09:34:06 lazarus MG: show objectinspector only if needed diff --git a/ide/mainbar.pas b/ide/mainbar.pas index 08aa653a72..80c3bc2bc9 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -64,8 +64,9 @@ type TLoadBufferFlags = set of TLoadBufferFlag; TMainIDEBar = class(TForm) + + // the speedbuttons panel for frequently used IDE functions pnlSpeedButtons : TPanel; - ViewUnitsSpeedBtn : TSpeedButton; ViewFormsSpeedBtn : TSpeedButton; NewUnitSpeedBtn : TSpeedButton; @@ -80,8 +81,8 @@ type StepIntoSpeedButton : TSpeedButton; StepOverSpeedButton : TSpeedButton; OpenFilePopUpMenu : TPopupMenu; - GlobalMouseSpeedButton: TSpeedButton; + // MainMenu mnuMain: TMainMenu; mnuFile: TMenuItem; @@ -130,6 +131,7 @@ type itmFindBlockStart: TMenuItem; itmFindDeclaration: TMenuItem; itmOpenFileAtCursor: TMenuItem; + itmGotoIncludeDirective: TMenuItem; itmViewInspector: TMenuItem; itmViewProject: TMenuItem; @@ -177,8 +179,11 @@ type itmHelpAboutLazarus: TMenuItem; + // component palette ComponentNotebook : TNotebook; + GlobalMouseSpeedButton: TSpeedButton; + // hints. Note/ToDo: hints should be controlled by the lcl, this is a workaround HintTimer1 : TTimer; HintWindow1 : THintWindow; public