bin/shellplay in shellplay-0.0.5 vs bin/shellplay in shellplay-0.0.6

- old
+ new

@@ -14,11 +14,11 @@ @session.import(ARGV[0]) continue = true @sleeptime = 1.0/48.0 @lastelapsed = 0 -@noplayprompt = false +@playprompt = true counter = 1 def usage puts "\nCommands: " puts " h,? show help" @@ -51,21 +51,23 @@ @lastelapsed = screen.timespent else @lastelapsed = 0 end print screen.stdout + @playprompt = screen.playprompt if screen.stderr != "" printf "\n#{Paint[screen.stderr, :red]}" end end def shownext if @session.current_screen and @session.current_screen.stdin display @session.current_screen @session.next else - puts "You are at the end of the session." + print Paint["... ", :cyan] + @playprompt = false @lastelapsed = 0 end end def show(index) @@ -77,12 +79,14 @@ @lastelapsed = 0 end end while continue do - print "\n\e[36m>\e[0m " if @playprompt - print "\e[35melapsed: #{@lastelapsed}s\e[0m " unless @lastelapsed == 0 + if @playprompt + print "\n\e[33m>\e[0m " + printf("\e[33melapsed: \e[0m\e[1;93m#{@session.config.timeformat}s\e[0m ", @lastelapsed) unless @lastelapsed == 0 + end command = STDIN.gets.strip case command when /^(?:q|x)$/ puts "\nPlay ended.\n" continue = false @@ -95,16 +99,16 @@ when /s([0-9]+)/ show($1) when '' shownext else - Open3.popen3("bash","-l","-c",command.strip) do |i, o, e, t| + Open3.popen3(command.strip) do |i, o, e, t| o.read.split("\n").each do |line| print line sleep sleeptime end e.read.split("\n").each do |line| - print Paint[line, :red] + print Paint[line, :red, :bold] end end end end