Customization of LaTeX.bsh
Version 11-October-2007.
Customization in the LaTeX.c configuration file.
A simple configuration file
For those like me who don't like to read documentation, the following configuration
file is almost sufficient for discovering its syntax (the HTML version of the
dialog mimics the actual version concerning tabs and tooltips).
The first string
in button definitions contains "e" for empty commands (i.e., for labels),
"c" for clipper commands, "s" for system commands,
"l" for BeanShell commands plus "i" for icons and "t" for
text. "TT:" indicates tooltips.
In command strings: | represents the selected text for clipper commands
or the name of the project main file for system commands.
To see this dialog working with jEdit, it suffices to replace the content of the
file LaTeX.c by the following lines (see the file LaTeX4.c in the goodies
sub-directory).
// Dialog window name can be replaced
JDialog frame = new JDialog(view, "Demo", false);
// Size of the dialog window
int d_width = 180;
int d_height = 130;
// Position "left", "right" or "bottom"
String d_position = "right";
// Maximum number of panels and of buttons per panel
JComponent[][] f = new JComponent[2][4];
// Number of rows of buttons per pannel
int nbrow = 2;
// Number of pixels between buttons
int buttonPadding = 1;
// Background color of panes
Color paneBgColor = new Color(255,255,255);
// Relative path to icons from directory containing this macro
String path2icons = "imagescol";
// Definition of the strings appearing on the tabs
String[] tabn = new String[2];
tabn[0] = "TAB1";
tabn[1] = "TAB2";
// Definition of tooltips for tabs
String[] tabnTooltips = new String[2];
tabnTooltips[0] = "Some title for TAB1";
tabnTooltips[1] = "Some title for TAB2";
// Definition of buttons and actions performed
String[][][] tabx =
{
{ // TAB_1
{"ei","","latex.png","orange" },
{"ct","\\begin{center}\n|\n\\end{center}","center" },
{"ct","\\footnote{|}","footnote","TT:Set selected text as a footnote" },
{"ct","||","repeat","white","orange" },
} ,
{ // TAB_2
{"et","","<html><b>Commands</b></html>","black","white" },
{"lt","Macros.getMacro(\"Text/Add_Prefix_and_Suffix\").invoke(view);",
"prefix/suffix","green","black" },
{"st","latex |","Latex","green","black" },
{"lt","frame.dispose();","Close","red","black","TT:Close dialog" },
},
};
Dialog layout
Click the button "Edit macro" of the command panel in order to
open the configuration file LaTeX.c. In this file:
The title of the dialog window (here LaTeX) can be modified in
JDialog frame = new JDialog(view, "LaTeX", false);
You can also modify the size and the location ("right", "left" or
"bottom") of the dialog window (see also nbrow below, it must be reduced
if you replace the default "tall" shape by a "fat" one).
int d_width = 150;
int d_height = 450;
String d_position = "right";
The maximum number of panels and of buttons per panel must be defined,
by default the number of panels is limited to 6
and the number of buttons per panel is limited to 70. If necessary
change these values in
JComponent[][] f = new JComponent[6][70];
The number of rows of buttons per panel is 16 in the default panels.
It can be modified in
int nbrow = 16;
Number of pixels between buttons
int buttonPadding = 1;
Background color of panes
Color paneBgColor = new Color(0,0,0);
The relative path to the icons directory from the directory containing this macro
is imagescol by default. It can be modified in
String path2icons = "imagescol";
Strings appearing on the tabs, see
String[] tabn = {"Gene1","Gene2","Pres","Math1","Math2","Greek","Cmds"};
Tab tooltips, see
String[] tabnTooltips = {"Documents, breakings, cross references",etc...};
Personal panel
The personal panel is for users who prefer to concentrate on a single panel the
most used commands (number limited to 70). In this case you can copy some lines from LaTeX.c corresponding
to your preferred commands and paste them in the personal panel section of LaTeX.c.
You can also add your personal clipper commands or invoke various macros
(for example those in the directory macros/text). The syntax is explained
below. Two short illustartive examples are proposed now:
- For a clipper command which clips the selected text as follows {\bf selected_text}
the command is
{"ct","{\\bf |}","bf"}, (where| represents the selected text).
- Invokation of the Prefix and Suffix macro located in macros/text
{"lt","Macros.getMacro(\"Text/Add_Prefix_and_Suffix\").invoke(view);", "Pref & suff","red"},.
See here for more examples.
Don't forget the coma at the end. It is "easy" to corrupt the LaTeX.c file but difficult
to identify problems, so, it is suggested to reopen for validation the dialog after a command line is added.
Syntax
Click the button "Edit macro" of the
Command or Perso panels in order to
open the configuration file LaTeX.c and scroll down to the
relevant area and read the explanations.
Each element tabx[i][j] is an array containing 3 to 6 strings (the indice i corresponds
to tabbed panes, here from 0 to 5, the indice j corresponds to buttons
on each tabbed pane).
- 1st string: "et", "ei", "ct", "ci",
"lt", "li", "st" or "si".
- "e" means empty,
- "c" means clipper command,
- "l" means local command (Beanshell command in fact),
- "s" means system command
- "t" means text,
- "i" means icon.
- 2nd string: command that can be "empty" or of "clipper", "local"
or "system" type
- clipper type command example: "{\\bf |}" (| will be replaced by the selected text).
- local type command example: "frame.dispose()".
- system type command example: "dvips -o |.ps |" (| will be
replaced by the master document).
Note that commands are separated in the command string by \n
- 3rd string: some text or an icon name for defining button foreground.
- text case if "t" is in the first string.
- icon case if "i" in the first string. Supported icons: .png or .gif (the .gif extension can be omitted).
All icons should be by defaut is the imagescol subdirectory.
- 4th string: optional, foreground color (case "t") or background color (case "i")
- 5th string: optional, background color (case "t"). Note that depending on
Look and Feel, the background color might be interpreted as the circumference
of the button. Warning: in this case white foreground is not visible.
- Last string: optional, for defining tool tips, e.g., "TT:My tool tip string".
Illustrative examples
A few illustrative examples: tabx[i][j] =
- {"et","",""},: "e" for empty command (if the second string is
not empty, the corresponding command will be ignored). The button is
replaced by an empty "JLabel".
- {"et","","Slides"},: as above but the "JLabel" is not empty. "t" indicates that this
"JLabel" will contain the text "Slides".
- {"ct","{\\huge |}","Huge"},: "c" indicates that this is a clipper command, i.e.,
the selected text will be replaced by {\huge selected-text} in the active buffer.
If no text is selected, the caret will move to the position of "|".
"t" means that the text "Huge" will appear on the button.
- {"ci","\\alpha","alpha","red"},: "c" for clipper command, here, \alpha
will be written in the active buffer at the caret position,
"i" indicates that the third argument is an icon name, here "alpha.gif"
(icons are stored in the directory "imagescol", customizable). The icon will appear
on a red button.
- {"lt","frame.dispose();","Close","white","black"},: l for local command. Here the local
command is frame.dispose() that closes the dialog window. The text "Close" will
appear in white on a black button.
- {"lt","setMasterFile()","Main file","red"},. As above but the
local command is the user defined function setMasterFile() added at
the end of the LaTeX.c file.
The text "Main file" will appear in red.
Note that from version of September 2007,
the macros originally defined in the LaTeX.c file have been removed from this file.
- {"lt","Macros.getMacro(\"Text/Add_Prefix_and_Suffix\").invoke(view);", "Pref & suff","red"},.
As above but here the local command is a macro (Add_Prefix_and_Suffix appearing here in the
macros/Text menu).
- {"st",latexString,"LaTeX"},: "s" for system command. The macro will ask the system
to execute the string latexString in which
| has been replaced by the master document name without tex extension.
- {"st","makeindex |","Makeindex"},: as above but here the command string was
not defined earlier.
Comments
-
Note that the string "|" might appear in some clipper command definitions
like \begin{array}{|c|}. In order to avoid the replacement of "|"
by the buffer selected text, use "\\|" instead of "|"
(e.g. "\\begin{array}{\\|c\\|}").
-
For system commands some shortcuts are very useful.
For example assume that the file of the active buffer is
/home/foo/file.tex:
- $c = file name without extension nor path (e.g., file)
- $d = directory with full path (e.g.,
/home/foo)
- $f = file with extension and full path (e.g., /home/foo/file.tex)
- $n = file name with extension (e.g., file.tex)
- $u = URL for browsers (e.g.,
file://home/foo/file.tex) (don't use because
one slash is missing ("file://" should be "file:///").
For example, if you want to run dvips -o file.ps file the system command strings
are "cd $d" followed by "dvips -o $c.ps $c".
- The commands separator is \n, for example "cd $d \n dvips -o $c.ps $c".
-
For creating new gif icons you can use the script tex2gif.py of
http://www.wag.caltech.edu/home/rpm/projects/tex2gif/
(I used myself an adapted version of this script for batch generation of sets of coloured icons).
Example of customization of the panels.
This is a simple concatenation of the seven panels shown here.
(the corresponding configuration file is LaTeX3.c in the goodies
sub-directory)
|