FLASHMODE

CLAUS GERHARDT

Date: September 17, 2008.

Contents

Contents
 1.  Introduction
 2.  Flashmode’s structure
 3.  Installation
 4.  Running Flashmode
 5.  Root files
 6.  Local Switcher
 7.  Calling scripts via menus
 8.  Calling Flashmode from within TeXShop
 9.  Test files
 10.  Flashmode with arbitrary editors and previewers
 11.  System requirements
 12.  History
 13.  Download Links
 14.  Links

1. Introduction

Flashmode enables simultaneous typesetting as Textures did. When Flashmode, or more precisely one of its applets, is started, it looks for the front most document in TeXShop, gets its path and after that it is hooked forever to this document as long as it stays open, i.e., a few split seconds after Flashmode has started the front most document in the TeXShop could be anything without doing any harm.

Then Flashmode checks in regular intervals (default is 0.001 sec), the length of which is user definable—0.001 sec are recommended for the 8-core Mac Pros—, if its tex document has been modified, and if so, it initiates a save, a pdflatex run, and asks TeXShop to refresh the corresponding pdf file. Flashmode can be invoked even if a document isn’t typeset yet, but beware that its first action will be a typesetting command.

An important feature is that tex syntax errors don’t cause any error messages or disruptions of any kind, i.e., the pdf gets never corrupted, at least the pdf viewer is never aware of it, and the last refreshment is always visible; the pdf viewer will never complain.

Thus, the user never gets any error messages; the presence of errors can only be deduced from the pdf window which then doesn’t change any more; of course the errors will be reported in the log file and can be looked up.

When the tex document is unmodified, Flashmode stays put in the background with very little CPU load: on my machine the idle Flashmode has less than 1%, i.e., Flashmode can stay open as long as one wishes without any bad side effects.

While Flashmode is active, the source document can be typeset independently by TeXShop or by other scripts or commands, especially other tex tools like bibtex can be run without any interference by Flashmode.

2. Flashmode’s structure

Flashmode uses small applications, referred to as applets, for its work. There are two sets of applets, where the members of each set use a specific shell script for typesetting. The applets in the first and largest set are called Flashmode-ts-i, 1 i 10, and the corresponding shell script is flashmode-ts-1 which calls pdflatex (this is its default definition). The members of the second set are called Flashmode-ts-alt-i, 1 i 3, with corresponding shell script flashmode-ts-alt-1, which is calling altpdflatex (its default definition).

The applets are started by pressing the corresponding buttons in the window „Flashmode Scripts“ of the application Flashmode, namely, run Flashmode for starting any of the ten applets of Flashmode-ts, run Flashmode-alt for the three applets of the set Flashmode-ts-alt, and finally quit Flashmode to quit any of the applets.

Notice that each applet controls exactly one document and the applet that controls the document filename.tex will be quit by pressing the button quit Flashmode while filename.tex is the front most document in TeXShop.

The buttons in the window „Flashmode Scripts“ are grouped into five sets and their meaning should be self-explanatory. The maintenance scripts are used to clear Flashmode’s bookkeeping files when necessary: Whenever an applet is started it will report that it is in use by placing a corresponding notice in the Activity folder and the document that will be controlled will be marked as such by creating a so-called protocol file filename.flashmode. When an applet is orderly quit by pressing the corresponding button, these files will be deleted. However, in case of a snafu the files might be still present with the effect that either an applet is falsely reported to be active or that a document is falsely supposed to be already controlled by Flashmode, i.e., its .flashmode file still exists. In this case no Flashmode applet can be started to control it and a beep will be heard when trying it. The maintenance scripts will take care of these irregularities.

There are three smaller windows containing buttons to run Applescripts which are all non-Flashmode related and it should be evident what these scripts are used for.

3. Installation

The Flashmode dmg contains three folders Flashmode-Leopard, Flashmode-Tiger and Local-Switcher. Place the application Flashmode that corresponds to your OS in the Applications folder

/Applications

and Local-Switcher too.

Wbhoelinc lFinlkashFmloadsehmisodseta“rtiend ~ f/oLri tbhrea firrys/t ttiom ae,f iotld weirllnpalamceed aFslyasmh--
mode tha”t resides inside Flashmode ’s bundle. Double clicking on
that symbolic link will open the folder, and you can inspect or
alter its contents.

The folder Flashmode contains the shell scripts (in the bin folder), subroutines for the Applescripts, Flashmode’s Preferences, a folder Applescripts-modular containing subroutines, some of which can be modified to your specific needs, and a folder texmf containing some style files for makeindex and for tex4ht. These folders makeindex and tex4ht should be put into your personal texmf folder, if you have already one, otherwise place the whole texmf folder into ~/Library/ to be your personal texmf folder.

Local-Switcher is used for placing a local symlink to the tex source of your choice. If it is missing download the latest from Local Switcher.

To use the shell scripts provided by Flashmode a local symlink to
thheelpteoxf s tohuer acpep hlaicsattoionbeLopclaacle Sdwiintcyhoeur,rcfh.o Smeectdioirnec6to.ry with the

