Writing help

master
Yevgen Muntyan 2007-11-25 01:10:24 -06:00
parent 6df2f4d874
commit fe236f4b24
17 changed files with 726 additions and 108 deletions

View File

@ -1,11 +1,9 @@
docbook_files = \
medit.docbook \
license.docbook \
editor-editing.docbook \
editor-open-save.docbook \
editor-plugins.docbook \
editor-prefs.docbook \
editor-tools.docbook
prefs.docbook \
prefs-file.docbook \
user-tools.docbook
EXTRA_DIST = \
$(docbook_files) \
@ -38,6 +36,11 @@ manual.html: $(docbook_files) manual.xsl
$(MAKE) $(AM_MAKEFLAGS) LGPL.xml && \
xsltproc --xinclude --path "." --output manual.html $(srcdir)/manual.xsl $(srcdir)/medit.docbook
medit.lo: build-help
prefs.lo: build-help
prefs-file.lo: build-help
license.lo: build-help
#############################################################################
# Standard automake stuff
#

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="sect-editing-text">
<title>Editing text</title>
<section id="dialog-find">
<title>dialog-find</title>
blah blah blah
</section>
<section id="dialog-replace">
<title>dialog-replace</title>
blah blah blah
</section>
<section id="dialog-find-in-files">
<title>dialog-find-in-files</title>
blah blah blah
</section>
<section id="dialog-find-file">
<title>dialog-find-file</title>
blah blah blah
</section>
</section>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="sect-opening-and-saving">
<title>Opening and Saving Files</title>
<section id="dialog-open">
<title>dialog-open</title>
blah blah blah
</section>
<section id="dialog-save">
<title>dialog-save</title>
blah blah blah
</section>
<section id="file-selector">
<title>file-selector</title>
blah blah blah
</section>
<section id="app-prefs-file-selector">
<title>app-prefs-file-selector</title>
blah blah blah
</section>
</section>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="sect-plugins">
<title>Plugins</title>
<section id="app-prefs-plugins">
<title>app-prefs-plugins</title>
blah blah blah
</section>
</section>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="app-prefs-dialog">
<title>Preferences</title>
<section id="app-prefs-langs-and-filters">
<title>app-prefs-langs-and-filters</title>
blah blah blah
</section>
</section>

View File

@ -1,5 +0,0 @@
<xi:include href="editor-open-save.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="editor-editing.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="editor-prefs.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="editor-tools.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="editor-plugins.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="sect-user-defined-tools">
<title>User-defined Tools</title>
<section id="app-prefs-user-tools">
<title>app-prefs-user-tools</title>
blah blah blah
</section>
</section>

View File

@ -4,11 +4,11 @@
#define HELP_SECTION_LICENSE "app-license"
#define HELP_SECTION_PREFS_LANGS_AND_FILTERS "app-prefs-langs-and-filters"
#define HELP_SECTION_PREFS_PLUGINS "app-prefs-plugins"
#define HELP_SECTION_PREFS_USER_TOOLS "app-prefs-user-tools"
#define HELP_SECTION_PREFS_FILE_SELECTOR "app-prefs-file-selector"
#define HELP_SECTION_PREFS_DIALOG "app-prefs-dialog"
#define HELP_SECTION_PREFS_LANGS_AND_FILTERS "prefs-langs-and-filters"
#define HELP_SECTION_PREFS_PLUGINS "prefs-plugins"
#define HELP_SECTION_PREFS_USER_TOOLS "prefs-user-tools"
#define HELP_SECTION_PREFS_FILE_SELECTOR "prefs-file-selector"
#define HELP_SECTION_PREFS_DIALOG "prefs-dialog"
#define HELP_SECTION_DIALOG_FIND "dialog-find"
#define HELP_SECTION_DIALOG_REPLACE "dialog-replace"

View File

