/usr/share/doc/gnat-gps/html/Defining-Actions.html is in gnat-gps-doc 5.0-16.
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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 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 2 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/.
A copy of the license is included in the section entitled
"GNU General Public License". -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Using the GNAT Programming Studio: Defining Actions</title>
<meta name="description" content="Using the GNAT Programming Studio: Defining Actions">
<meta name="keywords" content="Using the GNAT Programming Studio: Defining Actions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index-table.html#Index-table" rel="index" title="Index table">
<link href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" rel="up" title="Customizing through XML and Python files">
<link href="Macro-arguments.html#Macro-arguments" rel="next" title="Macro arguments">
<link href="Customization-files-and-plugins.html#Customization-files-and-plugins" rel="previous" title="Customization files and plugins">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
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 lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Defining-Actions"></a>
<div class="header">
<p>
Next: <a href="Macro-arguments.html#Macro-arguments" accesskey="n" rel="next">Macro arguments</a>, Previous: <a href="Customization-files-and-plugins.html#Customization-files-and-plugins" accesskey="p" rel="previous">Customization files and plugins</a>, Up: <a href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" accesskey="u" rel="up">Customizing through XML and Python files</a> [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Defining-Actions-1"></a>
<h4 class="subsection">16.5.2 Defining Actions</h4>
<a name="index-action-1"></a>
<a name="index-_003caction_003e"></a>
<a name="index-_003cshell_003e"></a>
<a name="index-_003cexternal_003e"></a>
<a name="index-_003cfilter_003e"></a>
<p>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>
<p>The general form to define new actions is to use the <code><action></code> tag.
This tag accepts the following attributes:
</p>
<dl compact="compact">
<dt><code>name (mandatory)</code></dt>
<dd><p>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 ’/’.
</p>
</dd>
<dt><code>output (optional)</code></dt>
<dd><p>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>.
</p>
</dd>
<dt><code>show-command (optional, default true)</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>show-task-manager (optional, default false)</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>category (optional, default "General")</code></dt>
<dd><p>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).
</p></dd>
</dl>
<p>If you are defining the same action multiple times, the last definition will
be kept. However, existing menus, buttons, … 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>
<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>
<p>The following XML tags are valid children for <code><action></code>.
</p><dl compact="compact">
<dd>
<a name="index-external"></a>
</dd>
<dt><code><external></code></dt>
<dd><p>This defines a command to execute through the system (i.e. a standard Unix or
Windows command)
</p>
<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>.bat</samp> or <samp>.cmd</samp> file, and call this file as usual.
The <code>external</code> tag would e.g. look like:
</p>
<div class="smallexample">
<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></div>
<p>This tag accepts the following attributes:
</p>
<dl compact="compact">
<dt><code>server (optional)</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>check-password (optional)</code></dt>
<dd><a name="index-password-3"></a>
<p>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>.
</p>
</dd>
<dt><code>show-command (optional)</code></dt>
<dd><p>This attribute can be used to override the homonym attribute specified for
the <code><action></code> tag.
</p>
</dd>
<dt><code>output (optional)</code></dt>
<dd><p>This attribute can be used to override the homonym attribute specified for
the <code><action></code> tag.
</p>
</dd>
<dt><code>progress-regexp (optional)</code></dt>
<dd><p>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>
<p>The name of the action is printed in the progress bar while the action is
executing.
</p>
<div class="smallexample">
<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></div>
</dd>
<dt><code>progress-current (optional, default is 1)</code></dt>
<dd><p>This is the opening parenthesis count index in <code>progress-regexp</code>
that contains the current step.
</p>
</dd>
<dt><code>progress-final (optional, default is 2)</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>progress-hide (optional, default is true)</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>show-task-manager (optional, default inherited from <code><action></code>)</code></dt>
<dd><p>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>
<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.
</p>
</dd>
</dl>
<a name="index-on_002dfailure"></a>
</dd>
<dt><code><on-failure></code></dt>
<dd>
<p>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>
<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>
<p>In this group of commands the %... and $... macros can be used (see <a href="Macro-arguments.html#Macro-arguments">Macro arguments</a>).
</p>
<div class="smallexample">
<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></div>
<a name="index-shell-4"></a>
<a name="index-shell-5"></a>
<a name="index-interactive-command-1"></a>
</dd>
<dt><code><shell></code></dt>
<dd><p>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>
<p>This tag supports the same <code>show-command</code> and <code>output</code> attributes
as the <code><action></code> tag.
</p>
<p>The following example shows how to
create two actions to invoke the <code>help</code> interactive command and to open
the file <samp>main.c</samp>.
</p>
<div class="smallexample">
<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></div>
<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>
<p>The value of this attribute could also be "python".
</p>
<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.
</p>
<div class="smallexample">
<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></div>
</dd>
<dt><code><description></code></dt>
<dd><a name="index-description"></a>
<p>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>.
</p>
</dd>
<dt><code><filter>, <filter_and>, <filter_or></code></dt>
<dd><a name="index-filter"></a>
<p>This is the context in which the action can be executed,
See <a href="Filtering-actions.html#Filtering-actions">Filtering actions</a>.
</p>
</dd>
</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.
</p>
<div class="smallexample">
<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></div>
<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>
<p>More information on chaining commands is provided in See <a href="Chaining-commands.html#Chaining-commands">Chaining commands</a>.
</p>
<p>Some actions are also predefined in GPS itself. This include for instance
aliases expansion, manipulating MDI windows, …;
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).
</p>
<hr>
<div class="header">
<p>
Next: <a href="Macro-arguments.html#Macro-arguments" accesskey="n" rel="next">Macro arguments</a>, Previous: <a href="Customization-files-and-plugins.html#Customization-files-and-plugins" accesskey="p" rel="previous">Customization files and plugins</a>, Up: <a href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" accesskey="u" rel="up">Customizing through XML and Python files</a> [<a href="Index-table.html#Index-table" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|