split/Tioga/lib/irb_tioga.rb in tioga-1.4 vs split/Tioga/lib/irb_tioga.rb in tioga-1.5
- old
+ new
@@ -3,13 +3,21 @@
module Tioga
module IRB_Tioga
$tioga_figure_filename = nil
$tioga_figure_num = nil
+
+
+def check_have_loaded
+ return true unless ($tioga_figure_filename == nil) || ($tioga_figure_filename.length == 0)
+ puts "Must open a file first."
+ return false
+end
def o(filename=nil)
filename = $tioga_figure_filename if filename == nil
+ return if filename == nil || filename.length == 0 # this happens if just give shell command irb_tioga with no filename
filename = $tioga_ui.fix_filename(filename)
result = $tioga_ui.setdir_and_load(filename)
return false if result == nil
$tioga_figure_filename = result
$tioga_figure_num = 0
@@ -20,36 +28,41 @@
if fignums.kind_of?String
fignums = $tioga_ui.parse_figs(fignums)
end
if fignums == nil
$tioga_ui.make_all_pdfs(view)
- elsif fignums.kind_of?Integer
- fignums += FigureMaker.default.num_figures if fignums < 0
- $tioga_ui.do_fignums([fignums],view)
+ set_figure_num(0)
else
+ if fignums.kind_of?Integer
+ fignums += FigureMaker.default.num_figures if fignums < 0
+ fignums = [fignums]
+ end
$tioga_ui.do_fignums(fignums,view)
+ set_figure_num(fignums[-1])
end
- set_figure_num(fignums[-1]) unless fignums == nil
return true
end
def s(fignums=nil)
+ return unless check_have_loaded
do_figs(fignums,true)
return true
end
def m(fignums=nil)
+ return unless check_have_loaded
do_figs(fignums,false)
return true
end
def set_figure_num(num)
num = FigureMaker.default.figure_names.index(num) unless num == nil || num.kind_of?(Integer)
$tioga_figure_num = num
end
def p(fignums=nil)
+ return unless check_have_loaded
if fignums.kind_of?String
fignums = $tioga_ui.parse_figs(fignums)
end
if fignums == nil
$tioga_ui.make_portfolio(true)
@@ -62,10 +75,11 @@
set_figure_num(fignums[-1]) unless fignums == nil
return true
end
def r
+ return unless check_have_loaded
if $tioga_figure_num != nil
figname = FigureMaker.default.figure_names[$tioga_figure_num]
else
figname = nil
end
@@ -77,24 +91,35 @@
end
end
end
+def cmds
+ l
+end
+
+
+def list_cmds
+ l
+end
+
+
def l
$tioga_ui.list_figures
return true
end
def h
puts ''
puts " Command description"
- puts " o 'filename' open tioga file (with extension .rb)."
- puts " l output a list of the defined figures by number and name."
- puts " m <figs> make PDFs without showing them in the viewer."
- puts " s <figs> make and show PDFs, each in a separate viewer window."
- puts " p <figs> make PDFs and show the portfolio as a multi-page document."
- puts " r reloads the current tioga file and reshows the current figure."
- puts " h helpfully print this list of commands."
+ puts " o 'filename' opens the named tioga file (with extension .rb)."
+ puts " o opens the current tioga file (i.e., reload)."
+ puts " l lists the defined figures by number and name."
+ puts " m <figs> makes PDFs without showing them in the viewer."
+ puts " s <figs> makes and shows PDFs, each in a separate viewer window."
+ puts " p <figs> makes PDFs and shows the portfolio as a multi-page document."
+ puts " r reloads the current file and reshows the current figure."
+ puts " h helpfully prints this list of commands."
puts "\n Since the filename extension is known, you can skip typing it if you like."
puts "\n If <figs> is omitted, then tioga does all the figures defined in the file"
puts " ordered by their definition index numbers."
puts "\n Otherwise, <figs> must be either"
puts " a valid ruby array index number for a figure (can be negative), or"