[OS X TeX] Combine Applescripts with scripts from Flashmode-TS
Claus Gerhardt
gerhardt at math.uni-heidelberg.de
Thu Sep 21 01:54:56 CEST 2006
This instruction is posted for future reference.
It is shown how the "refreshtext" script is combined with the
pdflatexc script (button) from Flashmode-TS.
Download Flashmode-downloadable from
http://www.math.uni-heidelberg.de/studinfo/gerhardt/tex
and install Flashmode-TS according to the instructions, i.e., the two
folders have to go inside ~/Library
You can trigger all Applescripts from Flashmode-TS that are not
Flashmode related.
The script below combines "refreshtext" and pdflatexc. Looking at the
structure you can replace pdflatexc by any other button name. Of
course Flashmode-TS should be open; I usually place its main window
in the lower-right corner.
I would recommend either to save the script as an application,
installing its icon in the Dock, as a TS macro, or use Apple's
universal Script menu to call the script from within any application.
Claus
tell application "TeXShop"
get path of document of window 1
set fileName to result
end tell
set {baseName, texName, pdfName, namePath, dirName, dirNameunquoted,
logName, logPath, rtfName, docName} to setnametsn(fileName)
tell document docName of application "TeXShop"
activate
refreshtext
end tell
set x to "pdflatexc" as string --button name
set y to "Flashmode-TS-Scripts" as string --window name
Flashmode(x, y)
on Flashmode(x, y)
tell application "Flashmode-TS-Scripts"
set windowList to title of windows as list
end tell
set n to (number of items of windowList) as number
set i to 1 as number
repeat while i ² n
if item i in windowList is equal to y then
set m to i
exit repeat
else
set i to (i + 1)
end if
end repeat
tell application "Flashmode-TS-Scripts"
tell window m
set buttonList to title of buttons as list
end tell
end tell
set n to (number of items of buttonList) as number
set i to 1 as number
repeat while i ² n
if item i in buttonList is equal to x then
set k to i
exit repeat
else
set i to (i + 1)
end if
end repeat
tell application "Flashmode-TS-Scripts"
tell window m
perform action button k
end tell
end tell
end Flashmode
on setnametsn(x)
set n to (number of characters of contents of x)
set fileNamequoted to quoted form of x
set windowName to do shell script "basename " & fileNamequoted
set m to (number of characters of contents of windowName)
set dirName to quoted form of (characters 1 thru (n - m - 1) of x as
string)
set dirNameunquoted to (characters 1 thru (n - m - 1) of x as string)
set theText to contents of windowName as string
set n to (number of characters of contents of theText)
set i to n as number
repeat while i > 0
if character i of theText is equal to "." then
set m to i
exit repeat
else
set i to (i - 1)
end if
end repeat
set baseName to (characters 1 thru (m - 1) of theText as string)
set texName to baseName & ".tex"
set namePath to dirNameunquoted & "/" & baseName as string
set pdfName to namePath & ".pdf" as string
set rtfName to namePath & ".rtf" as string
set logPath to namePath & ".log" as string
set logName to baseName & ".log" as string
set theFile to POSIX file x as string
tell application "Finder"
get displayed name of the file theFile
end tell
set docName to result
return {baseName, texName, pdfName, namePath, dirName,
dirNameunquoted, logName, logPath, rtfName, docName} as list
end setnametsn
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
More information about the macostex-archives
mailing list