add IO::Line::Multiple

This commit is contained in:
0x1eef 2022-06-08 21:34:51 -03:00
parent a0fb239729
commit 75537deea7

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
class IO::Line::Multiple
def initialize(lines, cursor)
@lines = lines
@cursor = cursor
end
def print(*strs, lineno:)
line = @lines[lineno]
if lineno > @cursor
line.io.cursor_down(lineno - @cursor)
elsif lineno < @cursor
line.io.cursor_up(lineno + @cursor)
end
@cursor = lineno
line.rewind.print(*strs)
end
end