Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Reline::Core #561

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 14 additions & 18 deletions lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,36 @@ def completion_append_character=(val)
if val.nil?
@completion_append_character = nil
elsif val.size == 1
@completion_append_character = val.encode(Reline::IOGate.encoding)
@completion_append_character = val.encode(encoding)
elsif val.size > 1
@completion_append_character = val[0].encode(Reline::IOGate.encoding)
@completion_append_character = val[0].encode(encoding)
else
@completion_append_character = nil
end
end

def basic_word_break_characters=(v)
@basic_word_break_characters = v.encode(Reline::IOGate.encoding)
@basic_word_break_characters = v.encode(encoding)
end

def completer_word_break_characters=(v)
@completer_word_break_characters = v.encode(Reline::IOGate.encoding)
@completer_word_break_characters = v.encode(encoding)
end

def basic_quote_characters=(v)
@basic_quote_characters = v.encode(Reline::IOGate.encoding)
@basic_quote_characters = v.encode(encoding)
end

def completer_quote_characters=(v)
@completer_quote_characters = v.encode(Reline::IOGate.encoding)
@completer_quote_characters = v.encode(encoding)
end

def filename_quote_characters=(v)
@filename_quote_characters = v.encode(Reline::IOGate.encoding)
@filename_quote_characters = v.encode(encoding)
end

def special_prefixes=(v)
@special_prefixes = v.encode(Reline::IOGate.encoding)
@special_prefixes = v.encode(encoding)
end

def completion_case_fold=(v)
Expand Down Expand Up @@ -181,20 +181,16 @@ def dialog_proc(name_sym)

def input=(val)
raise TypeError unless val.respond_to?(:getc) or val.nil?
if val.respond_to?(:getc)
if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
Reline::ANSI.input = val
elsif Reline::IOGate == Reline::GeneralIO
Reline::GeneralIO.input = val
end
if val.respond_to?(:getc) && Reline::IOGate.respond_to?(:input=)
Reline::IOGate.input = val
end
end

def output=(val)
raise TypeError unless val.respond_to?(:write) or val.nil?
@output = val
if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
Reline::ANSI.output = val
if Reline::IOGate.respond_to?(:output=)
Reline::IOGate.output = val
end
end

Expand Down Expand Up @@ -313,7 +309,7 @@ def readline(prompt = '', add_hist = false)
otio = Reline::IOGate.prep

may_req_ambiguous_char_width
line_editor.reset(prompt, encoding: Reline::IOGate.encoding)
line_editor.reset(prompt, encoding: encoding)
if multiline
line_editor.multiline_on
if block_given?
Expand Down Expand Up @@ -565,7 +561,7 @@ 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.line_editor = Reline::LineEditor.new(core.config, core.encoding)

core.basic_word_break_characters = " \t\n`><=;|&{("
core.completer_word_break_characters = " \t\n`><=;|&{("
Expand Down