[ruby/reline] Use IO#write instead of IO#print

IO#print always adds a string of $\ automatically.

https://github.com/ruby/reline/commit/a93119c847
This commit is contained in:
aycabta 2020-02-14 22:34:56 +09:00
Родитель 78282d4655
Коммит 2efb38e766
4 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -336,7 +336,7 @@ module Reline
@ambiguous_width = 2 if Reline::IOGate == 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::IOGate.move_cursor_column(0) Reline::IOGate.move_cursor_column(0)
print "\u{25bd}" output.write "\u{25bd}"
@ambiguous_width = Reline::IOGate.cursor_pos.x @ambiguous_width = Reline::IOGate.cursor_pos.x
Reline::IOGate.move_cursor_column(0) Reline::IOGate.move_cursor_column(0)
Reline::IOGate.erase_after_cursor Reline::IOGate.erase_after_cursor

Просмотреть файл

@ -124,12 +124,12 @@ class Reline::ANSI
end end
def self.move_cursor_column(x) def self.move_cursor_column(x)
print "\e[#{x + 1}G" @@output.write "\e[#{x + 1}G"
end end
def self.move_cursor_up(x) def self.move_cursor_up(x)
if x > 0 if x > 0
print "\e[#{x}A" if x > 0 @@output.write "\e[#{x}A" if x > 0
elsif x < 0 elsif x < 0
move_cursor_down(-x) move_cursor_down(-x)
end end
@ -137,24 +137,24 @@ class Reline::ANSI
def self.move_cursor_down(x) def self.move_cursor_down(x)
if x > 0 if x > 0
print "\e[#{x}B" if x > 0 @@output.write "\e[#{x}B" if x > 0
elsif x < 0 elsif x < 0
move_cursor_up(-x) move_cursor_up(-x)
end end
end end
def self.erase_after_cursor def self.erase_after_cursor
print "\e[K" @@output.write "\e[K"
end end
def self.scroll_down(x) def self.scroll_down(x)
return if x.zero? return if x.zero?
print "\e[#{x}S" @@output.write "\e[#{x}S"
end end
def self.clear_screen def self.clear_screen
print "\e[2J" @@output.write "\e[2J"
print "\e[1;1H" @@output.write "\e[1;1H"
end end
@@old_winch_handler = nil @@old_winch_handler = nil

Просмотреть файл

@ -319,7 +319,7 @@ class Reline::LineEditor
@rerender_all = true @rerender_all = true
@menu_info.list.sort!.each do |item| @menu_info.list.sort!.each do |item|
Reline::IOGate.move_cursor_column(0) Reline::IOGate.move_cursor_column(0)
@output.print item @output.write item
@output.flush @output.flush
scroll_down(1) scroll_down(1)
end end
@ -516,7 +516,7 @@ class Reline::LineEditor
end end
next next
end end
@output.print line @output.write line
if Reline::IOGate.win? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last if Reline::IOGate.win? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last
# A newline is automatically inserted if a character is rendered at eol on command prompt. # A newline is automatically inserted if a character is rendered at eol on command prompt.
@rest_height -= 1 if @rest_height > 0 @rest_height -= 1 if @rest_height > 0

Просмотреть файл

@ -250,8 +250,8 @@ class Reline::Windows
def self.clear_screen def self.clear_screen
# TODO: Use FillConsoleOutputCharacter and FillConsoleOutputAttribute # TODO: Use FillConsoleOutputCharacter and FillConsoleOutputAttribute
print "\e[2J" write "\e[2J"
print "\e[1;1H" write "\e[1;1H"
end end
def self.set_screen_size(rows, columns) def self.set_screen_size(rows, columns)