@ -3,7 +3,7 @@
<para>
&app; as a whole is distributed under the terms of GNU General Public License,
version 2, but most of its code is released under the GNU Lesser General Public
License. Full text of these licenses and list of licenses and acknowledgements for
License. Full text of these licenses as well as licenses and acknowledgements for
third-party software incorporated in &app; can be found in this section.
</para>
@ -17,4 +17,30 @@ third-party software incorporated in &app; can be found in this section.
<title>GNU Lesser General Public License</title>
<xi:include href="LGPL.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</sect1>
<sect1 id="license-lua">
<title>Lua license</title>
<programlisting><xi:include href="../moo/moolua/COPYRIGHT" parse="text" encoding="UTF-8"
xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
</sect1>
<sect1 id="license-lua-ex">
<title>Lua-ex library license</title>
<programlisting><xi:include href="../moo/moolua/lua-ex/COPYRIGHT" parse="text" encoding="UTF-8"
xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
</sect1>
<sect1 id="license-lua-lfs">
<title>LuaFileSystem license</title>
<programlisting>LuaFileSystem - File System Library for Lua
Copyright 2003-2007 PUC-Rio
http://www.keplerproject.org/luafilesystem
LuaFileSystem is a Lua library developed to complement the set of functions
related to file systems offered by the standard Lua distribution. LuaFileSystem
offers a portable way to access the underlying directory structure and file
attributes. LuaFileSystem is free software and uses the same license as Lua 5.1
Current version is 1.2.1.</programlisting>
</sect1>
</appendix>

View File

@ -5,8 +5,10 @@
<!ENTITY manrevision "0.1">
<!ENTITY date "November 2007">
<!ENTITY app "medit">
<!ENTITY editor-sections SYSTEM "editor-sections.xml">
<!ENTITY license SYSTEM "license.docbook">
<!ENTITY user-tools SYSTEM "user-tools.docbook">
<!ENTITY prefs SYSTEM "prefs.docbook">
<!ENTITY prefs-file SYSTEM "prefs-file.docbook">
]>
<article>
@ -25,7 +27,95 @@
</section>-->
&editor-sections;
<!--<section id="sect-opening-and-saving">
<title>Opening and Saving Files</title>
<section id="dialog-open">
<title>dialog-open</title>
blah blah blah
</section>
<section id="dialog-save">
<title>dialog-save</title>
blah blah blah
</section>
<section id="file-selector">
<title>file-selector</title>
blah blah blah
</section>
<section id="prefs-file-selector">
<title>app-prefs-file-selector</title>
blah blah blah
</section>
</section>-->
<!--<section id="sect-editing-text">
<title>Editing text</title>
<section id="dialog-find">
<title>dialog-find</title>
blah blah blah
</section>
<section id="dialog-replace">
<title>dialog-replace</title>
blah blah blah
</section>
<section id="dialog-find-in-files">
<title>dialog-find-in-files</title>
blah blah blah
</section>
<section id="dialog-find-file">
<title>dialog-find-file</title>
blah blah blah
</section>
</section>-->
<!--<section id="sect-searching">
<title>Search</title>
<section id="dialog-find">
<title>Searching in the document</title>
</section>
<section id="dialog-replace">
<title>dialog-replace</title>
blah blah blah
</section>
<section id="dialog-find-in-files">
<title>dialog-find-in-files</title>
blah blah blah
</section>
<section id="dialog-find-file">
<title>dialog-find-file</title>
blah blah blah
</section>
</section>-->
<!--<section id="prefs-dialog">
<title>Preferences</title>
<section id="prefs-langs-and-filters">
<title>app-prefs-langs-and-filters</title>
blah blah blah
</section>
</section>-->
&prefs;
&user-tools;
&prefs-file;
<!--<xi:include href="editor-plugins.docbook" xmlns:xi="http://www.w3.org/2001/XInclude"/>-->
<!--<section id="sect-plugins">
<title>Plugins</title>
<section id="prefs-plugins">
<title>app-prefs-plugins</title>
blah blah blah
</section>
</section>-->
&license;
<para role="generated-date">This document was generated

