[texworks] Bullet and Lua

Alain Delmotte alain.delmotte at leliseron.org
Fri Nov 4 15:02:07 CET 2011


Hi!

I did translate all my Python scripts to Lua.

I had a problem to insert the bullet (the one used for 
autocompletion).

Under Lua it is created with "\226\128\162" in a string.
For example the following code, to create a figure 
environment from an existing text for the caption, allows to 
move with Ctrl+Tab or Ctrl+Shift+Tab to the positions to 
fill in.
========================
--[[TeXworksScript
Title: i&mage \figure
Description: Encloses the current selection in a picture 
environment
Author: Alain Delmotte from Stefan Löffler & Jonathan Kew
Version: 0.1
Date: 2011-11-01
Script-Type: standalone
Context: TeXDocument
]]

txt = TW.target.selection
if (txt == nil) then txt = "" end
TW.target.insertText("\\begin{figure}[ht]\\centering\n\\includegraphics[width=\226\128\162cm]{\226\128\162}\n\\caption{" 
.. txt .. "}\n\\label{\226\128\162}\n\\end{figure}\n")
TW.target.selectRange(TW.target.selectionStart - 
string.len(txt) - 1, string.len(txt))
=======================

Remark the "\n" to insert a line feed as it looks like the 
string to be created should be in the same line (no CRLF in 
the middle)

Also on the second line the & is to create an accelerator, 
but I haven't yet succeeded to use it with Windows 7!!!

Regards,

Alain





More information about the texworks mailing list