Thursday, November 21, 2019

Exploring the Navigation Toolbar


There have been a few times when a major feature of the IDE has gone largely unnoticed, but they are rare. Nonetheless, it has happened again in a recent release of Delphi. Since the release of Delphi XE8, Delphi's IDE now sports some new informational and navigational features that are big, really big. And, so far, most Delphi developers that I've demonstrated these to have been surprised, and shocked, and have immediately changed the way they work with units while in Delphi's editor. This feature is call the Navigation toolbar, and it's easy to miss.

The Navigation toolbar appears just above the code editor when the Code tab is selected in the designer. The Navigation toolbar is shown in the following figure. There's not much to it, is there. This is why it's easy to miss.


The Navigation toolbar is used both for information, as well as navigation and searching. You can determine which unit is being displayed in the code editor by the text that appears on the currently selected tab, and that's been a feature of the IDE since Galileo was originally released with C++ Builder and Delphi 8 (and, the tabs are not part of the Navigation toolbar, The Navigation toolbar is only the thin slice beneath the tabs). When the insertion point (the current position of the cursor in the editor) is within a type declaration or a type implementation, the type appears in the Types combo box. This is shown in the following figure, where the insertion point is in the TUserData declaration of the Win.UserData unit of the UserData project.


If your insertion point is in the implementation of a method, the class or record appears in the Type combo box, and the method appears in the Methods combo box.



If your insertion point is inside the implementation of a pure function or procedure, the Type combo box will be empty, and the procedure or function name will appear in the Methods combo box, as shown in the following figure.



While serving to inform you where your insertion point is located, you can also use the Type and Method combo boxes to navigate your units, and this is where the real advantage of the Navigation toolbar begins to emerge.
Again, with the Win.UserData unit selected, I can easily move between the various types declared in this unit by dropping down the Type combo box, as shown in following figure.



If the selected type is a class or record, you can further navigate to a particular method of that type by dropping down the Method combo box.



While you can easily do this with your mouse, both the Type combo box and Method combo box dropdowns can also be accessed using key combinations. For the Type combo box, press Ctrl-Alt-N + Ctrl-Alt-T. That is, hold down the Ctrl and Alt keys while pressing N, and then release and then hold down the Ctrl and Alt keys while pressing T, and then release. Access the Method combo box dropdown by pressing Ctrl-Alt-N + Ctrl-Alt-P.

While I love the Type and Method combo boxes, my favorite feature of the Navigation toolbar is the File Sections combo box. This combo box permits you to instantly navigate to a specific section of the current unit, a feature that you will use over and over. This combo box, shown in the following figure, can also be accessed using the Ctrl-Alt-N + Ctrl-Alt-S key combination.



To the left of the File Sections combo box you will find the Used Units combo box. This combo box displays all of the units used by the current unit (both interface and implementation section uses clauses), and permits you to easily open and navigate to any of those units (assuming that the source code is available). The Used Units combo box, shown in the following figure, can also be displayed by pressing the Ctrl-Alt-N + Ctrl-Alt-U key combination.



There is one more feature available from the Navigation toolbar. To the right of the Methods combo box you will find the Project Symbol Search feature, which is represented by a magnifying glass icon.

Click on the magnifying glass icon, or press Ctrl-Alt-N + Ctrl-Alt-F, and the Navigation toolbar will display a search window and an associated Results list box. As you type characters, all symbols within the current project that include those consecutive characters that you've typed will appear in the Results list box (in the following figure I have typed btnc). If you then click on, or select and press the Enter key, any of the results, you instantly navigate to the selected unit and symbol declaration.



That's it for the Navigation toolbar. However, before we leave this section I want to point out the down arrow icon that appears at the upper-right corner of the preceding figure. You probably already know about this one, since it's been in the product a long time. But in case you do not, let me point out that this dropdown displays all open units, in alphabetical order. This can be very handy when you want to move to an open unit, but you have so many units opened that only a subset of the open units appear in the tabs above the editor pane. To use this feature, click on the down-arrow icon, and then select the unit to which you want to navigate from the displayed dropdown list.

Note: Notice that all of these key combinations used by the Navigation toolbar start with Ctrl-Alt-N (for navigation) while the second key press is almost predictable, as in Ctrl-Alt-T for type, Ctrl-Alt-S for section, Ctrl-Alt-U for Used Units. Only the Methods combo box dropdown key combination is awkward, using Ctrl-Alt-P, but in that case I must assume the P stands for procedure.


Copyright (c) 2017-2019 Cary Jensen. All Rights Reserved.

1 comment:

  1. I keep meaning to post this on QC. The Types and Methods drop downs stop working on old code bases that use the
    Write(F, Value:10); colon syntax. It only seems to affect larger units. Unfortunately the 20 odd year old code base I work one has a lot of both.

    ReplyDelete