[texworks] Bullet and Lua

Paul A Norman paul.a.norman at gmail.com
Sat Nov 5 04:38:04 CET 2011


Hi Alain,

Good researching on the \226\128\162 bullet.

Ok if you are doing a lot of that, I've attached the current version 0.311
of my makeScript.js, you just have a new blank document open, cursor in
editor, run  makeScript.js and it walks through the skeleton of making
QtScript, Python, or Lua script (if you allow the established shortcut keys
that would be just
Alt N Alt S)

I used make a new script and copied and pasted your text (changed the
title), and  under Xp when I ran the script ..

--[[TeXworksScript

Title: Trial &Lua

Description: Encloses the current selection in a picture environment

Author: Alain Delmotte from Stefan Löffler & Jonathan Kew

Version: 0.1

Date: 2011-11-05

Script-Type: standalone

Context: TeXDocument

Shortcut: Alt+T, Alt+Q

]]


 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))


The results under Xp were:


\begin{figure}[ht]\centering

\includegraphics[width=•cm]{•}

\caption{}

\label{•}

\end{figure}

Plus I can see in my case (Xp) see the accelerator key on the menu item, in
my case an underlined L

Paul

On 5 November 2011 03:02, Alain Delmotte <alain.delmotte at leliseron.org>wrote:

> 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
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texworks/attachments/20111105/1c93efc3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makeScript_0.311.zip
Type: application/zip
Size: 3320 bytes
Desc: not available
URL: <http://tug.org/pipermail/texworks/attachments/20111105/1c93efc3/attachment-0001.zip>


More information about the texworks mailing list