[texworks] Accelerators and shortcuts

Alain Delmotte esperanto at swing.be
Sat May 11 09:32:42 CEST 2013


Hello everybody,

Following the old discussion (back in 04/2010) and the query 
of Alexander Pruss I had a new look to the problem (and a 
discussion with Stefan).
So here is the result of my big thinking.

You have four ways to speed the use of TeXworks from the 
keyboard.

1) Accelerators
This works on Windows, I don't know on the other systems.
This is what Alexander asked.
It can be implemented in the language localisation file 
(TeXworks_XX.qm, where XX is two letters for the language, 
ex. TeXworks_fr.qm for French), which should go to the 
resources folder: (under Windows generally) 
c:\users\<your_name>\TeXworks\translations
It is sufficient to add "&" just before the letter which 
should serve as accelerator. One has to take care avoiding 
using the same letter in one menu and avoiding the same in 
dialogue boxes with several
I did prepare the files for English and French, attached!

2) Auto-completion (works on all systems)
See the manual for the details of use.
You can create your own root for completion, put them in a 
text file in the "completion" folder of the resources folder 
of TeXworks. The name of the file should be tw-something.txt.
I did create one (tw-perso.txt, not shown complete) with:
------------------
%%!TEX encoding = UTF-8 Unicode
bvv:=\begin{Verbatim}#RET##INS#\end{Verbatim}#RET#•
vsp:=\vspace{#INS#}#RET#•
éé:=É
èè:=È
àà:=À
µ:=~
inde:=\index{#INS#}#RET#•
indea:=\index{#INS#|textbf}#RET#•
indeb:=\index{#INS#@•}#RET#•
bsui:=\begin{suite}#RET#\item #INS##RET#\end{suite}•
figh:=\hfill\setlength{\unitlength}{1mm}#RET#\begin{picture}(0,0)\footnotesize%#RET#\put(20,0){\includegraphics[scale=0.#INS#]{illustrations/illus•}}#RET#\put(•,•){•}#RET#\end{picture}%#RET#\setlength{\unitlength}{1pt}
figp:=\parpic[r]{\includegraphics[scale=0.#INS#]{illustrations/illus•}}
bu:=•
-----------------
for my personal use.
the éé, èè, àà and µ is because Qt doesn't work well with 
the French keyboard and the dead keys for ´`~ (the accents 
on capitals).

3) Scripts (work on all systems)
You can add accelerators and shortcuts to your scripts. For 
example I have a script a-emph.lua to get \emph{selected text}:
-----------------
--[[TeXworksScript
Title: a: accentué \&emph
Shortcut: Alt+E
Description: Encloses the current selection in \emph{}
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("\\emph{" .. txt .. "}")
TW.target.selectRange(TW.target.selectionStart - 
string.len(txt) - 1, string.len(txt))
-----------------
On line 2 you see the & before emph to have the letter "e" 
as accelerator and on line 3 you have the definition of the 
shortcut.
Again avoid conflicts with other existing or personal 
shortcut and accelerator.
NB. On line 2 the title starts with "a: ", this allow to 
have the scripts sorted in the Scripts menu, first on a: 
(b:,...) to group them according to types of actions.

4) Shortcut definitions (work on all systems)
In the manual (section A.2) there is a long explanation 
about shortcut, including lists of possible actions.
All the shortcuts can be redefined either to create new 
shortcuts or to modify the existing ones to match personal 
uses or change shortcuts not adapted to one particular 
keyboard layout. You can find the list of possible actions 
to associate with shortcuts in the attached file (from 2009 
- Stefan: are there new actions?).
To define your own shortcuts, put a file named shortcuts.ini 
in the <resources>/configuration folder, next to 
auto-indent-patterns.txt, delimiter-pairs.txt, …, 
texworks-config.txt.
For example, this file could contain:
-----------------
   actionHard_Wrap = Shift+F3
   actionLast_Page = Ctrl+End
   actionFirst_Page = Ctrl+Home
   actionWrap_Lines = F3
   actionLine_Numbers = F4
   actionBalance_Delimiters = F9
-----------------
Your definition redefine the build-in one.

Read the manual, you will find a lot of informations to make 
your work automatic, except thinking!!!

Regards,

Alain

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TeXworks_en.qm
Type: application/octet-stream
Size: 31540 bytes
Desc: not available
URL: <http://tug.org/pipermail/texworks/attachments/20130511/e7db3791/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TeXworks_fr.qm
Type: application/octet-stream
Size: 60600 bytes
Desc: not available
URL: <http://tug.org/pipermail/texworks/attachments/20130511/e7db3791/attachment-0003.obj>
-------------- next part --------------
actionAbout_TW
actionActual_Size
actionAutoIndent_None
actionBalance_Delimiters
actionClear
actionClose
actionComment
actionCopy
actionCopy_to_Find
actionCopy_to_Replace
actionCut
actionFind
actionFind_Again
actionFind_Selection
actionFirst_Page
actionFit_to_Width
actionFit_to_Window
actionFont
actionFull_Screen
actionGoToHomePage
actionGo_to_Line
actionGo_to_Page
actionGo_to_Preview
actionGo_to_Source
actionIndent
actionLast_Page
actionMagnify
actionNew
actionNew_from_Template
actionNext_Page
actionNone
actionOpen
actionPaste
actionPlace_on_Left
actionPlace_on_Right
actionPreferences
actionPrevious_Page
actionQuit_TeXworks
actionRedo
actionRemove_Aux_Files
actionReplace
actionReplace_Again
actionRevert_to_Saved
actionSave
actionSave_As
actionScroll
actionSelect_All
actionShow_Hide_Console
actionShow_Selection
actionSide_by_Side
actionSmartQuotes_None
actionStack
actionSyntaxColoring_None
actionTile
actionTo_Lowercase
actionTo_Uppercase
actionTypeset
actionUncomment
actionUndo
actionUnindent
actionWrap_Lines
actionWriteToMailingList
actionZoom_In
actionZoom_Out


More information about the texworks mailing list