[前][次][番号順一覧][スレッド一覧]

ruby-changes:60074

From: aycabta <ko1@a...>
Date: Fri, 14 Feb 2020 22:50:27 +0900 (JST)
Subject: [ruby-changes:60074] 2efb38e766 (master): [ruby/reline] Use IO#write instead of IO#print

https://git.ruby-lang.org/ruby.git/commit/?id=2efb38e766

From 2efb38e766b6fc304bb933d696c7500425d178a1 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 14 Feb 2020 22:34:56 +0900
Subject: [ruby/reline] Use IO#write instead of IO#print

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

https://github.com/ruby/reline/commit/a93119c847

diff --git a/lib/reline.rb b/lib/reline.rb
index bcb3af5..3303fb4 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -336,7 +336,7 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L336
       @ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
       return if ambiguous_width
       Reline::IOGate.move_cursor_column(0)
-      print "\u{25bd}"
+      output.write "\u{25bd}"
       @ambiguous_width = Reline::IOGate.cursor_pos.x
       Reline::IOGate.move_cursor_column(0)
       Reline::IOGate.erase_after_cursor
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index 9959529..3ef02d6 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -124,12 +124,12 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L124
   end
 
   def self.move_cursor_column(x)
-    print "\e[#{x + 1}G"
+    @@output.write "\e[#{x + 1}G"
   end
 
   def self.move_cursor_up(x)
     if x > 0
-      print "\e[#{x}A" if x > 0
+      @@output.write "\e[#{x}A" if x > 0
     elsif x < 0
       move_cursor_down(-x)
     end
@@ -137,24 +137,24 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L137
 
   def self.move_cursor_down(x)
     if x > 0
-      print "\e[#{x}B" if x > 0
+      @@output.write "\e[#{x}B" if x > 0
     elsif x < 0
       move_cursor_up(-x)
     end
   end
 
   def self.erase_after_cursor
-    print "\e[K"
+    @@output.write "\e[K"
   end
 
   def self.scroll_down(x)
     return if x.zero?
-    print "\e[#{x}S"
+    @@output.write "\e[#{x}S"
   end
 
   def self.clear_screen
-    print "\e[2J"
-    print "\e[1;1H"
+    @@output.write "\e[2J"
+    @@output.write "\e[1;1H"
   end
 
   @@old_winch_handler = nil
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index c68847d..478d1d7 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -319,7 +319,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L319
       @rerender_all = true
       @menu_info.list.sort!.each do |item|
         Reline::IOGate.move_cursor_column(0)
-        @output.print item
+        @output.write item
         @output.flush
         scroll_down(1)
       end
@@ -516,7 +516,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L516
         end
         next
       end
-      @output.print line
+      @output.write line
       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.
         @rest_height -= 1 if @rest_height > 0
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index 22a009e..c229c85 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -250,8 +250,8 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L250
 
   def self.clear_screen
     # TODO: Use FillConsoleOutputCharacter and FillConsoleOutputAttribute
-    print "\e[2J"
-    print "\e[1;1H"
+    write "\e[2J"
+    write "\e[1;1H"
   end
 
   def self.set_screen_size(rows, columns)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]