123456789_123456789_123456789_123456789_123456789_

Class: Reline::LineEditor::Dialog

Relationships & Source Files
Inherits: Object
Defined in: lib/reline/line_editor.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, config, proc_scope) ⇒ Dialog

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 640

def initialize(name, config, proc_scope)
  @name = name
  @config = config
  @proc_scope = proc_scope
  @width = nil
  @scroll_top = 0
  @trap_key = nil
end

Instance Attribute Details

#column (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 638

attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key

#contents (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 637

attr_reader :name, :contents, :width

#contents=(contents) (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 657

def contents=(contents)
  @contents = contents
  if contents and @width.nil?
    @width = contents.map{ |line| Reline::Unicode.calculate_width(line, true) }.max
  end
end

#name (readonly)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 637

attr_reader :name, :contents, :width

#pointer (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 638

attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key

#scroll_top (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 638

attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key

#trap_key (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 638

attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key

#vertical_offset (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 638

attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key

#width (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 637

attr_reader :name, :contents, :width

#width=(v) (rw)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 653

def width=(v)
  @width = v
end

Instance Method Details

#call(key)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 664

def call(key)
  @proc_scope.set_dialog(self)
  @proc_scope.set_key(key)
  dialog_render_info = @proc_scope.call
  if @trap_key
    if @trap_key.any?{ |i| i.is_a?(Array) } # multiple trap
      @trap_key.each do |t|
        @config.add_oneshot_key_binding(t, @name)
      end
    else
      @config.add_oneshot_key_binding(@trap_key, @name)
    end
  end
  dialog_render_info
end

#set_cursor_pos(col, row)

[ GitHub ]

  
# File 'lib/reline/line_editor.rb', line 649

def set_cursor_pos(col, row)
  @proc_scope.set_cursor_pos(col, row)
end