61
doc/prefs-file.docbook Normal file
View File

@ -0,0 +1,61 @@
<!-- ========== prefs-file ========== -->
<section id="prefs-file">
<title>Preferences files</title>
<para>
&app; preferences are stored in <filename>$HOME/.config/&app;rc</filename> file.
It is an XML file which may be edited to set preferences which have not found
their place in the <interface>Preferences</interface> dialog.
</para>
<note>
&app; reads the preferences file on startup and writes it whenever <guibutton>OK</guibutton>
or <guibutton>Apply</guibutton> button is clicked in the <interface>Preferences</interface>
dialog. Therefore, if you modify the preferences file, your changes may be overwritten,
and they not take the effect until you restart &app;.
</note>
<para>
The following "hidden" settings are available.
</para>
<variablelist>
<varlistentry><term><userinput>Editor/window_title</userinput>:</term>
<listitem>
Format of the window title. It is a string which may contain format sequences:
percent sign followed by a character:
<itemizedlist>
<listitem>
<userinput>%a</userinput>: application name;
</listitem>
<listitem>
<userinput>%b</userinput>: current document basename;
</listitem>
<listitem>
<userinput>%f</userinput>: full path of the current document;
</listitem>
<listitem>
<userinput>%u</userinput>: URI of the current document;
</listitem>
<listitem>
<userinput>%s</userinput>: the status of the current document, e.g. "<literal> [modified]</literal>".
It is prefixed with space, so that "<literal>%b%s</literal>" will produce a nice string;
</listitem>
<listitem>
<userinput>%%</userinput>: the percent character.
</listitem>
</itemizedlist>
Default value is "<literal>%a - %f%s</literal>" which produces something like
"<literal>&app; - /home/user/file [modified]</literal>".
</listitem>
</varlistentry>
<varlistentry><term><userinput>Editor/window_title_no_doc</userinput>:</term>
<listitem>
Same as <userinput>Editor/window_title</userinput>, used when no document is open. Default value
is "<literal>%a</literal>".
</listitem>
</varlistentry>
<varlistentry><term><userinput>Editor/tab_width</userinput>:</term>
<listitem>
Visual width of the Tab character, 8 by default.
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- ========== prefs-file ========== -->

136
doc/prefs.docbook Normal file
View File

