Prev Up Top Next Contents

7.7 External editors

The therion files are plain text files, therefore one can write them with any text editor. Two popular editors, at least in the Unix community, are emacs (http://www.gnu.org/software/emacs/ ) and vi (http://www.vim.org ). These editors have been around for a while and have nice features to make the editing easier. In particular they can highlight the text with colors to emphasize keywords and errors helping the user to spot a mistake without the need to run therion. They can interact with other programs, so that they can become a sort of "integrated development environment"
They are however limited to text editing and have no graphical editing capabilities for the maps. They cannot compete with xtherion on this regard. But they can integrate it for the text editing, since they are more powerful.

7.7.1 emacs

An emacs "therion-mode" has been written by M. Luthi and can be downloaded from the contrib section of the therion wiki. The syntax highlight is limited to therion config files, but it integrates the therion command which is executed with C-c C-c. Emacs can also spawn a shell, so you can preview the map with xpdf --remote therion cave.pdf &. Replace "cave.pdf" with the name of your map file. Here "therion" is just the name of the remote xpdf (can use another name if you want). The ampersand '&' at the end is necessary only the first time, to send the process in background. When you exit emacs asks you if you want to terminate the xpdf process as well.
The installation instructions are contained in the file itself. Basically you put the file together with the others mode files in your pc, and write the commands to use it the in your emacs configuration file (usually $HOME/.emacs),
(require 'therion-mode)
(setq auto-mode-alist (cons '("\\.th$" . therion-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("thconfig\\.*" . therion-mode) auto-mode-alist)

7.7.2 Aquamacs

Aquamacs is an emacs for MacOS. You can add a therion mode to it [M. Sluka]. You must create a directory for emacs modes and copy the therion-mode file there.
From a terminal, you type
   sudo mkdir /Library/Application\ Support/Emacs
   sudo mkdir /Library/Application\ Support/Emacs/site-lisp
   sudo cp therion-mode.el /Library/Application\ Support/Emacs/site-lisp/
Alternatively from Finder (as Administrator):
  1. make the directory /Library/Application Support/Emacs/site-lisp/
  2. copy to that directory the file therion-mode.el
Finally with a plain text editor add the following lines to your emacs preference file, ~/Library/Preferences/Aquamacs Emacs/Preferences.el:
  (require 'therion-mode)
  (setq auto-mode-alist (cons '("\\.th$" . therion-mode) auto-mode-alist))
  (setq auto-mode-alist (cons '("thconfig\\.*" . therion-mode) auto- mode-alist))

Editing with emacs
Fig. 91. Editing with emacs

7.7.3 Vi

The vi syntax-file can be downloaded from the contrib section in the therion wiki. The syntax highlight covers both the config and the data files (both ".th" and ".th2"), but it is far from complete.
To invoke commands from vi you enter ex (type ':') and type '!' followed by the command and its arguments. For example :!therion thconfig.plan. This invokes therion with the configuration file thconfig.plan. Therefore you can also invoke a preview: :!xpdf --remote therion cave.pdf &. The output of the command as displayed in the shell and remains on the screen until you press a key. You can always go back to the shell with :sh (and you go back ti vi with the command exit, or C-d).
It is rather convenient to have a makefile with the possible targets and use make.

Editing with vi
Fig. 92. Editing with vi


7.7.4 Inkscape

Thomas Holder has written python extensions for Inkscape, to import and export drawings as therion th2 files. Inkscape is an open source program to draw SVG (Scalable Vector Graphics), it requires a number of libraries and is probably an overdoing for therion scrap files having functionalities that have no use for therion, and missing others (mostly the "semantics" of therion).
You need to put the extension files (.py and .inx) in the inkscape extensions directory, either the system (/usr/share/inkscape/extensions) or the user one (~/.config/inkscape/extensions). After that therion th2 files can be loaded in inkscape.
It is a good tool to remaster therion drawings. Points are displayed with "conventional" symbols. Label points are displayed with the associated text. Lines too are shown by the type, with some exceptions: for instance label lines do not show the text (although this is correctly imported and exported). Areas are not supported, they are not show in inkscape, but are correctly put back when the file is saved.
Using the "select" tool (arrow) points can be easily grabbed and moved around. Lines can also be selected by clicking on, and shifted or rescaled. The "control point" tool (arrow pointing to a litte square) allows to modify the control points of lines, just like as in xtherion.
The type of lines and points is stored in the object label. The type can be changes with the "Objects Properties" dialog. Alternately these can be changed on the selected objetcs with the menu "Extension | Therion | Set...". You can also specify the subtype; although this does not affect the display, it is correctly written in the export. The "Objects Properties" dialog has two checkboxes: "Hide" and "Lock". The former hides the object which can be seen again by clicking the box again. The latter freezes the object wich caqnnot be modified since
Lines can be drawn as free-hand or as bezier curves (as in xtherion). Free-hand lines are easier to draw but they usually have far too many points and can be "jagged" (zoom in to check it). You can smooth them and reduce the number of points using the "Path|Simplify" tool. Editing of lines with line-point options is not supported (these lines are marked as read-only when the th2 file is imported).
To add a point there is a hidden layer with all point symbols from which you can take a point and put it on the drawing. Alternatly, you can draw a little circle and set the point type in its label; however these points are shown as circles instead of with the speleological symbols. Points with orientation are correctly imported. You can set/modify the orientation of points within the label, but this is not reflected in the display.
Background images are also put on an hidden layer. To show them you need to un-hide it, in the "Layer panel".
When you import a th2 file with several scraps, these are all put in a single layer, and later exported as one scrap.
There is nothing to help the user specify the proper terms in order to write a syntactically correct th2 file. Nevertheless it is a big improvement over xtherion as far as drawing is concerned. It is easier to draw lines, and to move line points.
Inkspace website is http://inkscape.org/ , and the extension is available at http://www.thomas-holder.de/projects/inkscape-speleo/extensions/th2-latest.zip .

Drawing with Inkscape
Fig. 93. Drawing with Inkscape


therion users - Sun Jan 15 12:58:03 2012
Prev Up Top Next Contents

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.