4. Running Flashmode

Notice that it is no longer necessary to enter your serial number to run Flashmode.

Install the icon of Flashmode into the dock. When Flashmode is started one window will appear, Flashmode Scripts, which is used to control the applets. I usually place it in the lower right corner of my screen such that it is slightly visible when working in TeXShop.

Then adjust TeXShop for using it with Flashmode. Open an already typeset document so that both the preview window as well as the source window are present. Your screen should be large enough that both windows can be placed side by side. If you are pleased with the arrangement, open TeXShop’s preferences and check under Document the button „All windows start at fixed position“ and then press „Set with current position“ , same under Preview, uncheck the „Automatic Preview Update“ , set „Default Page Style“ to „Multi-Page“ .

If you set the local symlink, then define under Engine the tex path to

/Users/yourName/texprograms

where „yourName“ is the short version of your account’s user name. This setting is not necessary to run Flashmode, but if you do, TeXShop will use the same tex source as Flashmode.

Under Misc define the „Sync Method“ you would want to use. If you use TeXShop version 2.18 or better, then I recommend „Synctex“ . This setting requires that the preamble of your tex file contains the command

\synctex=1

I didn’t notice any slowdown because of the additional creation of a of .synctex.gz file with each typesetting on an 8-core Mac Pro. This might be different for a less powerful Macintosh.

Flashmode can only be used when the document has already been saved once, i.e., it should have a name. When the tex document is opened and front most in TeXShop and you would like it to be controlled by Flashmode, e.g., by any member of the first set of applets, press the button „run Flashmode“. An applet, most likely Flashmode-ts-1, will start and take control of the front document, i.e., it will check periodically, default is 0.001 seconds, if the document has been modified, and if so it will issue a typesetting command.

TFhlaussh,m tohdee dwoocunme’tntdestehcotu alndy nmevoedrifibcea staiovnesd! manually, since then

On an 8-core Mac Pro the typed text will be instantaneously shown in the preview window in case of a 50 pages document, if the time interval is set to 0.001 seconds. Even for a 300 pages book the delay will be only 2-3 seconds.

Since Flashmode will never complain or show an error message, your only way of spotting a problem is by watching the preview window which won’t change anymore when the source file has been modified in such a case.

Then you can open the log, or even better, press the button „pdflatexc“ , then the cause of the error will be shown in your source file. Anyway, the error shouldn’t be too far from the present position of the cursor.

Notice that up to ten documents can be simultaneously controlled by Flashmode and three additionally by the applets from „Flashmode-alt“.

When a document should be released from Flashmode’s control, make it front most in TeXShop and press the button „quit Flashmode“, then the corresponding applet will quit.

The provided shell scripts require first line parsing for documents
uosfin tghep cdoflraretsexp,onpddiftnegx s,o cuorncteex fitl,e xse slhaoteuxld olro xoekt leikxe i.e., the first line

%&pdflatex  
%&cont-en  
%&pdftex  
%&xelatex  
%&xetex

if you want the document to be typeset in pdflatex, context, plain tex, xelatex or xetex.

Only if you want to use the routine „dvi -> ps -> pdf“ , i.e., typesetting with simpdftex, then no special first line is required, in fact it is not allowed, except when using the Applescript „simpdftex complete“ which ignores the first line.

5. Root files

When writing a book in LATEX one usually has a root file and the chapters are loaded through the „include“ command. In this situation the chapters are the target files for Flashmode though the typesetting’s target has to be the root file. A smooth interaction can be accomplished by inserting

%SourceDoc rootName.tex

in one of the first three lines of you chapter file, where „rootname“ is the name of your root file, and in the present situation it is assumed that the chapter file and the root file are in the same directory. If this is not the case, then the relative path to the root file has to be given like e.g.,

%SourceDoc ./rootName.tex

TceaXnS ehiothperusbees auseddiffceorenncturprehnrtalyseotroyinodui ccaantettehlle TeroXoSthofiple wthoi ucshe
its old settings by issuing the command in the terminal
defaults write TeXShop UseOldHeadingCommands YES

6. Local Switcher

Use Local Switcher to set a local symlink to the tex source. Such a symlink is necessary, if you are using the provided shell scripts unmodified, since the path of these shell scripts is set to

set path= ( $home/texprograms /usr/local/bin /usr/bin /bin /sbin /usr/sbin )

Local Switcher has its own detailed instructions available under the help menu.

7. Calling scripts via menus

Additional scripts can be triggered from the menus „Bibdesk, Makeindex, Metapost, Htlatex, Xelatex, Scripts and Templates“ . Most of these Applescripts are stored as subroutines in

~/Library/Flashmode/Applescripts-modular

and thus can be modified by the user.

In the Scripts menu are also three triggers „user1, user2, user3“ for not yet defined scripts that can be supplied by the user.

Some scripts can be triggered by a keystroke when Flashmode is the front application.

The scripts „mathmacros.sty“ resp. „mathmacrosB.sty“ in the „Templates“ menu open my personal .sty files in BBEdit by calling corresponding subroutines in