@ -0,0 +1,136 @@
<!-- ========== prefs-langs-and-filters ========== -->
<section id="prefs-langs-and-filters">
<title>Selecting options and languages</title>
<para>
<guilabel>Languages and files</guilabel> tab in the <guilabel>Editor</guilabel>
section of the <interface>Preferences</interface> dialog allows customizing
how syntax highlighting language and a number of editing options are chosen
depending on the document filename, as well as setting editing options for
all documents which use given language and choosing file patterns and mime types
for which given language should be used.
</para>
<!-- ========== Language-specific options ========== -->
<section id="prefs-lang-options">
<title>Language-specific options</title>
<para>
Here you can set editing options on per-language basis, as well as define
for which file patterns and mime types given language should be used.
</para>
<variablelist>
<varlistentry><term><userinput>Language</userinput> combo box:</term>
<listitem>
Choose the language you want to customize. Settings for <literal>None</literal>
will apply to documents for which no syntax highlighting language was chosen.
</listitem>
</varlistentry>
<varlistentry><term><userinput>Mime types</userinput>:</term>
<listitem>
The given language will be used for files with these mime types, unless the language
is chosen based on the filename or overridden in the <interface>File filters</interface>
section.
</listitem>
</varlistentry>
<varlistentry><term><userinput>Extensions</userinput>:</term>
<listitem>
The given language will be used for files whose filenames match these patterns, unless
overridden in the <interface>File filters</interface> section.
</listitem>
</varlistentry>
<varlistentry><term><userinput>Options</userinput>:</term>
<listitem>
Default editing options to use in documents which use the given language. These options
can be overridden using <interface>File filters</interface> section, and options set
in the file text have a higher priority as well. See the
<link linkend="editing-options" endterm="editing-options.title"/> section for the format
of this entry content.
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- ========== File filters ========== -->
<section id="prefs-file-filters">
<title>File filters</title>
<para>
<interface>File filters</interface> section allows to customize editing options,
as well as syntax highlighting language, on per-document basis using regular expressions
which are matched against the document filename. Full file paths are used, so one can
have per-directory settings.<footnote><para>Use dollar if you need to match ends
of filenames, e.g. "<literal>\.doc$</literal>" will work as "<literal>*.doc</literal>"
pattern.</para></footnote>
</para>
<para>
The filters are applied in the order they appear in the list, one by one. All filters
are applied to every file, so several filters may affect options in the same file. In this
way one can set some options for a set of files or a directory, then set or modify some
additional options for certain files in that set, etc.
</para>
<para>
To add a filter, use <guilabel>New</guilabel> button. Click the filter in the list to
select it, then click the <guilabel>Filter</guilabel> or <guilabel>Options</guilabel>
part of it to edit. Use <guilabel>Delete</guilabel> button to delete a filter,
and <guilabel>Up</guilabel>/<guilabel>Down</guilabel> buttons to change the order in
which they are applied.
</para>
<para>
<guilabel>Filter</guilabel> field contains a regular expression matched agains the
document filename. If it is found in the filename, then the options from the
<guilabel>Options</guilabel> field are applied to the document.
</para>
<para>
<guilabel>Options</guilabel> field contains the options, in format described in the
<link linkend="editing-options" endterm="editing-options.title"/> section.
</para>
</section>
<!-- ========== Tools preferences ========== -->
<section id="editing-options">
<title id="editing-options.title">Editing options</title>
<para>
&app; has some editing options which can be set in the file text, or in the
<interface>Preferences</interface> dialog for sets of files or for given syntax highlighting
language.
</para>
<para>
To set the options in the document text, place the following on the first, second or the last
line of the document:
<programlisting>-%- <emphasis>options</emphasis> -%-</programlisting>
where <emphasis>options</emphasis> is the option string
<programlisting><emphasis>key</emphasis>: <emphasis>value</emphasis>; <emphasis>key</emphasis>: <emphasis>value</emphasis>; ...</programlisting>
(the latter is the format used also in the <interface>Preferences</interface> dialog).
</para>
<para>
Values can be strings, integer numbers, or boolean values. Boolean values may be specified
using <userinput>yes</userinput>/<userinput>no</userinput>,
<userinput>true</userinput>/<userinput>false</userinput>, <userinput>1</userinput>/<userinput>0</userinput>.
The following options are available:
<itemizedlist>
<listitem><para>
<userinput>lang</userinput>: syntax highlighting language to use in this document.
</para></listitem>
<listitem><para>
<userinput>strip</userinput>: a boolean value, whether trailing whitespace should be removed
from the document on saving.
</para></listitem>
<listitem><para>
<userinput>tab-width</userinput>: displayed width of the Tab character.<footnote><para>This is not an indentation
offset, this is the visual width of a Tab character.</para></footnote>
</para></listitem>
<listitem><para>
<userinput>use-tabs</userinput>: whether the Tab character should be used for indentation.
</para></listitem>
<listitem><para>
<userinput>indent-width</userinput>: an integer specifying indentation offset used when the
Tab key is pressed to indent text.
</para></listitem>
</itemizedlist>
</para>
<para>
&app; tries to understand modelines of Vim, Emacs, and Kate text editors, so chances are it will correctly
pick up the conventional settings from source files.
</para>
</section>
</section>
<!-- ========== User-defined tools ========== -->

381
doc/user-tools.docbook Normal file
View File

