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:

NameFormatDescription
captionstring This text will be displayed in the Tools menu and in the title of the output window.
commandstringThe full name of the command to execute. Blanks are accepted, no need to use quotes.
argumentsstringThe 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.
directorystringThe directory where you want the command to execute. This attribute accepts the same variables as the arguments attribute.
save-alltrue
false
If true, all files are saved before launching the command. The command will not be launched if at least one save fails.
save-currenttrue
false
If true, the current file is saved before launching the command. The command will not be launched if the save fails.
show-windowtrue
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.
languagestringIf this value is set, the tool is available only with files of this language.
hot-keykeycodeAn optional key to launch quickly the tool. The syntax is:

[CTRL+][ALT+][SHIFT+] keyname

auto-closetrue
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-argumentstrue
false
If true, the you will be prompted for arguments.
error-pattern-nregexA 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:

  • \F matches the filename. The filename can be relative to the initial directory (the directory property) or absolute.
  • \L matches the line number.
  • The regular expression must not include any group, remember that parenthesis must be escaped with backslashes: \( \).

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:

NameDescription
WorkDirThe directory of the current project.
FilePathThe full name of the current file
FileDirThe directory of the current file
FileNameThe filename without directory and without extension
FileNameExtThe filename with extension but without directory
CurTextThe current selection or the word under the caret. This value will be empty if the selection contains new lines.
CurLineThe current line of the caret. This value is an absolute line number i.e. starting from the beginning of the file, not the section.
CurColThe 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