Sha256: a2583cf978993436ba18b7039d3c455039399e9ce193032c9d1149e4b8b05a2a

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

require 'rib/more/multiline' # dependency

module Rib::MultilineHistory
  include Rib::Plugin
  Shell.use(self)

  def loop_eval input
    return super if MultilineHistory.disabled?
    value = super
  rescue Exception
    # might be multiline editing, ignore
    raise
  else
    if multiline_buffer.size > 1
      # so multiline editing is considering done here
      (multiline_buffer.size + (@multiline_trash || 0)).times{ history.pop }
      history << "\n" + multiline_buffer.join("\n")
    end
    value
  end

  def handle_interrupt
    return super if MultilineHistory.disabled?
    if multiline_buffer.size > 1
      @multiline_trash ||= 0
      @multiline_trash  += 1
    end
    super
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rib-0.1.0 lib/rib/more/multiline_history.rb