@ -0,0 +1,381 @@
<!-- ========== User-defined tools ========== -->
<section id="sect-user-tools">
<title>User-defined Tools</title>
<para>
&app; allows extending its functionality with user-defined
<emphasis>tools</emphasis>. It can be a Lua or Python (provided
&app; has been built with Python support) script
which is executed inside &app;, or a shell script which can
use the text of the open document as its input and/or output.
</para><para>
There is a number of predefined tools which you can use as
an example or to modify to suit your needs.
</para>
<!-- ========== Tools preferences ========== -->
<section id="prefs-user-tools">
<title>Managing tools</title>
<para>
To create a new tool or to modify existing ones, open
<interface>Preferences</interface> dialog and select
<guilabel>Tools</guilabel> in the list on the left.
</para><para>
Select the tool in the list or click the <guilabel>New</guilabel>
button to create a new one. To modify the order in which the tools
appear in the <guimenu>Tools</guimenu> menu (or in the document
context menu), use the <guilabel>Up</guilabel> and <guilabel>Down</guilabel>
button. To rename a tool, click its name in the list to select it
and then click again to edit the name. Use the <guilabel>Delete</guilabel>
button to delete a tool.
</para><para>
The following controls are available to modify the tools behavior:
</para>
<variablelist>
<varlistentry><term><userinput>Files</userinput></term>
<listitem>
<para>
Specifies for which files the tool is going to be available.
The entry content can be the following:
</para>
<itemizedlist>
<listitem>
<para>
a comma-separated list of file patterns, e.g. "<literal>*.c,*.h</literal>";
</para>
</listitem>
<listitem>
<para>
a comma-separated list of languages prefixed with "<literal>langs:</literal>", e.g.
"<literal>langs: c, c++, objc</literal>";
</para>
</listitem>
<listitem>
<para>
a regular expression matching document filename prefixed with "<literal>regex:</literal>", e.g.
the above pattern list may be written as "<literal>regex:\.[ch]$</literal>".
</para>
</listitem>
</itemizedlist>
<para>
Empty entry means the tool will be available for all documents.
</para>
</listitem>
</varlistentry>
<varlistentry><term><userinput>Options</userinput></term>
<listitem>
<para>
Specifies under which conditions the tool should be enabled. It is a comma-separated
list of the following:
</para>
<itemizedlist>
<listitem><para>
<userinput>need-doc</userinput>: the tool needs an open document;
</para></listitem>
<listitem><para>
<userinput>need-file</userinput>: the tool will not work in new unsaved documents.
</para></listitem>
<listitem><para>
<userinput>need-save</userinput>: the document will be saved before the command is executed.
</para></listitem>
<listitem><para>
<userinput>need-save-all</userinput>: all open documents will be saved before the command is executed.
</para></listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry><term><userinput>Command type</userinput></term>
<listitem>
<para>
The type of the tool: a Python script, a Lua script, or a shell script.
</para>
</listitem>
</varlistentry>
<varlistentry><term><userinput>Code text field</userinput></term>
<listitem>
<para>
Here you enter the actual script text.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Shell script tools also have the following controls available:
</para>
<variablelist>
<varlistentry><term><userinput>Input</userinput></term>
<listitem>
<para>
Specifies what text from the document should be passed to the command via its
standard input:
</para><para>
<userinput>None</userinput>: no input text.
</para><para>
<userinput>Selected lines</userinput>: the lines containing selection or the line containing the cursor
in case when no text is selected.
</para><para>
<userinput>Selection</userinput>: exact selected text. This will be different from "Selected lines"
if selection does not span whole lines of the document, for instance if it is
a single word.
</para><para>
<userinput>Whole document</userinput>: whole document contents.
</para>
</listitem>
</varlistentry>
<varlistentry><term><userinput>Output</userinput></term>
<listitem>
<para>
Specifies how the standard output of the command should be redirected.
</para><para>
<userinput>None</userinput>: the command output will be suppressed.
</para><para>
<userinput>None, asynchronous</userinput>: the command output will be suppressed, and the command
will be executed in background. For instance, you should use this if you need
to launch some external program like a web browser.
</para><para>
<userinput>Output pane</userinput>: the command output will be displayed in an output pane. This is
useful for running programs like compilers, where you want to see the output.
</para><para>
<userinput>Insert into the document</userinput>: output will be inserted into the current document at
the cursor position. It will replace the text used as an input, if any.
</para><para>
<userinput>New document</userinput>: new document will be created and the command output will be inserted
into it.
</para>
</listitem>
</varlistentry>
<varlistentry><term><userinput>Filter</userinput></term>
<listitem>
<para>
If the output pane is used, then it can be passed through a <emphasis>filter</emphasis>:
the filter can match filenames and line numbers, so when you click the text in the
output pane it will open the corresponding file. This is used for compilers and similar
commands, which output locations of errors in processed files.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- ========== Tools files ========== -->
<section id="user-tools-files">
<title>Storing tools in files</title>
<para>
It is possible to create tools without using the <interface>Preferences</interface> dialog,
they can be stored in files in <filename>tools</filename> subfolder of the &app; data
folders (or <filename>tools-context</filename> for tools which appear in the document context
menu). In particular, on Unix systems you can place files into <filename>$HOME/.local/share/medit/tools/</filename>
folder.
</para><para>
Names of the files in the <filename>tools</filename> folder are used as their menu item
labels, after stripping first two characters, so you can use two-character prefix to affect
the order of the menu items, e.g. you can have <filename>00Do Something</filename>,
<filename>01Another tool</filename> files to have them in that order in the menu. The files
may be of three types: files with extension "<filename>.py</filename>", they will be used
as Python scripts; files with extension "<filename>.lua</filename>", they will be used
as Lua scripts; and executable files, they will be executed in the same way as shell commands.
</para><para>
To set parameters for a tool, place them on the first or the second line of the file in
the following format:
<programlisting>!! <emphasis>key=value; key=value; ...</emphasis> !!</programlisting>
<emphasis>key</emphasis> may be one of the following:
</para>
<itemizedlist>
<listitem><para>
<userinput>position</userinput>: it can be <userinput>start</userinput> or <userinput>end</userinput>,
and defines whether the menu item will be located at the start or at the end of the menu.
</para></listitem>
<listitem><para>
<userinput>id</userinput>: the tool identificator.
</para></listitem>
<listitem><para>
<userinput>name</userinput>: the tool name, i.e. the label used in the menu item. It will override
the file name.
</para></listitem>
<listitem><para>
<userinput>os</userinput>: <userinput>windows</userinput> or <userinput>unix</userinput>. If specified,
then the tool will not be used when &app; is running on a different operating system.
</para></listitem>
<listitem><para>
<userinput>accel</userinput>: default keyboard accelerator used to invoke this tool.
</para></listitem>
<listitem><para>
<userinput>menu</userinput>: the menu to place this tool into. By default the tools are
located in the Tools menu, but they can be as well put into any other menu.
</para></listitem>
<listitem><para>
<userinput>langs</userinput>: comma-separated list of languages for which this tool will
be enabled.
</para></listitem>
<listitem><para>
<userinput>filter</userinput>, <userinput>file-filter</userinput>: defines for which files this tool
will be enabled. The value has the same format as in the <interface>Preferences</interface> dialog.
</para></listitem>
<listitem><para>
<userinput>options</userinput>: same as the <guilabel>Options</guilabel> entry content
in the <interface>Preferences</interface> dialog.
</para></listitem>
</itemizedlist>
<para>
In addition to these, you can set input and output options for executable files:
</para>
<itemizedlist>
<listitem><para>
<userinput>input</userinput>: can be <userinput>none</userinput>, <userinput>lines</userinput>,
<userinput>selection</userinput>, or <userinput>doc</userinput>.
</para></listitem>
<listitem><para>
<userinput>output</userinput>: can be <userinput>none</userinput>, <userinput>async</userinput>,
<userinput>pane</userinput>, <userinput>insert</userinput>, or <userinput>new-doc</userinput>.
</para></listitem>
<listitem><para>
<userinput>filter</userinput>: the output filter name.
</para></listitem>
</itemizedlist>
</section>
<!-- ========== Python scripts ========== -->
<section id="user-tools-python">
<title>Python scripts</title>
<para>
If &app; is built with Python support, then Python scripts have full access to the program
internals via builtin <symbol>moo</symbol> module. &app; classes extend classes from <symbol>pygtk</symbol>,
in particular the <symbol>moo.edit.Edit</symbol> class representing documents extends the
<symbol>gtk.TextView</symbol> class, and all editing operations can be implemented using
<symbol>pygtk</symbol> API.
</para><para>
Python scripts have the following variables predefined:
</para>
<itemizedlist>
<listitem><para>
<symbol>doc</symbol>: the current document object.
</para></listitem>
<listitem><para>
<symbol>window</symbol>: the current editor window.
</para></listitem>
<listitem><para>
<symbol>buffer</symbol>: the text buffer (a <symbol>moo.edit.TextBuffer</symbol> instance) of
the current document.
</para></listitem>
<listitem><para>
<symbol>editor</symbol>: the <symbol>moo.edit.Editor</symbol> object representing the text
editor. Use its methods to open/close files, switch between documents and windows, etc.
</para></listitem>
<listitem><para>
<symbol>moo</symbol>: the <symbol>moo</symbol> module, already imported so you can omit
<literal>import moo</literal> statement in scripts.
</para></listitem>
</itemizedlist>
</section>
<!-- ========== Lua scripts ========== -->
<section id="user-tools-lua">
<title>Lua scripts</title>
<para>
Lua scripts can use the standard Lua library, <symbol>lfs</symbol> and <symbol>lua-ex</symbol>
libraries, and <symbol>medit</symbol> package which provides some text editor API. Lua scripts
have the following variables and functions available.
</para>
<para>
<literal>doc</literal>: a table with the following fields:
<itemizedlist>
<listitem>
<literal>file</literal>: the document file path.
</listitem>
<listitem>
<literal>name</literal>: the document file basename.
</listitem>
<listitem>
<literal>dir</literal>: the document file directory.
</listitem>
<listitem>
<literal>ext</literal>: the document filename extension including the period.
</listitem>
<listitem>
<literal>base</literal>: the document filename without the extension: the basename is always
<literal>base..ext</literal>.
</listitem>
</itemizedlist>
</para>
<para>
<literal>Cut()</literal>, <literal>Copy()</literal>, <literal>Paste()</literal>: clipboard operations.
</para>
<para>
<literal>Backspace()</literal>, <literal>Delete()</literal>: corresponding key actions.
</para>
<para>
<literal>Up()</literal>, <literal>Down()</literal>, <literal>Left()</literal>, <literal>Right()</literal>:
move cursor as the arrow keys do.
</para>
<para>
<literal>Selection()</literal>: returns selected text as a string. Returns <literal>nil</literal>
when no text is selected.
</para>
<para>
<literal>Select(n)</literal>: selects <literal>n</literal> characters to the right
if <literal>n</literal> is positive, and <literal>-n</literal> characters to the left
if it is negative.
</para>
<para>
<literal>Insert(...)</literal>: inserts text at cursor. Namely, it converts each argument to a string
and inserts the result into the document.
</para>
<para>
<literal>NewLine()</literal>: inserts new line character.
</para>
</section>
<!-- ========== Shell scripts ========== -->
<section id="user-tools-shell">
<title>Shell scripts</title>
<para>
In addition to the document text passed via standard input,
shell scripts have a number of environment variables set. <literal>$APP_PID</literal>
variable is set to the current process process id, so that opening a file in the
same instance of &app; is as simple as <command>&app; filename</command> (on the other
hand, you will have to use command line options if you need to run a new &app; instance).
The following environment variables are set when scripts are executed:
</para>
<itemizedlist>
<listitem>
<literal>DOC</literal>: the document basename.
</listitem>
<listitem>
<literal>DOC_DIR</literal>: the document file directory. The full file path is
<literal>$DOC_DIR/$DOC</literal>.
</listitem>
<listitem>
<literal>DOC_BASE</literal>: the basename without extension.
</listitem>
<listitem>
<literal>DOC_EXT</literal>: the document filename extension including the period. The basename
is always <literal>$DOC_BASE$DOC_EXT</literal>.
</listitem>
<listitem>
<literal>LINE</literal>: the number of the line containing cursor.
</listitem>
<listitem>
<literal>DATA_DIR</literal>: the user data directory. For example the tools are stored
in <filename>$DATA_DIR/menu.cfg</filename> file and in files in the <filename>$DATA_DIR/tools/</filename>
directory.
</listitem>
</itemizedlist>
<para>
Additionally, all processes ran from inside &app; will have <filename>DATADIR/scripts</filename>
directories in <literal>$PATH</literal>, so you may place some &app;-specific programs
or scripts into <filename>USERDATADIR/scripts/</filename> to be used from shell script tools.
</para>
</section>
</section>
<!-- ========== User-defined tools ========== -->

