/usr/share/doc/gnat-gps/html/Defining-Actions.html is in gnat-gps-doc 5.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | <html lang="en">
<head>
<title>Defining Actions - Using the GNAT Programming Studio</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNAT Programming Studio">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" title="Customizing through XML and Python files">
<link rel="prev" href="Customization-files-and-plugins.html#Customization-files-and-plugins" title="Customization files and plugins">
<link rel="next" href="Macro-arguments.html#Macro-arguments" title="Macro arguments">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 2002-2010 AdaCore.
This document is free; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see `http://www.gnu.org/licenses/'.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
pre.smallexample {background-color:rgb(240,240,240);
font-family: courier new,courier,fixed;
font-size: 14px;
margin: 0px 40px 0px 40px;
border-width: 1px 2px 2px 1px;
border-top-style: dotted;
border-left-style: dotted;
border-right-style: solid;
border-bottom-style: solid;
border-color: black;}
code {color:black;
font-family: courier new,courier,fixed;
font-size: 14px;}
body {font-family: arial,helvetica,sans-serif;
font-size: 16px;
max-width: 800px;
text-align: justify}
samp {font-family: courier new,courier,fixed;
font-size: 14px}
--></style>
</head>
<body>
<div class="node">
<a name="Defining-Actions"></a>
<p>
Next: <a rel="next" accesskey="n" href="Macro-arguments.html#Macro-arguments">Macro arguments</a>,
Previous: <a rel="previous" accesskey="p" href="Customization-files-and-plugins.html#Customization-files-and-plugins">Customization files and plugins</a>,
Up: <a rel="up" accesskey="u" href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files">Customizing through XML and Python files</a>
<hr>
</div>
<h4 class="subsection">16.5.2 Defining Actions</h4>
<p><a name="index-action-782"></a><a name="index-g_t_003caction_003e-783"></a><a name="index-g_t_003cshell_003e-784"></a><a name="index-g_t_003cexternal_003e-785"></a><a name="index-g_t_003cfilter_003e-786"></a><!-- -->
<p class="noindent">This facility distinguishes the actions from their associated menus or
key bindings. Actions can take several forms: external commands,
shell commands and predefined commands, as will be explained in more details
below.
<p>The general form to define new actions is to use the <code><action></code> tag.
This tag accepts the following attributes:
<dl>
<dt><code>name (mandatory)</code><dd>This tag must be specified. It provides the name by which the action is
referenced in other parts of the customization files, for instance when it is
associated with a menu or a toolbar button. The name can contain any character,
although it is recommended to avoid XML special characters. It mustn't
start with a '/'.
<br><dt><code>output (optional)</code><dd>If specified, this attribute indicates where the output of the commands will
be sent by default. This can be overridden by each command, using the same
attribute for <code><shell></code> and <code><external></code> tags,
See <a href="Redirecting-the-command-output.html#Redirecting-the-command-output">Redirecting the command output</a>.
<br><dt><code>show-command (optional, default true)</code><dd>If specified, this attribute indicates whether the text of the command itself
should be displayed at the same location as its output. Neither will be
displayed if the output is hidden. The default is to show the command along
with its output.
This attribute can be overridden for each command.
<br><dt><code>show-task-manager (optional, default false)</code><dd>This attribute indicates whether an entry should be created in the task
manager to show this command. Associated with this entry is the progress
bar indicator, so if you hide the entry, no progress will be shown. On the
other hand, several progress bars might be displayed for your action if you
show the progress bar here, which might be an issue depending on the
context.
This attribute can be overriden for each external command.
<br><dt><code>category (optional, default "General")</code><dd>The category in the keybindings editor (menu <code>Edit/Key bindings</code>) in which
the action should be shown to the user. If you specify an empty string, the
action is considered as an implementation detail, and not displayed in the
editor. The user will thus not be able to assign it a keybinding through the
graphical user interface (although this is still doable through XML commands).
</dl>
<p>If you are defining the same action multiple times, the last definition will
be kept. However, existing menus, buttons, <small class="dots">...</small> that already reference that
action will keep their existing semantic. The new definition will only be
used for all new menus created from that point on.
<p>The <code><action></code> can have one or
several children, all of which define a particular command to execute. All
of these commands are executed one after the other, unless one of them
fails in which case the following commands are not executed.
<p>The following XML tags are valid children for <code><action></code>.
<a name="index-external-787"></a>
<dl><dt><code><external></code><dd>This defines a command to execute through the system (i.e. a standard Unix or
Windows command)
<p>Note for Windows users: like under UNIX, scripts can be called
from custom menu. In order to do that, you need to write your script in a
<samp><span class="file">.bat</span></samp> or <samp><span class="file">.cmd</span></samp> file, and call this file as usual.
The <code>external</code> tag would e.g. look like:
<pre class="smallexample"> <?xml version="1.0" ?>
<external_example>
<action name="my_command">
<external>c:\.gps\my_scripts\my_cmd.cmd</external>
</action>
</external_example>
</pre>
<p>This tag accepts the following attributes:
<dl>
<dt><code>server (optional)</code><dd> This attribute can be used to execute the external command on a remote
server. The accepted values are <code>"gps_server"</code> (default),
<code>"build_server"</code>, <code>"execution_server"</code>, <code>"debug_server"</code> and
<code>"tools_server"</code>.
See <a href="Remote-operations.html#Remote-operations">Remote operations</a>, for explanation of what these servers are.
<br><dt><code>check-password (optional)</code><dd> <a name="index-password-788"></a> This attribute can be used to tell GPS to check and handle password prompts
from the external command. The accepted values are <code>"false"</code> (default)
and <code>"true"</code>.
<br><dt><code>show-command (optional)</code><dd> This attribute can be used to override the homonym attribute specified for
the <code><action></code> tag.
<br><dt><code>output (optional)</code><dd> This attribute can be used to override the homonym attribute specified for
the <code><action></code> tag.
<br><dt><code>progress-regexp (optional)</code><dd> This attribute specifies a regular expression that the output of the
command will be checked against. Every time the regular expression matches,
it should provide two numeric values that are used to display the usual
progress indicators at the bottom-right corner of the GPS window, as
happens during regular compilations.
<p>The name of the action is printed in the progress bar while the action is
executing.
<pre class="smallexample"> <?xml version="1.0" ?>
<progress_action>
<action name="progress" >
<external
progress-regexp="(\d+) out of (\d+).*$"
progress-current="1"
progress-final="2"
progress-hide="true">gnatmake foo.adb
</external>
</action>
</progress_action>
</pre>
<br><dt><code>progress-current (optional, default is 1)</code><dd> This is the opening parenthesis count index in <code>progress-regexp</code>
that contains the current step.
<br><dt><code>progress-final (optional, default is 2)</code><dd> This is the opening parenthesis count index in <code>progress-regexp</code>
that contains the current last step. This last index can grow as
needed. For example, gnatmake will output the number of
the file it is currently examining, and the total number of files to be
examined. However, that last number may grow up, since parsing a new file
might generate a list of additional files to parse later on.
<br><dt><code>progress-hide (optional, default is true)</code><dd> If this attribute is set to the value "true", then all the lines that
match <code>progress-regexp</code> and are used to compute the progress will
not be displayed in the output console. For any other value of this
attribute, these lines are displayed along will the rest of the output.
<br><dt><code>show-task-manager (optional, default inherited from <action>)</code><dd> This attribute indicates whether an entry should be created in the task
manager to show this command. Associated with this entry is the progress
bar indicator, so if you hide the entry, no progress will be shown. On the
other hand, several progress bars might be displayed for your action if you
show the progress bar here, which might be an issue depending on the
context.
<p>If you have set a value for <code>progress-regexp</code>, this will automatically
be set to true by default so that the progress bar is indeed displayed in
the task manager. You can still override it explicitly for that
<code><external></code> element to force hiding the progress bar.
</dl>
<p><a name="index-on_002dfailure-789"></a><br><dt><code><on-failure></code><dd>
This tag specifies a group of command to be executed if the previous
external command fails. Typically, this is used to parse the output of the
command and fill the location window appropriately
(see <a href="Processing-the-tool-output.html#Processing-the-tool-output">Processing the tool output</a>).
<p>For instance, the following action spawn an external tool, and parses its
output to the location window and the automatic fixing tool if the external
tool happens to fail.
<p>In this group of commands the %... and $... macros can be used (see <a href="Macro-arguments.html#Macro-arguments">Macro arguments</a>).
<pre class="smallexample"> <?xml version="1.0" ?>
<action_launch_to_location>
<action name="launch tool to location" >
<external>tool-path</external>
<on-failure>
<shell>Locations.parse "%1" category<shell>
<external>echo the error message is "%2"</external>
</on-failure>
<external>echo the tool succeeded with message %1</external>
</action>
</action_launch_to_location>
</pre>
<p><a name="index-shell-790"></a><a name="index-shell-791"></a><a name="index-interactive-command-792"></a><br><dt><code><shell></code><dd>As well as external commands, you can use custom menu items to invoke GPS
commands using the <code>shell</code> tag. These are command written in one of the
shell scripts supported by GPS.
<p>This tag supports the same <code>show-command</code> and <code>output</code> attributes
as the <code><action></code> tag.
<p>The following example shows how to
create two actions to invoke the <code>help</code> interactive command and to open
the file <samp><span class="file">main.c</span></samp>.
<pre class="smallexample"> <?xml version="1.0" ?>
<help>
<action name="help">
<shell>help</shell>
</action>
<action name="edit">
<shell>edit main.c</shell>
</action>
</help>
</pre>
<p>By default, commands are expected to be written in the GPS shell language.
However, you can specify the language through the <code>lang</code> attribute. Its
default value is <code>"shell"</code>.
<p>The value of this attribute could also be "python".
<p>When programming with the GPS shell, you can execute multiple commands
by separating them with semicolons. Therefore, the following example
adds a menu which lists all the files used by the current file, in a
project browser.
<pre class="smallexample"> <?xml version="1.0" ?>
<current_file_uses>
<action name="current file uses">
<shell lang="shell">File %f</shell>
<shell lang="shell">File.uses %1</shell>
</action>
</current_file_uses>
</pre>
<br><dt><code><description></code><dd><a name="index-description-793"></a>This tag contains a description for the command, which is used in the
graphical editor for the key manager. See <a href="The-Key-Manager-Dialog.html#The-Key-Manager-Dialog">The Key Manager Dialog</a>.
<br><dt><code><filter>, <filter_and>, <filter_or></code><dd><a name="index-filter-794"></a>This is the context in which the action can be executed,
See <a href="Filtering-actions.html#Filtering-actions">Filtering actions</a>.
</dl>
<p>It is possible to mix both shell commands and external commands. For
instance, the following command opens an xterm (on Unix systems only)
in the current directory, which depends on the context.
<pre class="smallexample"> <?xml version="1.0" ?>
<xterm_directory>
<action "xterm in current directory">
<shell lang="shell">cd %d</shell>
<external>xterm</external>
</action>
</xterm_directory>
</pre>
<p>As seen in some of the examples above, some special strings are expanded by
GPS just prior to executing the command. These are the "%f", "%d",.. See below
for a full list.
<p>More information on chaining commands is provided in See <a href="Chaining-commands.html#Chaining-commands">Chaining commands</a>.
<p>Some actions are also predefined in GPS itself. This include for instance
aliases expansion, manipulating MDI windows, <small class="dots">...</small>;
All known actions (predefined
and the ones you have defined in your own customization files) can be
discovered by opening the key shortcut editor (<code>Edit->Key shortcuts</code> menu).
<!-- -->
</body></html>
|