~/Library/Flashmode/Applescripts-modular

If you want to use these commands for your personal files, you have to change the file paths in the subroutines and, if necessary, to replace „BBEdit“ by „TeXShop“ or any other editor of your choice. Similar arguments apply to the scripts „PaperTemplate“, „LetterTemplate“, „LetterTemplate Private“ and „LetterTemplate Special“ .

If you don’t know what a script does, open the script in Script Editor and read the short explanation.

8. Calling Flashmode from within TeXShop

Flashmode commands can be triggered by TeXShop macros. In

~/Library/Flashmode/Example\ Script

is the script „Flashmode-meta“ which triggers the button „run Flashmode“ . The script can be saved as a macro in TeXShop to be called with a keystroke. That particular script can be easily modified to call other buttons, e.g., „quit Flashmode“ .

9. Test files

In the folder

~/Library/Flashmode/Test-files

are minimal test files for articles or books that should run with Flashmode and a useful template for using metapost via the package mfpic. If they aren’t typeset by Flashmode then there is probably something wrong with your set up.

10. Flashmode with arbitrary editors and previewers

There is a version of Flashmode for arbitrary editors and previewers where the name of the editor has to be specified in

~/Library/Flashmode/Preferences

and the name of the previewer in

~/Library/Flashmode/Applesripts-modular/refreshpdfbackground

The editors and previewers have to understand a few basic Applescript commands that are implemented in TeXShop.

First the requirements for the editors:

get path of document of window 1

The result should be the unix path to the front document.

save document docName

where docName is the displayed name of the file in the Finder and most likely the name of the window which displays the corresponding document, e.g., Flashmode-ReadMe.tex, if the Finder shows the suffixes, or else Flashmode-ReadMe.

tell application editorName  
if document docName is modified then  
save document docName  
end if  
end tell

Most likely any scriptable editor will understand this command.

Secondly the requirement for the previewers:

They should understand the command

tell document docName of application previewerName  
refreshpdfbackground  
end tell

where „refreshpdfbackground“ means that the pdf window is silently refreshed without activating the application or the window.

Beware that presently only „TeXShop“ understands these commands, even „BBEdit“ doesn’t understand all commands for the editors.

To make the editor and previewer of your choice work with that particular version of Flashmode you have to ask the corresponding authors to implement these commands.

Notice that the additional Applescripts in Flashmode—apart from the maintenance scripts—only work with TexShop. Similar restrictions apply to the 3 applets Flashmode-alt.

11. System requirements

Starting with version 5.0 Flashmode requires OS 10.5 or better, and a fast intelMac; a large screen is recommended.

The old version 4.2 that also runs on PowerPCs is still available TEXHelpers-old

12. History

  1. Version 5.2: A 64 bit version has been added.
  2. Version 5.1: The window Flashmode Scripts has been redesigned and made smaller.
  3. Version 5.0: Flashmode and the applets are compiled for the Intel architecture only.
  4. Version 4.2: The code for the applets has been improved such that TeXShop’s editor window is more responsive under heavy load.
  5. Version 4.1: The folder „Flashmode“ is now also part of the application’s bundle, i.e., installing Flashmode now simply means dragging Flashmode to the Applications folder.
  6. Version 4.0: The applets are now applications running more smoothly and efficiently. Their cpu load is only a fraction of what it used to be. This upgrade is a major improvement.
  7. Version 3.5: The former folder „Flashmode-TS“ is now contained in the Flashmode bundle. Flashmode’s Preferences can be accessed from Flashmode’s Preferences in the main menu. All applets automatically stay in the background when started.
  8. Version 3.4: Flashmode has been optimized for OS 10.5 and the main applets accept any admissible first line; their number has been increased to 10.
  9. Version 3.3: Hasn’t been distributed.
  10. Version 3.2: Flashmode now offers only one window. There are additional menus containing triggers for scripts.
  11. Version 3.1: A Scripts Menu has been added and first line parsing has been enabled except for simpdftex, see the end of Section 4.
  12. Version 3.0: Flashmode now only works with TeXShop. Its layout has been remodelled, the shell scripts now work universally on an intelMac as well as on a PowerPC provided that a local symlink to the tex source has been defined by Local Switcher.

    A previous bug in the Flashmode-ts-alt applets has been corrected.

13. Download Links

Flashmode is part of the bundle TEXHelpers containing in addition the applications „Local Switcher“, „pdfselect“ and „MathFormulas“.

There is also a Flashmode version for BBEdit as editor and TeXShop as previewer TEXHelpers-BBEdit.

Here is the Flashmode version for arbitrary editors and previewers TEXHelpers-Any.

14. Links

Home page, TEXHelpers, TEX Switcher, pdfselect, TEX Scripts, Books, Preprints, Former Students, Veranstaltungen, Lecture Notes

Ruprecht-Karls-Universität, Institut für Angewandte Mathematik, Im Neuenheimer Feld 294, 69120 Heidelberg, Germany

URL: http://www.math.uni-heidelberg.de/studinfo/gerhardt/