mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
Rename confuzed name Reline::IO with Reline::IOGate
This commit is contained in:
parent
0cc893d01d
commit
f54aa6c5b2
2 changed files with 32 additions and 32 deletions
|
@ -184,8 +184,8 @@ module Reline
|
||||||
raise TypeError unless val.respond_to?(:getc) or val.nil?
|
raise TypeError unless val.respond_to?(:getc) or val.nil?
|
||||||
if val.respond_to?(:getc)
|
if val.respond_to?(:getc)
|
||||||
Reline::GeneralIO.input = val
|
Reline::GeneralIO.input = val
|
||||||
remove_const('IO') if const_defined?('IO')
|
remove_const('IOGate') if const_defined?('IOGate')
|
||||||
const_set('IO', Reline::GeneralIO)
|
const_set('IOGate', Reline::GeneralIO)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ module Reline
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_screen_size
|
def self.get_screen_size
|
||||||
Reline::IO.get_screen_size
|
Reline::IOGate.get_screen_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def retrieve_completion_block(line, byte_pointer)
|
def retrieve_completion_block(line, byte_pointer)
|
||||||
|
@ -264,7 +264,7 @@ module Reline
|
||||||
|
|
||||||
def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
|
def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
|
||||||
@@config.read
|
@@config.read
|
||||||
otio = Reline::IO.prep
|
otio = Reline::IOGate.prep
|
||||||
|
|
||||||
may_req_ambiguous_char_width
|
may_req_ambiguous_char_width
|
||||||
@@line_editor.reset(prompt)
|
@@line_editor.reset(prompt)
|
||||||
|
@ -306,7 +306,7 @@ module Reline
|
||||||
key_stroke = Reline::KeyStroke.new(config)
|
key_stroke = Reline::KeyStroke.new(config)
|
||||||
begin
|
begin
|
||||||
loop do
|
loop do
|
||||||
c = Reline::IO.getc
|
c = Reline::IOGate.getc
|
||||||
key_stroke.input_to!(c)&.then { |inputs|
|
key_stroke.input_to!(c)&.then { |inputs|
|
||||||
inputs.each { |c|
|
inputs.each { |c|
|
||||||
@@line_editor.input_key(c)
|
@@line_editor.input_key(c)
|
||||||
|
@ -315,23 +315,23 @@ module Reline
|
||||||
}
|
}
|
||||||
break if @@line_editor.finished?
|
break if @@line_editor.finished?
|
||||||
end
|
end
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Reline::IO.deprep(otio)
|
Reline::IOGate.deprep(otio)
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
||||||
Reline::IO.deprep(otio)
|
Reline::IOGate.deprep(otio)
|
||||||
end
|
end
|
||||||
|
|
||||||
def may_req_ambiguous_char_width
|
def may_req_ambiguous_char_width
|
||||||
@@ambiguous_width = 2 if Reline::IO == Reline::GeneralIO or STDOUT.is_a?(File)
|
@@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
|
||||||
return if @@ambiguous_width
|
return if @@ambiguous_width
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
print "\u{25bd}"
|
print "\u{25bd}"
|
||||||
@@ambiguous_width = Reline::IO.cursor_pos.x
|
@@ambiguous_width = Reline::IOGate.cursor_pos.x
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
Reline::IO.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ambiguous_width
|
def self.ambiguous_width
|
||||||
|
@ -341,9 +341,9 @@ end
|
||||||
|
|
||||||
if Reline::IS_WINDOWS
|
if Reline::IS_WINDOWS
|
||||||
require 'reline/windows'
|
require 'reline/windows'
|
||||||
Reline::IO = Reline::Windows
|
Reline::IOGate = Reline::Windows
|
||||||
else
|
else
|
||||||
require 'reline/ansi'
|
require 'reline/ansi'
|
||||||
Reline::IO = Reline::ANSI
|
Reline::IOGate = Reline::ANSI
|
||||||
end
|
end
|
||||||
require 'reline/general_io'
|
require 'reline/general_io'
|
||||||
|
|
|
@ -172,18 +172,18 @@ class Reline::LineEditor
|
||||||
|
|
||||||
private def scroll_down(val)
|
private def scroll_down(val)
|
||||||
if val <= @rest_height
|
if val <= @rest_height
|
||||||
Reline::IO.move_cursor_down(val)
|
Reline::IOGate.move_cursor_down(val)
|
||||||
@rest_height -= val
|
@rest_height -= val
|
||||||
else
|
else
|
||||||
Reline::IO.move_cursor_down(@rest_height)
|
Reline::IOGate.move_cursor_down(@rest_height)
|
||||||
Reline::IO.scroll_down(val - @rest_height)
|
Reline::IOGate.scroll_down(val - @rest_height)
|
||||||
@rest_height = 0
|
@rest_height = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def move_cursor_up(val)
|
private def move_cursor_up(val)
|
||||||
if val > 0
|
if val > 0
|
||||||
Reline::IO.move_cursor_up(val)
|
Reline::IOGate.move_cursor_up(val)
|
||||||
@rest_height += val
|
@rest_height += val
|
||||||
elsif val < 0
|
elsif val < 0
|
||||||
move_cursor_down(-val)
|
move_cursor_down(-val)
|
||||||
|
@ -192,7 +192,7 @@ class Reline::LineEditor
|
||||||
|
|
||||||
private def move_cursor_down(val)
|
private def move_cursor_down(val)
|
||||||
if val > 0
|
if val > 0
|
||||||
Reline::IO.move_cursor_down(val)
|
Reline::IOGate.move_cursor_down(val)
|
||||||
@rest_height -= val
|
@rest_height -= val
|
||||||
@rest_height = 0 if @rest_height < 0
|
@rest_height = 0 if @rest_height < 0
|
||||||
elsif val < 0
|
elsif val < 0
|
||||||
|
@ -224,8 +224,8 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
|
|
||||||
def rerender # TODO: support physical and logical lines
|
def rerender # TODO: support physical and logical lines
|
||||||
@rest_height ||= (Reline::IO.get_screen_size.first - 1) - Reline::IO.cursor_pos.y
|
@rest_height ||= (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
|
||||||
@screen_size ||= Reline::IO.get_screen_size
|
@screen_size ||= Reline::IOGate.get_screen_size
|
||||||
if @menu_info
|
if @menu_info
|
||||||
@output.puts
|
@output.puts
|
||||||
@menu_info.list.each do |item|
|
@menu_info.list.each do |item|
|
||||||
|
@ -245,7 +245,7 @@ class Reline::LineEditor
|
||||||
prompt_width = @prompt_width
|
prompt_width = @prompt_width
|
||||||
end
|
end
|
||||||
if @cleared
|
if @cleared
|
||||||
Reline::IO.clear_screen
|
Reline::IOGate.clear_screen
|
||||||
@cleared = false
|
@cleared = false
|
||||||
back = 0
|
back = 0
|
||||||
@buffer_of_lines.each_with_index do |line, index|
|
@buffer_of_lines.each_with_index do |line, index|
|
||||||
|
@ -258,7 +258,7 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
move_cursor_up(back)
|
move_cursor_up(back)
|
||||||
move_cursor_down(@first_line_started_from + @started_from)
|
move_cursor_down(@first_line_started_from + @started_from)
|
||||||
Reline::IO.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# FIXME: end of logical line sometimes breaks
|
# FIXME: end of logical line sometimes breaks
|
||||||
|
@ -302,7 +302,7 @@ class Reline::LineEditor
|
||||||
@previous_line_index = nil
|
@previous_line_index = nil
|
||||||
elsif @rerender_all
|
elsif @rerender_all
|
||||||
move_cursor_up(@first_line_started_from + @started_from)
|
move_cursor_up(@first_line_started_from + @started_from)
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
back = 0
|
back = 0
|
||||||
@buffer_of_lines.each do |line|
|
@buffer_of_lines.each do |line|
|
||||||
width = prompt_width + calculate_width(line)
|
width = prompt_width + calculate_width(line)
|
||||||
|
@ -314,10 +314,10 @@ class Reline::LineEditor
|
||||||
move_cursor_up(back)
|
move_cursor_up(back)
|
||||||
elsif back < @highest_in_all
|
elsif back < @highest_in_all
|
||||||
scroll_down(back)
|
scroll_down(back)
|
||||||
Reline::IO.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
(@highest_in_all - back).times do
|
(@highest_in_all - back).times do
|
||||||
scroll_down(1)
|
scroll_down(1)
|
||||||
Reline::IO.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
end
|
end
|
||||||
move_cursor_up(@highest_in_all)
|
move_cursor_up(@highest_in_all)
|
||||||
end
|
end
|
||||||
|
@ -344,8 +344,8 @@ class Reline::LineEditor
|
||||||
render_partial(prompt, prompt_width, @line) if !@is_multiline or !finished?
|
render_partial(prompt, prompt_width, @line) if !@is_multiline or !finished?
|
||||||
if @is_multiline and finished?
|
if @is_multiline and finished?
|
||||||
scroll_down(1) unless @buffer_of_lines.last.empty?
|
scroll_down(1) unless @buffer_of_lines.last.empty?
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
Reline::IO.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -364,13 +364,13 @@ class Reline::LineEditor
|
||||||
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
@started_from = calculate_height_by_width(prompt_width + @cursor) - 1
|
||||||
end
|
end
|
||||||
visual_lines.each_with_index do |line, index|
|
visual_lines.each_with_index do |line, index|
|
||||||
Reline::IO.move_cursor_column(0)
|
Reline::IOGate.move_cursor_column(0)
|
||||||
escaped_print line
|
escaped_print line
|
||||||
if @first_prompt
|
if @first_prompt
|
||||||
@first_prompt = false
|
@first_prompt = false
|
||||||
@pre_input_hook&.call
|
@pre_input_hook&.call
|
||||||
end
|
end
|
||||||
Reline::IO.erase_after_cursor
|
Reline::IOGate.erase_after_cursor
|
||||||
move_cursor_down(1) if index < (visual_lines.size - 1)
|
move_cursor_down(1) if index < (visual_lines.size - 1)
|
||||||
end
|
end
|
||||||
if with_control
|
if with_control
|
||||||
|
@ -378,7 +378,7 @@ class Reline::LineEditor
|
||||||
@output.puts
|
@output.puts
|
||||||
else
|
else
|
||||||
move_cursor_up((visual_lines.size - 1) - @started_from)
|
move_cursor_up((visual_lines.size - 1) - @started_from)
|
||||||
Reline::IO.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
visual_lines.size
|
visual_lines.size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue