Skip to Content Skip to Search
Methods
C
E
I
L
U

Constants

CursorPos = Struct.new(:x, :y)
 
DEFAULT_DIALOG_CONTEXT = Array.new
 
DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() { # autocomplete return unless config.autocompletion journey_data = completion_journey_data return unless journey_data target = journey_data.list.first completed = journey_data.list[journey_data.pointer] result = journey_data.list.drop(1) pointer = journey_data.pointer - 1 return if completed.empty? || (result == [completed] && pointer < 0) target_width = Reline::Unicode.calculate_width(target) completed_width = Reline::Unicode.calculate_width(completed) if cursor_pos.x <= completed_width - target_width # When target is rendered on the line above cursor position x = screen_width - completed_width y = -1 else x = [cursor_pos.x - completed_width, 0].max y = 0 end cursor_pos_to_render = Reline::CursorPos.new(x, y) if context and context.is_a?(Array) context.clear context.push(cursor_pos_to_render, result, pointer, dialog) end dialog.pointer = pointer DialogRenderInfo.new( pos: cursor_pos_to_render, contents: result, scrollbar: true, height: [15, preferred_dialog_height].min, face: :completion_dialog ) }
 
DialogRenderInfo = Struct.new( :pos, :contents, :face, :bg_color, # For the time being, this line should stay here for the compatibility with IRB. :width, :height, :scrollbar, keyword_init: true )
 
FILENAME_COMPLETION_PROC = nil
 

NOTE: For making compatible with the rb-readline gem

HISTORY = Reline::History.new(Reline.core.config)
 
IOGate = if tty require 'reline/ansi' Reline::ANSI else io end
 
Key = Struct.new(:char, :combined_char, :with_meta) do def match?(other) case other when Reline::Key (other.char.nil? or char.nil? or char == other.char) and (other.combined_char.nil? or combined_char.nil? or combined_char == other.combined_char) and (other.with_meta.nil? or with_meta.nil? or with_meta == other.with_meta) when Integer, Symbol (combined_char and combined_char == other) or (combined_char.nil? and char and char == other) else false end end alias_method :==, :match? end
 
USERNAME_COMPLETION_PROC = nil
 
VERSION = '0.5.7'
 

Class Public methods

core()

# File ruby/lib/reline.rb, line 547
def self.core
  @core ||= Core.new { |core|
    core.config = Reline::Config.new
    core.key_stroke = Reline::KeyStroke.new(core.config)
    core.line_editor = Reline::LineEditor.new(core.config, core.encoding)

    core.basic_word_break_characters = " \t\n`><=;|&{("
    core.completer_word_break_characters = " \t\n`><=;|&{("
    core.basic_quote_characters = '"\''
    core.completer_quote_characters = '"\''
    core.filename_quote_characters = ""
    core.special_prefixes = ""
    core.add_dialog_proc(:autocomplete, Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE, Reline::DEFAULT_DIALOG_CONTEXT)
  }
end

encoding_system_needs()

# File ruby/lib/reline.rb, line 543
def self.encoding_system_needs
  self.core.encoding
end

insert_text(*args, &block)

# File ruby/lib/reline.rb, line 524
def self.insert_text(*args, &block)
  line_editor.insert_text(*args, &block)
  self
end

line_editor()

# File ruby/lib/reline.rb, line 567
def self.line_editor
  core.line_editor
end

ungetc(c)

# File ruby/lib/reline.rb, line 563
def self.ungetc(c)
  core.io_gate.ungetc(c)
end

update_iogate()

# File ruby/lib/reline.rb, line 571
def self.update_iogate
  return if core.config.test_mode

  # Need to change IOGate when `$stdout.tty?` change from false to true by `$stdout.reopen`
  # Example: rails/spring boot the application in non-tty, then run console in tty.
  if ENV['TERM'] != 'dumb' && core.io_gate == Reline::GeneralIO && $stdout.tty?
    require 'reline/ansi'
    remove_const(:IOGate)
    const_set(:IOGate, Reline::ANSI)
  end
end