Class: Reline::LineEditor::Dialog

Inherits:
Object
  • Object
show all
Defined in:
lib/reline/line_editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config, proc_scope) ⇒ Dialog

Returns a new instance of Dialog.



656
657
658
659
660
661
662
663
# File 'lib/reline/line_editor.rb', line 656

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

#columnObject

Returns the value of attribute column.



654
655
656
# File 'lib/reline/line_editor.rb', line 654

def column
  @column
end

#contentsObject

Returns the value of attribute contents.



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

def contents
  @contents
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pointerObject

Returns the value of attribute pointer.



654
655
656
# File 'lib/reline/line_editor.rb', line 654

def pointer
  @pointer
end

#scroll_topObject

Returns the value of attribute scroll_top.



654
655
656
# File 'lib/reline/line_editor.rb', line 654

def scroll_top
  @scroll_top
end

#trap_keyObject

Returns the value of attribute trap_key.



654
655
656
# File 'lib/reline/line_editor.rb', line 654

def trap_key
  @trap_key
end

#vertical_offsetObject

Returns the value of attribute vertical_offset.



654
655
656
# File 'lib/reline/line_editor.rb', line 654

def vertical_offset
  @vertical_offset
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#call(key) ⇒ Object



680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
# File 'lib/reline/line_editor.rb', line 680

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) ⇒ Object



665
666
667
# File 'lib/reline/line_editor.rb', line 665

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