[texworks] Suggestions for the next TeXworks version

Alain Delmotte esperanto at swing.be
Tue May 13 17:10:56 CEST 2014


Hi Lukas,

Just an answer for one of the points:

Le 13/05/2014 13:13, Lukas Császár a écrit :
> o) An option (or hotkey) that puts marked content into curly
> braces (and places the cursor in front of the opening
> brace). This could be useful if one decides to precede code
> with a makro after it has been already written.
>
It is possible to create scripts to do that; I have a 
collection of scripts in the scripts subfolder of the 
resources folder of TeXworks. The scripts appear in the 
Scripts menu.
Example to create a chapter title when the text of the title 
already exists: one select the text, then type Alt+W and Alt+&
==============
--[[TeXworksScript
Title: d: chapter \c&hapter
Description: Encloses the current selection in \chapter{}
Author: Alain Delmotte from Stefan Löffler & Jonathan Kew
Version: 0.1
Date: 2011-11-01
Script-Type: standalone
Context: TeXDocument
Shortcut: Alt+W, Alt+&
]]

txt = TW.target.selection
if (txt == nil) then txt = "" end
TW.target.insertText("\\chapter{" .. txt .. "}")
TW.target.selectRange(TW.target.selectionStart - 
string.len(txt) - 1, string.len(txt))
==============

Alt+W is the first part of the combination (for structure 
scripts) and Alt+& for chapter (the & is lowercase on the 1 
key on a Belgian AZERTY keyboard)

NB. The "&" character in the Title is an accelerator in the 
Windows menu (this I developed on my translation / 
localisation of TeXworks, I did it also for the English 
version and proposed it some time ago in this list.)

So you have to change the lines 2 - 3 - 9 and 14 for what 
you want. If you just want {selection}, line 14 will be
TW.target.insertText("{" .. txt .. "}")

Regards,

Alain





More information about the texworks mailing list