Sha256: 5c4ed2156339845941750d9ed9b2ec90f64a27ab185914a54b4bb01f2f91389f

Contents?: true

Size: 718 Bytes

Versions: 2

Compression:

Stored size: 718 Bytes

Contents

require 'ripl/rc/u'
require 'ripl/rc/multiline' # dependency

module Ripl::Rc::MultilineHistory
  include Ripl::Rc::U

  def loop_eval(input)
    return super if MultilineHistory.disabled?
    result = super # might throw
    unless @rc_multiline_buffer.empty?
      (@rc_multiline_buffer.size + (@rc_multiline_trash || 0)).
        times{ history.pop }
       @rc_multiline_trash = 0
      history << "\n" + @rc_multiline_buffer.join("\n")
    end
    result
  end

  def handle_interrupt
    return super if MultilineHistory.disabled?
    unless @rc_multiline_buffer.empty?
      @rc_multiline_trash ||= 0
      @rc_multiline_trash  += 1
    end
    super
  end
end

Ripl::Shell.include(Ripl::Rc::MultilineHistory)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ripl-rc-0.2.3 lib/ripl/rc/multiline_history.rb
ripl-rc-0.2.2 lib/ripl/rc/multiline_history.rb