lib/roku_builder/monitor.rb in roku_builder-3.10.7 vs lib/roku_builder/monitor.rb in roku_builder-3.11.0
- old
+ new
@@ -14,10 +14,11 @@
task2: 8091,
task3: 8092,
taskX: 8093,
profiler: 8080,
}
+ @show_prompt = false
end
# Monitor a development log on the Roku device
# @param type [Symbol] The log type to monitor
def monitor(type:)
@@ -39,23 +40,51 @@
connection.waitfor(waitfor) do |txt|
all_text = manage_text(all_text: all_text, txt: txt)
end
end
}
+ # setup readline
+
+ libedit = false
+ begin
+ Readline.vi_editing_mode
+ rescue NotImplementedError
+ libedit = true
+ end
+
+ commands = [
+ "bsc", "bscs", "brkd", "bt", "classes", "cont", "cont", "down", "d",
+ "exit", "gc", "help", "last", "list", "next", "print", "p", "?", "step",
+ "s", "t", "over", "out", "up", "u", "var", "q"
+ ].sort
+ commands.collect { |i| i += ' ' } if libedit
+
+ comp = proc { |s| commands.grep( /^#{Regexp.escape(s)}/ ) }
+
+ Readline.completion_append_character = " "
+ Readline.completion_proc = comp
+
+
running = true
@logger.unknown "Q to exit"
while running
begin
- command = gets.chomp
- case command
- when "q"
- thread.exit
- running = false
- when "stop"
- thread[:connection].puts("\C-c")
+ if @show_prompt
+ command = Readline.readline('BrightScript Debugger> ', true)
+ if command =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == command
+ Readline::HISTORY.pop
+ end
+ case command
+ when "q"
+ thread.exit
+ running = false
+ else
+ @show_prompt = false
+ thread[:connection].puts(command)
+ end
else
- thread[:connection].puts(command)
+ sleep 0.01
end
rescue SystemExit, Interrupt
thread[:connection].puts("\C-c")
end
end
@@ -71,10 +100,10 @@
all_text += txt
while line = all_text.slice!(/^.*\n/) do
puts line if !line.strip.empty?
end
if all_text.downcase == "BrightScript Debugger> ".downcase
- print all_text
+ @show_prompt = true
all_text = ""
end
all_text
end
end