View File

@ -30,10 +30,10 @@
</metadata>
<styles>
<style id="header-elements" _name="Header Elements" map-to="def:keyword"/>
<style id="formatting-elements" _name="Formatting Elements" map-to="def:keyword"/>
<style id="gui-elements" _name="GUI Elements" map-to="def:keyword"/>
<style id="structural-elements" _name="Structural Elements" map-to="def:keyword"/>
<style id="header-elements" _name="Header Elements" map-to="xml:element-name"/>
<style id="formatting-elements" _name="Formatting Elements" map-to="xml:element-name"/>
<style id="gui-elements" _name="GUI Elements" map-to="xml:element-name"/>
<style id="structural-elements" _name="Structural Elements" map-to="xml:element-name"/>
</styles>
<definitions>

View File

@ -97,6 +97,12 @@
<style name="xml:processing-instruction" bold="true"/>
<style name="xml:doctype" foreground="dark-red" bold="true"/>
<style name="docbook-element" foreground="#004141" bold="true"/>
<style name="docbook:header-elements" use-style="docbook-element"/>
<style name="docbook:formatting-elements" use-style="docbook-element"/>
<style name="docbook:gui-elements" use-style="docbook-element"/>
<style name="docbook:structural-elements" use-style="docbook-element"/>
<style name="js:object" foreground="dark-green"/>
<style name="js:constructors" bold="true"/>

