Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
6ee6a68694 | |||
5b7130c2f9 | |||
fb1a0606fd | |||
174ec96c6d | |||
2c996c7a18 | |||
0fe0a966f0 | |||
240ea58411 |
3 changed files with 22 additions and 17 deletions
39
rubberin
39
rubberin
|
@ -70,10 +70,8 @@ def compile(infile, mode)
|
||||||
params = ARGV.join(" ")
|
params = ARGV.join(" ")
|
||||||
err_file = infile.with_extname("err")
|
err_file = infile.with_extname("err")
|
||||||
|
|
||||||
_ret = system "rubber --inplace #{mode_opt} #{params} #{infile} 2> #{err_file}"
|
system "rubber --inplace #{mode_opt} #{params} #{infile} 2> #{err_file}"
|
||||||
File.open(err_file) { |file| puts file.read }
|
File.open(err_file) { |file| puts file.read }
|
||||||
# Remove the output save file if compile was succesful.
|
|
||||||
# clean(infile) if ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Start the right viewer based on the mode.
|
# Start the right viewer based on the mode.
|
||||||
|
@ -109,7 +107,7 @@ end
|
||||||
|
|
||||||
## Initialisation
|
## Initialisation
|
||||||
PROGRAM = File.basename($PROGRAM_NAME).freeze
|
PROGRAM = File.basename($PROGRAM_NAME).freeze
|
||||||
VERSION = "0.8".freeze
|
VERSION = "0.9".freeze
|
||||||
|
|
||||||
# Parse the command line options.
|
# Parse the command line options.
|
||||||
# Determine the compile mode from the options.
|
# Determine the compile mode from the options.
|
||||||
|
@ -128,8 +126,10 @@ opts.each do |opt, _arg|
|
||||||
when "--ps"
|
when "--ps"
|
||||||
mode = :ps
|
mode = :ps
|
||||||
when "--pdf"
|
when "--pdf"
|
||||||
mode = if mode == :ps then :pspdf
|
mode = if mode == :ps
|
||||||
else :pdf
|
:pspdf
|
||||||
|
else
|
||||||
|
:pdf
|
||||||
end
|
end
|
||||||
when "--version"
|
when "--version"
|
||||||
puts "#{PROGRAM} #{VERSION}"
|
puts "#{PROGRAM} #{VERSION}"
|
||||||
|
@ -172,18 +172,9 @@ viewer_pid =
|
||||||
view(infile, mode)
|
view(infile, mode)
|
||||||
# If xdvi/evince exits, this program should exit too.
|
# If xdvi/evince exits, this program should exit too.
|
||||||
puts "#{PROGRAM}: viewer exited, so will I!"
|
puts "#{PROGRAM}: viewer exited, so will I!"
|
||||||
Process.kill("TERM", pid)
|
Process.kill("HUP", pid)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handle signals.
|
|
||||||
["INT", "TERM", "QUIT"].each do |sig|
|
|
||||||
Signal.trap(sig) do
|
|
||||||
Process.kill(sig, viewer_pid)
|
|
||||||
clean(infile)
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
## Main event loop
|
## Main event loop
|
||||||
|
|
||||||
# Add input file with dependancies to the watch list and start event loop.
|
# Add input file with dependancies to the watch list and start event loop.
|
||||||
|
@ -196,11 +187,25 @@ dirs.each do |dir|
|
||||||
file_path = (dir + ev.name).to_s
|
file_path = (dir + ev.name).to_s
|
||||||
next unless files.include? file_path
|
next unless files.include? file_path
|
||||||
|
|
||||||
puts "I: file #{ev.name} modified, compiling #{infile}..."
|
puts "#{PROGRAM}: file #{ev.name} modified, compiling #{infile}..."
|
||||||
compile(infile, mode)
|
compile(infile, mode)
|
||||||
reload(infile, mode)
|
reload(infile, mode)
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Handle signals during the main event loop.
|
||||||
|
["INT", "TERM", "QUIT"].each do |sig|
|
||||||
|
Signal.trap(sig) do
|
||||||
|
puts "#{PROGRAM}: caught signal #{sig}, stopping the viewer..."
|
||||||
|
Process.kill(sig, viewer_pid)
|
||||||
|
notifier.stop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Signal.trap("HUP") { notifier.stop }
|
||||||
|
|
||||||
|
# Run the main event loop.
|
||||||
notifier.run
|
notifier.run
|
||||||
|
|
||||||
|
# Clean before finishing!
|
||||||
|
clean(infile)
|
||||||
|
|
Loading…
Reference in a new issue