123456789_123456789_123456789_123456789_123456789_

Module: Reline

Relationships & Source Files
Namespace Children
Modules:
Classes:
Exceptions:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, SingleForwardable, Forwardable
Defined in: lib/reline.rb,
lib/reline/version.rb

Constant Summary

  • DEFAULT_DIALOG_CONTEXT =
    # File 'lib/reline.rb', line 265
    Array.new
  • DEFAULT_DIALOG_PROC_AUTOCOMPLETE =
    # File 'lib/reline.rb', line 218
    ->() {
      # autocomplete
      return nil unless config.autocompletion
      if just_cursor_moving and completion_journey_data.nil?
        # Auto complete starts only when edited
        return nil
      end
      pre, target, post = retrieve_completion_block(true)
      if target.nil? or target.empty? or (completion_journey_data&.pointer == -1 and target.size <= 3)
        return nil
      end
      if completion_journey_data and completion_journey_data.list
        result = completion_journey_data.list.dup
        result.shift
        pointer = completion_journey_data.pointer - 1
      else
        result = call_completion_proc_with_checking_args(pre, target, post)
        pointer = nil
      end
      if result and result.size == 1 and result[0] == target and pointer != 0
        result = nil
      end
      target_width = Reline::Unicode.calculate_width(target)
      x = cursor_pos.x - target_width
      if x < 0
        x = screen_width + x
        y = -1
      else
        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,
        bg_color: 46,
        pointer_bg_color: 45,
        fg_color: 37,
        pointer_fg_color: 37
      )
    }
  • FILENAME_COMPLETION_PROC =
    # File 'lib/reline.rb', line 14
    nil
  • HISTORY =
    # File 'lib/reline.rb', line 600
    Reline::History.new(Reline.core.config)
  • IOGate =
    # File 'lib/reline.rb', line 593
    if tty
      require 'reline/ansi'
      Reline::ANSI
    else
      io
    end
  • USERNAME_COMPLETION_PROC =
    # File 'lib/reline.rb', line 15
    nil
  • VERSION =
    # File 'lib/reline/version.rb', line 2
    '0.3.2'

Class Method Summary

Class Method Details

.core

[ GitHub ]

  
# File 'lib/reline.rb', line 557

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, Reline::IOGate.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

[ GitHub ]

  
# File 'lib/reline.rb', line 553

def self.encoding_system_needs
  self.core.encoding
end

.insert_text(*args, &block)

[ GitHub ]

  
# File 'lib/reline.rb', line 534

def self.insert_text(*args, &block)
  line_editor.insert_text(*args, &block)
  self
end

.line_editor

[ GitHub ]

  
# File 'lib/reline.rb', line 577

def self.line_editor
  core.line_editor
end

.ungetc(c)

[ GitHub ]

  
# File 'lib/reline.rb', line 573

def self.ungetc(c)
  Reline::IOGate.ungetc(c)
end