View File

@ -63,12 +63,11 @@ enum {
KEY_INPUT,
KEY_OUTPUT,
KEY_FILTER,
KEY_EXE,
N_KEYS
};
static const char *data_keys[] = {
"input", "output", "filter", "exe", NULL
static const char *data_keys[N_KEYS+1] = {
"input", "output", "filter", NULL
};
struct _MooCommandUnxPrivate {
@ -730,7 +729,7 @@ init_filter_combo (GtkComboBox *combo)
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
gtk_list_store_append (store, &iter);
/* Translators: "None" means no filter for a shell command, do not translate the part before | */
/* Translators: "None" means no output filter for a shell command, do not translate the part before | */
gtk_list_store_set (store, &iter, COLUMN_NAME, Q_("Filter|None"), -1);
ids = moo_command_filter_list ();

View File

@ -494,7 +494,8 @@ parse_params (MooUserToolInfo *info,
g_free (info->filter);
info->filter = g_strdup_printf ("langs: %s", value);
}
else if (!strcmp (key, KEY_FILTER))
else if (!strcmp (key, KEY_FILTER) ||
!strcmp (key, "file-filter"))
{
g_free (info->filter);
info->filter = g_strdup (value);
@ -553,7 +554,7 @@ cmp_filenames (const void *p1,
return strcmp (*sp1, *sp2);
}
#define NAME_PREFIX_LEN 3
#define NAME_PREFIX_LEN 2
static void
load_directory (const char *path,
MooUserToolType type,