"Fossies" - the Fresh Open Source Software Archive
Member "zim-0.71.1/data/manual/Help/Custom_Tools.txt" (12 Jan 2018, 3841 Bytes) of package /linux/privat/zim-0.71.1.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard
) with prefixed line numbers.
Alternatively you can here view
the uninterpreted source code file.
1 Content-Type: text/x-zim-wiki
2 Wiki-Format: zim 0.4
4 ====== Custom Tools ======
6 Zim allows you to define custom tools to extend the basic functionality with simple functions that can be handled by an external program or script. The custom tool manager allows you to quickly extend functionality in zim by shell scripts or other external programs. It is also useful to prototype plugin functionality without having to learn the full API for plugins.
8 Note: the "tool" is always a single executable command. To use a more complex shell command, e.g. with a pipe, you should write a shell script first and call the script as an executable from the "tool".
10 ===== Add a custom tool =====
11 To add a custom tool, open up the custom tool manager dialog using the menu item //Tools// -> //Custom Tools//. Now press the "Add" icon button and zim will prompt for the properties of a new tool.
13 The **Name** is used in the tools menu for this tool and is mandatory.
15 The **Description** should be a slightly more verbose description of this tool. It is used for example as the tooltip for toolbar items.
17 The **Command** ...
19 When defining a command, you can use the following parameters to supply the external program with some context information from within zim:
21 **%f** for page source as a temporary file
22 **%d** for the [[Help:Attachments|attachment]] directory of the current page
23 **%s** for the real page source file (if any)
24 **%p** for the page name
25 **%n** for the notebook location (file or folder)
26 **%D** for the document root (if any)
27 **%t** for the selected text or word under cursor
29 The optional **Icon** is used for toolbar items and for menu items depending on your Gtk appearance settings.
31 Then there is the checkbox **Command does not modify data**. Enable this option if your tool only read data but does not modify it. In that case zim will execute the application in the background and keep running. Otherwise, if your tool does modify data, zim has to wait for it to finish and reload the current page.
33 If the option **Output should replace current selection** is enabled (and the above checkbox is not enabled) the output of the command is used to replace the current selection in the editor window. This can be used for custom commands that modify a single word or sentence.
35 The option **Show in the toolbar** determines if this tool will be added to the toolbar or not.
37 Tools are always visible in the "Tools" menu in the main window. Depending on the parameters they take, they may also be shown in the context menus for pages or for selected text in the editor.
40 ===== Developing custom tool scripts =====
41 If you start writing scripts for custom tools that go further than just calling another program directly here are some tips:
43 When testing out scripts that directly modify the notebook directory, make sure you have backups of your data. It might also be a good idea to enable version control and save a snapshot of the notebook before running a script.
45 If you want to modify the wiki syntax in an automated way, it is worth considering to do your script in python and directly use the ''zim.formats.wiki'' module for parsing the wiki page. Once you take this step it becomes relatively easy to turn the script into a full plugin module later on.
47 If your script needs e.g. a custom dialog to prompt information from the user it is advised to look into python and gtk as well. The Glade editor may help you to rapidly draw a dialog. Again, by using this framework it will be easy to turn the script into a plugin later on.
49 One limitation of these custom tools is that you can not interact directly with the textbuffer. For example you can not change the cursor position or apply changes which will be undoable. To achieve this you will need to look into writing a real plugin and use the API for the text buffer.