Sha256: 852229e41cbb0113099b3b2772378d238120b41ed396f732284e9b3a7b7c6016

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
# I/O related command processor methods
require_relative '../app/util'
require_relative 'virtual'
class Trepan
  class CmdProcessor < VirtualCmdProcessor

    attr_accessor :ruby_highlighter

    def errmsg(message, opts={})
      message = safe_rep(message) unless opts[:unlimited]
      if @settings[:highlight] && defined?(Term::ANSIColor)
        message = 
          Term::ANSIColor.italic + message + Term::ANSIColor.reset 
      end
      @dbgr.intf[-1].errmsg(message)
    end

    def msg(message, opts={})
      message = safe_rep(message) unless opts[:unlimited]
      @dbgr.intf[-1].msg(message)
    end

    def msg_nocr(message, opts={})
      message = safe_rep(message) unless opts[:unlimited]
      @dbgr.intf[-1].msg_nocr(message)
    end

    def read_command()
      @dbgr.intf[-1].read_command(@prompt)
    end

    def ruby_format(text)
      return text unless settings[:highlight]
      unless @ruby_highlighter
        begin
          require 'coderay'
          require 'term/ansicolor'
          @ruby_highlighter = CodeRay::Duo[:ruby, :term]
        rescue LoadError
          return text
        end
      end
      return @ruby_highlighter.encode(text)
    end

    def safe_rep(str)
      Util::safe_repr(str, @settings[:maxstring])
    end

    def section(message, opts={})
      message = safe_rep(message) unless opts[:unlimited]
      if @settings[:highlight] && defined?(Term::ANSIColor)
        message = 
          Term::ANSIColor.bold + message + Term::ANSIColor.reset 
      end
      @dbgr.intf[-1].msg(message)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trepanning-0.1.3 processor/msg.rb