[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.1 General Information 5.2 Editing Sources 5.3 The File Selector 5.4 Menu Items 5.5 Using an External Editor 5.6 Using the Clipboard 5.7 Saving Files 5.8 Remote Files
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Source editing is one of the central parts of GPS, giving in turn access to many other functionalities, including extended source navigation and source analyzing tools.
The integrated source editor provides all the usual capabilities found in integrated environments, including:
The second box shows the writable state of the file. You can change this state by clicking on the label directly: this will switch between writable and read-only. Note that this will not change the permissions of the file on disk, it will only change the writable state of the source editor within GPS.
When trying to save a file which is read only on the disk, GPS will ask for confirmation, and if possible, will force saving of the file, keeping its read only state.
The third box shows whether the file has been modified since the last save. The three possible states are:
The fourth box displays the position of the cursor in the file by a line and a column number.
If a set of lines is selected when you press the indentation key, this whole set of lines will be indented.
The type of information displayed depends on the current state of GPS.
In normal mode, the entity kind and the location of declaration is displayed when this information is available. That is, when the cross-reference information about the current file has been generated. If there is no relevant information, no tooltip is displayed. See 6.1 Support for Cross-References for more information.
In debugging mode, the value of the variable under the mouse is displayed in the pop up window if the variable is known to the debugger. Otherwise, the normal mode information is displayed.
You can disable the automatic pop up of tool tips in the Editor section of the preferences dialog. See section 15.1 The Preferences Dialog.
Completions are searched in the edited source file, by first looking at the closest words and then looking further in the source as needed.
You can also jump to a corresponding delimiter by using the Ctrl-' key, that can be configured in the preferences. Typing twice on this key will move the cursor back to its original position.
begin...end
block, or loop statement,
etc...
The block highlighting will also take into account the changes made in your source code, and will recompute automatically the current block when needed.
This capability is currently implemented for Ada, C and C++ languages.
-
icons on the left side,
corresponding to the beginning of subprograms. If you click on one of these
icons, all the lines corresponding to this subprogram are hidden, except
the first one. As for the block highlighting, these icons are recomputed
automatically when you modify your sources and are always kept up to date.
This capability is currently implemented for Ada, C and C++ languages.
GPS also integrates with existing third party editors such as
Emacs
or vi
. See section 5.5 Using an External Editor.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The key bindings are listed below in two sections: the common key bindings, always available; the Emacs key bindings, available as an option.
In addition, there are several ways to define new key bindings, see 15.5 Defining Text Aliases and Defining new key bindings.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file selector is a dialog used to select a file. Under Windows, the default is to use the standard file selection widget. Under other platforms, the file selector is a built-in dialog:
This dialog provides the following areas and capabilities:
/
if
not defined)
+
and -
icons on the left of the directories, or
navigate using the keyboard keys: up and down to select the
previous or the next directory, + and - to expand and collapse
the current directory, and backspace to select the parent directory.
OK
and Cancel
buttons.
When you have selected the right file, clock on OK
to confirm, or
click on Cancel
at any time to cancel and close the file selection.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The main menus that give access to extended functionalities related to source editing are described in this section.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When you save a new file for the first time, GPS will ask you to enter the name of the file. In case you have started typing Ada code, GPS will try to guess based on the first main entity in the editor and on the current naming scheme, what should be the default name of this new file.
A new view can also be created by keeping the shift key pressed while drag-and-dropping the editor (see 4.7 Moving Windows). This second method is preferred, since you can then specify directly where you want to put the new view. The default when using the menu is that the new view is put on top of the editor itself.
The first text area allows you to type a file name. You can start the beginning of a file name, and use the Tab key to complete the file name. If there are several possible completions, the common prefix will be displayed, and a list of all possible completions will be displayed in the second text area.
You can then either complete the name by typing it, or continue hitting the Tab key to cycle through the possible completions, or click on one of the completions in the list displayed.
If you press the down arrow key, the focus will move to the list of completions, so that you can select a file from this list without using the mouse.
Once you have made your choice, click on the OK
button to validate.
Clicking on Cancel
or hitting the Esc key will cancel the
operation and close the dialog.
This dialog will only show each file once. If you have extended
projects in your hierarchy, some files may be redefined in some
extending project. In this case, only the files from the extending
project are shown, and you cannot have access through this dialog to
the overridden files of the extended project. Of course, you can still
use the project explorer or the standard File->Open
menu to
open these files.
On Windows, if no command is specified in the preferences the standard Windows print dialog box is displayed. This dialog box allows the user to specify the target printer, the properties of the printer, which pages to print (all, or a specific range of pages), the number of copies to print, and, when more than one copy is specified, whether the pages should be collated. Pressing the Cancel button on the dialog box returns to GPS without printing the window contents; otherwise the specified pages and copies are printed on the selected printer. Each page is printed with a header containing the name of the file (if the window has ever been saved). The page number is printed on the bottom of each page. See Print Command.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
gnatstub
.
gnatpp
. It is possible to specify gnatpp
switches in the
switch editor. See section 7.8 The Switches Editor.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GPS is fully integrated with a number of external editors, in
particular Emacs
and vi
. The choice of the default
external editor is done in the preferences. See section 15.1 The Preferences Dialog.
The following values are recognized:
gnuclient
By default, gnuclient will open a new Emacs frame for every file that is opened. You might want to add the following code to your `.emacs' file (create one if needed) so that the same Emacs frame is reused every time:
(setq gnuserv-frame (car (frame-list))) |
See http://www.hpl.hp.co.uk/people/ange/gnuserv/ for more information.
emacsclient
emacs
emacsclient
instead, since it is much
faster, and makes it easier to copy and paste between multiple
files. Basically, the only reason to use this external editor is if
your system doesn't support emacsclient
.
vim
Vim
is a vi-like editor that provides a number of enhancements,
for instance syntax highlighting for all the languages supported by
GPS. Selecting this external editor will start an xterm (or command
window, depending on your system) with a running vim
process editing
the file.
Note that one limitation of this editor is that if GPS needs to open the same file a second time, it will open a new editor, instead of reusing the existing one.
To enable this capability, the xterm executable must be found in the PATH,
and thus is not supported on Windows systems. Under Windows systems,
you can use the custom
editor instead.
vi
vi
command instead of vim
.
custom
none
In the cases that require an Emacs server, GPS will try several solutions if no already running server was found. It will first try to spawn the glide environment distributed with GNAT. If not found in the PATH, it will then start a standard Emacs. The project file currently used in GPS will be set appropriately the first time Emacs is spawned. This means that if you load a new project in GPS, or modify the paths of the current project, you should kill any running Emacs, so that a new one is spawned by GPS with the appropriate project.
Alternatively, you can reload explicitly the project from
Emacs itself by using the menu Project->Load
In the preferences, there are three settings that allow you to select the external editor (if left to an empty string, GPS will automatically select the first editor available on your system), to specify the custom editor command, in case you've selector this item, and whether this editor should always be used every time you double-click on a file, or whether you need to explicitly select the contextual menu to open the external editor.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section concerns X-Window users who are used to cutting and pasting with the middle mouse button. In the GPS text editor, as in many recent X applications, the GPS clipboard is set by explicit cut/copy/paste actions, either through menu items or keyboard shortcuts, and the primary clipboard (i.e. the "middle button" clipboard) is set by the current selection.
Therefore, copy/paste between GPS and other X applications using the primary clipboard will still work, provided that there is some text currently selected. The GPS clipboard, when set, will override the primary clipboard.
See http://www.freedesktop.org/standards/clipboards.txt for more information.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
After you have finished modifying your files, you need to save them. The basic
method to do that is to select the menu File->Save
, which saves the
currently selected file.
You can also use the menu File->Save As...
if you want to save the
file with another name, or in another directory.
If you have multiple files to save, another possibility is to use the menu
File->Save More->All
. This will open a dialog listing all the currently
modified editors that need saving. You can then select individually which
one should be saved, and click on Save
to do the actual saving.
When calling external commands, such as compiling a file, if the
Auto save
preference is disabled, this same dialog is also used,
to make sure that e.g. the compiler will take into account your local changes.
If the preference is enabled, the saving is performed automatically.
You can conveniently select or unselect all the files at once by clicking on the title of the first column (labelled Select). This will toggle the selection status of the first line, and have the same status for all other editors.
If you press Cancel
instead of Save
, no saving will take place,
and the action that displayed this dialog is also cancelled. Such actions can
be for instance starting a compilation command, a VCS operation, or quitting
GPS with unsaved files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GPS has a basic support for working with files on remote hosts. This includes a number of protocols, described below, which allow you to read a file from a remote host, edit it locally, and then save it transparently to the remote machine.
For now, the support for remote files is only available through the GPS shell window. You start editing a remote file by typing a line similar to
edit protocol://user@machine/full/path |
where "protocol" should be replaced by the name of the protocol you want to use, "user" is the login name you wish to use on the remote "machine", and "/full/path" is the full path on the remote machine to access the file.
The user name is optional. If it is the same as on the local machine, you can omit the user name as well as the "@" sign.
Likewise, the machine name is optional, if you want to get a file from the local host. This can be used to access files belonging to another user. In this case, you need to specify the "@" sign, but do not insert a machine name right after it.
Remote files can also be used if you want to work with GPS, but the machine on which the files are found isn't supported by GPS.
The following protocols are supported:
Although ssh can be setup not to require a password, GPS will automatically detect if a password is asked and open a dialog to query it.
The remote system must be a Unix-like system with support for standard Unix
commands like test
, echo
, rm
and ls
.
In the sample shell command above, you would replace the word "protocol" with "ssh" to use this protocol.
It has the same requirements that the ssh protocol. To use it, substitute the word "rsh" to "protocol" in the example above.
To use it, substitute the word "telnet" to "protocol" in the example above.
It basically has the same behavior as the ssh protocol, although it might be slightly slower since a new connection has to be established every time a file is fetched from, or written to the remote host. However, it might work better than ssh if the file contains 8 bit characters.
To use it, substitute the word "scp" to "protocol" in the example above.
Rsync is specially optimized to transfer only the parts of a file that are different from the one already on the remote host. Therefore, it will generally provide the best performance when writing the file back to the remote host.
If you set up the environment variable RSYNC_RSH to ssh before starting gps, the connection will then be encrypted when transfering the files.
To use this protocol, substitute the word "rsync" to "protocol" in the example above.
To use this protocol, substitute the word "ftp" to "protocol" in the example above.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |