Skip to content

Commit a93119c

Browse files
committed
Use IO#write instead of IO#print
IO#print always adds a string of $\ automatically.
1 parent 41deb1a commit a93119c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

lib/reline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def readline(prompt = '', add_hist = false)
336336
@ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
337337
return if ambiguous_width
338338
Reline::IOGate.move_cursor_column(0)
339-
print "\u{25bd}"
339+
output.write "\u{25bd}"
340340
@ambiguous_width = Reline::IOGate.cursor_pos.x
341341
Reline::IOGate.move_cursor_column(0)
342342
Reline::IOGate.erase_after_cursor

lib/reline/ansi.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,37 +124,37 @@ def self.cursor_pos
124124
end
125125

126126
def self.move_cursor_column(x)
127-
print "\e[#{x + 1}G"
127+
@@output.write "\e[#{x + 1}G"
128128
end
129129

130130
def self.move_cursor_up(x)
131131
if x > 0
132-
print "\e[#{x}A" if x > 0
132+
@@output.write "\e[#{x}A" if x > 0
133133
elsif x < 0
134134
move_cursor_down(-x)
135135
end
136136
end
137137

138138
def self.move_cursor_down(x)
139139
if x > 0
140-
print "\e[#{x}B" if x > 0
140+
@@output.write "\e[#{x}B" if x > 0
141141
elsif x < 0
142142
move_cursor_up(-x)
143143
end
144144
end
145145

146146
def self.erase_after_cursor
147-
print "\e[K"
147+
@@output.write "\e[K"
148148
end
149149

150150
def self.scroll_down(x)
151151
return if x.zero?
152-
print "\e[#{x}S"
152+
@@output.write "\e[#{x}S"
153153
end
154154

155155
def self.clear_screen
156-
print "\e[2J"
157-
print "\e[1;1H"
156+
@@output.write "\e[2J"
157+
@@output.write "\e[1;1H"
158158
end
159159

160160
@@old_winch_handler = nil

lib/reline/line_editor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def rerender
319319
@rerender_all = true
320320
@menu_info.list.sort!.each do |item|
321321
Reline::IOGate.move_cursor_column(0)
322-
@output.print item
322+
@output.write item
323323
@output.flush
324324
scroll_down(1)
325325
end
@@ -516,7 +516,7 @@ def rerender
516516
end
517517
next
518518
end
519-
@output.print line
519+
@output.write line
520520
if Reline::IOGate.win? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last
521521
# A newline is automatically inserted if a character is rendered at eol on command prompt.
522522
@rest_height -= 1 if @rest_height > 0

lib/reline/windows.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ def self.scroll_down(val)
250250

251251
def self.clear_screen
252252
# TODO: Use FillConsoleOutputCharacter and FillConsoleOutputAttribute
253-
print "\e[2J"
254-
print "\e[1;1H"
253+
write "\e[2J"
254+
write "\e[1;1H"
255255
end
256256

257257
def self.set_screen_size(rows, columns)

0 commit comments

Comments
 (0)