[texworks] shortcuts with multiple letters
Mark Yagnatinsky
markyag at gmail.com
Thu Mar 16 01:28:34 CET 2017
First off, I never knew about shortcuts.ini before; this is a great feature
and needs to be made more discoverable. I suggest, at a minimum, that a
fresh TeXworks installation creates an empty shortcuts.ini file so that
someone might wonder what it's for. Maybe someone should file a feature
request. (Maybe me??)
Second, it seems a bit silly that the syntax for shortcuts in shortcuts.ini
does not match the syntax for shortcuts for running scripts; surely those
should be identical. Sounds like another feature request.
Third: in what world is "Alt + F + S" a familiar keyboard shortcut for
saving a file!?! The only thing I'm aware of that comes even close is "Alt
+ F, S", which simply opens the file menu, and then selects the save
option. Unfortunately, this doesn't seem to work in TeXworks, since it
seems that none of the menus on the menu bar have an accelerator key
defined, so Alt + F fails to open the file menu, and even if it did, "S"
does not activate save. Yet another missing feature.
Finally, I'm no expert in the TeXworks scripting API, and have written
precisely zero working scripts, but this seems to do what you need:
http://twscript.paulanorman.info/docs/html/TexWorksQtScripting.html?save.html
In other words, the script is a one line: TW.target.save();
Disclaimer: I have not tried it. I personally just use Ctrl + S, to save.
(Actually, this is not true. What I actually do is Ctrl + T to typeset,
and rely on the implicit save just before typesetting.)
Hope some of this helps.
If not, ask again.
On Wed, Mar 15, 2017 at 12:28 AM, Z Br <breigzach at gmail.com> wrote:
> Thanks Alain!
>
> Unfortunately I am not much of a programmer and so I am unsure how to
> modify the script you posted to get the action I had asked about. Could you
> give a bit more direction, or if someone else knows if this is possible
> with the short cuts file that would be great too.
>
> ZB
>
> On Tue, Mar 14, 2017 at 1:32 PM, Alain Delmotte <
> alain.delmotte at leliseron.org> wrote:
>
>> Hi,
>>
>> I don't think that it is possible with a shortcut*, but you could have a
>> script to do that, like this one:
>>
>> ================================ chapter.lua
>> --[[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))
>> ============================
>>
>> To create a \chapter{xyz} instruction I type "xyz", select this and type
>> Alt+W& (the key where is "1", but on my belgian keyboard it has & as lower
>> case). If I selct nothing I just have \chapter{}.
>>
>> You have to put the script file in the scripts folder.
>>
>> Regards,
>>
>> Alain
>> * to be confirmed by the specialists
>>
>>
>> Le 14/03/2017 à 14:15, Z Br a écrit :
>>
>> Hi:
>>
>> I am using a shortcuts.ini file to create some custom shortcuts. I would
>> like to have shortcuts which involve multiple letters, e.g. the familiar
>> Alt+F+S to save the file. But when I include lines like this in
>> shortcuts.ini,
>> actionSave = Alt+F+S
>> they do not work (literally nothing happens). Shortcuts with just one
>> letter like
>> actionSave = Alt+S
>> do work.
>>
>> Is there a way to create shortcuts with multiple letters?
>>
>> Regards,
>> Zach
>>
>>
>> My setup:
>> Win7 Enterprise x64
>> TexWorks 0.6.1
>>
>>
>>
>>
>> ------------------------------
>> [image: Avast logo] <https://www.avast.com/antivirus>
>>
>> L'absence de virus dans ce courrier électronique a été vérifiée par le
>> logiciel antivirus Avast.
>> www.avast.com <https://www.avast.com/antivirus>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texworks/attachments/20170315/3b8bfba3/attachment.html>
More information about the texworks
mailing list