Archive for the ‘TeXworks’ Category
Scripting in TeXworks
Stefan Löffler has recently posted to the TeXworks mailing list that he’s sorted out a patch to integrate Lua into TeXworks. Many people will be aware that Lua is very much the scripting language of the moment in the TeX world, because of the LuaTeX project. So it makes sense to consider it as a method for scripting TeXworks. The idea has always been that TeXworks will have a simple interface but powerful features available to those who want them. So adding scripting is a vital step forward. With a light-weight scripting system available, power users can code their own features into TeXworks while leaving the basics accessible to everyone.
That doesn’t mean that Lua has to be the (only) language available: Jonathan Kew (TeXworks lead developer) has suggested QtScript (which is JavaScript-like) as a possibility. TeXworks is built using Qt, so there is a definite logic here. As Jonathan himself points out, actually having a patch available certainly means that Lua is likely to be integrated!
TeXworks for developers
The TeXworks program is aim at making using TeX easier for day-to-day TeX users. By stripping the interface down to a minimum, I feel it really succeeds. I’m sure that many experienced TeX developers prefer more “full featured” editors (such as WinEdt on Windows or AUCTeX on Linux). However, I find that I rarely use any of the more complex features of these richer editors, and so I’m using TeXworks for both day-to-day documents and writing LaTeX packages.
There are still a few things I’d like to have in TeXworks that are currently lacking, but I’m hoping that as the program develops it will be possible to do some user extension and add on what I’d like. For example, I’d like to be able to use hard line wrapping (with a fixed number of characters in a line) and to delete lines of text rapidly (“killing” them). What I have been able to do so far is create some customised syntax highlighting and some completion code, similar to DTX submode for WinEdt. At the moment, the syntax highlighting I’ve gone for looks like:
[dtx patterns]
# comments
red Y \^\^A.*
# special characters
darkred N [$#^_{}&]
# Guards
gold N %<(?:[A-Za-z0-9!\|]+|.)>
limegreen N %<\*(?:[A-Za-z0-9!\|]+|.)>
crimson N %</(?:[A-Za-z0-9!\|]+|.)>
# Macrocode
green N ^%[\s]{4}\\(?:begin|end)\{macrocode\}
# LaTeX environments
darkgreen N \\(?:begin|end)\s*\{[^}]*\}
# LaTeX packages
darkblue N \\usepackage\s*(?:\[[^]]*\]\s*)?\{[^}]*\}
# control sequences
blue N \\(?:[A-Za-z@:_]+|.)
# Non-code
grey Y %.*
which is certainly helping me to improve my understanding of regex writing! There are a few things I can’t seem to get working quite as I’d ideally like, but for the moment I’m happy.
For auto-completion, I’ve had to make some assumptions about the beginnings of lines, to get the % characters correct:
%%!TEX encoding = UTF-8 Unicode
arg:=\Arg{#INS#}
bcode:= \begin{macrocode}#RET##INS##RET#% \end{macrocode}#RET#•
benv:=\begin{environment}{#INS#}#RET#%•#RET#%\end{environment}#RET#%•
bmac:=\begin{macro}{#INS#}#RET#%•#RET#%\end{macro}#RET#%•
cc:=\changes{#INS#}{•}{•}#RET#•
cmd:=\cmd{#INS#}
cs:=\cs{#INS#}
denv:=\DescribeEnv{#INS#}
dmac:=\DescribeMacro{#INS#}
dopt:=\DescribeOption{#INS#}
ecode:= \end{macrocode}#RET##INS#% \begin{macrocode}#RET#•
eenv:=\end{environment}#RET#
emac:=\end{macro}#RET#
m:=\meta{#INS#}
meta:=\meta{#INS#}
pkg:=\pkg{#INS#}
\Arg{#INS#}
\changes:=\changes{#INS#}{•}{•}#RET#•
\cmd{#INS#}
\cs{#INS#}
\meta{#INS#}
\pkg{#INS#}
I’d be interested to hear how other people find TeXworks for writing TeX code, and of course for any contributions to my configuration ideas.
TeXworks updated
The TeXworks program has had a few bug fixes recently, for example to get spell-checking and syntax highlighting to work together properly. For Linux users, compiling from the source is the best way to get a current build. For those of use on Windows, Alain Delmoitte is very kindly providing public builds now and then: he has updated his build to build 291. Alain is also working on a manual (in French and English) for TeXworks, available from the same site.
TeXworks for package authors
The TeXworks project is targetted at making life easier for new users of TeX. The clean, Mac-inspired interface certainly makes writing TeX documents very easy, as does the buit-in PDF viewer with SyncTeX ability. As a long time user of a more “traditional” editor (WinEdt), I’ve found that TeXworks is good for all of my editing, to the point that I’m not longer using WinEdt. The parred-down feature set really suits my way of working (I’ve never liked all of the editor icons in a traditional IDE), and even at this pre-release stage the advanced features (such as regex searching) are impressive.