processor/command/display.rb in trepanning-0.1.3 vs processor/command/display.rb in trepanning-0.1.4

- old
+ new

@@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net> -require_relative 'base/cmd' +require_relative '../command' class Trepan::Command::DisplayCommand < Trepan::Command - + unless defined?(HELP) NAME = File.basename(__FILE__, '.rb') HELP = <<-HELP #{name} [format] EXP @@ -20,43 +20,50 @@ case or not. With no argument, evaluate and display all currently requested auto-display expressions. Use "undisplay" to cancel display requests previously made. + +See also "undisplay", "enable", and "disable". HELP - CATEGORY = 'data' - NEED_STACK = false - SHORT_HELP = 'Display expressions when entering debugger' - end - - def run(args) + CATEGORY = 'data' + NEED_STACK = false + SHORT_HELP = 'Display expressions when entering debugger' +end - if args.size == 1 - # Display anything active - @proc.run_eval_display - else - if %w(/c /x /o /f /s).member?(args[1]) - if 2 == args.size - errmsg("Expecting an expression after the format") - return - end - format = args[1] - expr = args[2..-1].join(' ') - else - format = nil - expr = args[1..-1].join(' ') - end +#def save_command +# val = settings[subcmd_setting_key] ? 'on' : 'off' +# ["#{subcmd_prefix_string} #{val}"] +#end - dp = @proc.displays.add(@proc.frame, expr, format) - unless dp - errmsg('Error evaluating "%s" in the current frame' % expr) +def run(args) + + if args.size == 1 + # Display anything active + @proc.run_eval_display + else + if %w(/c /x /o /f /s).member?(args[1]) + if 2 == args.size + errmsg("Expecting an expression after the format") return end - msg(dp.to_s(@proc.frame)) - @proc.cmdloop_prehooks.insert_if_new(5, *@proc.display_hook) + format = args[1] + expr = args[2..-1].join(' ') + else + format = nil + expr = args[1..-1].join(' ') end + + dp = @proc.displays.add(@proc.frame, expr, format) + unless dp + errmsg('Error evaluating "%s" in the current frame' % expr) + return + end + msg(dp.to_s(@proc.frame)) + @proc.cmdloop_prehooks.insert_if_new(5, *@proc.display_hook) end +end end if __FILE__ == $0 # Demo it. require 'thread_frame'