02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3<br />

Launcher<br />

#<br />

# ERRORS: N/A<br />

#<br />

proc launchFileOpen {} {<br />

set result [noticePost fileselect "Open file" Open "*"]<br />

if {$result != ""} {<br />

launchEdit $result<br />

}<br />

}<br />

3<br />

#############################################################################<br />

#<br />

#<br />

# launchEdit - run system editor on specified file<br />

#<br />

# This routine runs the system editor (as specified in the environment<br />

# variable EDITOR, or vi if EDITOR is undefined) on the file specified<br />

# in its argument.<br />

#<br />

# SYNOPSIS:<br />

# launchEdit fname<br />

#<br />

# PARAMETERS:<br />

# fname: the name of a file to edit<br />

#<br />

# RETURNS: N/A<br />

#<br />

# ERRORS: N/A<br />

#<br />

proc launchEdit {fname} {<br />

# we need to examine environment variables<br />

global env<br />

if { ([file readable $fname] && ![file isdirectory $fname]) ||<br />

([file writable [file dirname $fname]] && ![file exists $fname])<br />

} then {<br />

# We have an editable file<br />

# Use the EDITOR environment variable, with vi default<br />

if [info exists env(EDITOR)] {<br />

set editor $env(EDITOR)<br />

} else {<br />

set editor vi<br />

}<br />

if [string match "emacsc*" $editor] {<br />

# looks like emacsclient. Don't run an xterm; just put this<br />

# in the background.<br />

89

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!