Gem #67: Managing the GPS Workspace

Let's get started…

When you open GPS initially, it shows a number of views: the Messages window (which can never be closed), the Project View, showing the list of files in your project, the Outline View, which shows the list of subprograms in the current edit, the Scenario View listing the scenario variables in your project, and a Welcome window to help you get started.

When several windows share the same screen area (which is the case for the project view and the outline view in the default desktop), they are organized into notebooks, and it's possible to show any view by clicking on its associated tab. By default, GPS will now show the tabs if there is only one window in a given area, to save screen real estate. This behavior can be changed through the "Notebook Tabs Policy" preference. You can also change the location of the tabs (which by default appear below the window) through the "Notebook Tabs Position" preference. This latter preference configures the default location, though, and you can change it on a per-notebook basis by right-clicking in any of the tabs and changing the tabs position.

Windows can also be made to float. They are then put under the control of the operating system (or the window manager), and you can move them to another screen, another virtual desktop, iconify them, and so on. The window will have its own entry in your systems panel (the bar that is generally displayed at the bottom of the screen and shows all open windows). GPS has a mode where all windows it creates are made floating by default (this is the "All Floating" preference). When this mode is not activated, you can move a floating window back into GPS using one of two methods: the /Window/Floating menu, or by clicking on the [x] in the window's title bar when the "Destroy Floating" preference is unset; at that point, instead of closing the window, GPS will simply put it back in its own window. If you really want to close it, you have to click a second time on [x].

Only one of the views has the focus at any given time, and it receives all keyboard input. Its title bar is then highlighted in a different color (which you configure in the preferences). To save some space on the screen, you could choose to hide the title bars. Indeed, it is obvious most of the time what each window is after you have used them a few times. The only case where you might be missing info is for editors (since the title bar includes the full name of the file). However, this name also appears in GPS's own title bar. When the title bar is hidden, the notebook's tab will be color highlighted to show the currently active window.

When a window is not currently visible on the screen (most often this will be when the Messages window is below the Locations window for instance), its tab is highlighted in a special color to bring attention to it and encourage you to check what has changed in that window.

It is rather obvious (or so we hope) that the views can be resized as you see fit simply by dragging the separators between those windows (that is, click on the separator, hold the mouse button, and move the mouse up/down or left/right, depending on the orientation of the separator). The resizing can take one of two forms: either a simple line overlaid on top of the windows to show where the separator will end up when you release the mouse, or by redrawing the windows each time you move the mouse. This behavior can also be configured in the preferences.

However, did you know that you can actually create any number of new areas on the desktop (which we call the MDI, for Multiple Document Interface)? This can be done in a number of ways. The easiest to discover is to use the menu /Window/Split Side-by-Side or /Window/Split Up-Down. For instance, assuming you have the default desktop loaded in GPS, select the project view. Then select the menu /Window/Split Up-Down. This will put the outline view in its own area below the project view, allowing you to see both at the same time.

However, the most flexible way to reorganize windows is by using drag and drop. Start by clicking on the title bar or the tab of any window. Then, without releasing the mouse button, move your mouse to where you would like to put the window you clicked on. Note how a pop-up window appears on top of the GPS window to describe what will happen when you release the mouse. There are six places where you can drop a window: if you release the mouse in the middle of an existing window, the two windows will be stacked into a notebook; if you release on any of the sides of an existing window (there is a margin a few pixels wide on each side), the existing window will be split and the window you are moving will be displayed next to it; finally, you can also release the mouse outside of the GPS window altogether to make the window floating.

As an additional bonus, if you press the shift key when you are dropping an editor window, a new view will be created (showing the same contents) instead of moving the initial editor. This allows you to view several locations in a given file, which is often useful when you want to view data structures when writing code, or when comparing several sections of code.

My own preferred organization (on a wide screen) is as follows: I have two editors side by side (for instance spec and body). Then on the left side I display the Windows view (/Tools/Views/Windows menu), which provides a fast way to select and bring to the front any window no matter where it currently is on the screen. This is a also a convenient place from which to start the drag-and-drop operations (clicking on a file and dropping it where I want to put the editor). Below this Windows view I have the Bookmarks view, which allows me to save places within any of the editors (through the /Edit/Create Bookmark menu), and come back to them later. Below the two editors, I display the Messages window and the Locations window side by side, so that I can see compilation errors easily, while keeping an eye on whether GPS has reported an error in its messages window. Finally, on the right-hand side of the screen I display the Outline view, since this is such a great way to move fast within a file, and the Tasks view that shows what's being executed in the background (and provides a way to monitor the progress of compilations when using the -d switch to gnatmake). As you see, there are quite a number of views. To save space, I usually hide title bars (which as explained above are not necessary once you know what the windows are for), as well as the status bar at the bottom of the GPS window (since the task view displays the same information already).

Once you have found a layout that you like, however, you probably want to reuse it every time you open GPS. This is called saving the desktop. This process is very configurable, to adapt to the various needs that people might have:

- The default is for GPS to save the project-specific desktop. This means that the layout you have just created will be saved automatically on exit, and reapplied when loading the same project later on. If you load another project, the default layout will be used. One reason to do that is to save the currently opened files in the desktop (this is controlled by another preference, "Save Editor is Desktop", where you decide whether you want to save editors or not, and if you do, whether only project-specific editors will be saved or any file that happens to be opened at that time.

- If you want to reuse the same layout for all projects on which you work, you should make sure the preference "General/Save Project-Specific Desktop on Exit" is disabled. This means that a single version of the desktop will be saved, and will apply to all projects (in this case it might be a good idea to remove the file $HOME/desktop.xml prior to launching GPS the first time, so that any trace of project-specific desktop is wiped out). In such a case, one of the drawbacks is that you might not want to save the editors since they would not necessarily match the next project you load.

The method I have been using is the following: after removing the desktop.xml file as described above, I launch GPS and set up the various views as I like, but do not open any editor. I then save the current desktop as the default through the menu /File/Save Move/Default Desktop. I then ensure that the preference to save project-specific desktops is on, as well as the preference to save the editors in the desktop. This ensures that every time I open a project that I've never opened before, I get the default desktop (with no editor), but when I open a project that I have already opened before, then I get the same editors (and in the same location) as the last time I exited GPS.