User Tools
A user tool is a command in the menu that launches an external program and capture the result. A typical usage is to launch an external compiler or interperter. It is possible to pass special values to the command line such as the filename of the current file or the current line line number.
1. Syntax
Attributes:
Name | Format | Description |
---|---|---|
caption | string | This text will be displayed in the Tools menu and in the title of the output window. |
command | string | The full name of the command to execute. Blanks are accepted, no need to use quotes. |
arguments | string | The arguments to pass to the command. This attribute accepts special variables that will be substituted when launching the command. The syntax is $(variablename) where 'variablename' is described below. |
directory | string | The directory where you want the command to execute. This attribute accepts the same variables as the arguments attribute. |
save-all | true false | If true, all files are saved before launching the command. The command will not be launched if at least one save fails. |
save-current | true false | If true, the current file is saved before launching the command. The command will not be launched if the save fails. |
show-window | true false | Set this attribute to true for graphical tools, set it to false to the other to prevent the opening of a console. This attribute is unused on Unix platform. |
language | string | If this value is set, the tool is available only with files of this language. |
hot-key | keycode | An optional key to launch quickly the tool. The syntax is:
[CTRL+][ALT+][SHIFT+] keyname |
auto-close | true false | If true, the output window will be closed if the tool terminates without error (i.e. exit code = 0) and does not report any link. |
edit-arguments | true false | If true, the you will be prompted for arguments. |
error-pattern-n | regex | A special regular expression to define a custom error pattern: if a line
from the output matches the pattern, it will be recognized as
an error message, the output line will be converted into a link
and the target line will be marked as an error.
The pattern is a regex with the following rules:
Example: an errors such as c:\myproj\src\main.c(15): Error: 'myvar' undefined will be recognized with the pattern \F\(\L\): .* |
Variables in Arguments:
Name | Description |
---|---|
WorkDir | The directory of the current project. |
FilePath | The full name of the current file |
FileDir | The directory of the current file |
FileName | The filename without directory and without extension |
FileNameExt | The filename with extension but without directory |
CurText | The current selection or the word under the caret. This value will be empty if the selection contains new lines. |
CurLine | The current line of the caret. This value is an absolute line number i.e. starting from the beginning of the file, not the section. |
CurCol | The current column of the caret. This value is an offset, tab characters are not expanded. |
2. Handling Output
When a tool is run, its output is parsed. If a line is recognized as an error or warning message, it will appear in the output window as a link. By default, the editor recognizes two patterns:
filename:line:message filename(line):message
but it can be customized with the error-pattern properties.
If the file is not an absolute path, the directory specified in tool is used. If there is no directory specified, the current working directory of the editor is used instead.
3. Examples
def tools def build-cb caption = Build Code Browser command = cmd.exe arguments = /c build.bat directory = c:\projects\code-browser save-all = true hot-key = F7 end def run-cb caption = Run Code Browser command = cb.exe directory = c:\projects\code-browser show-window = true hot-key = F5 end end