add IO::Line::Multiple
This commit is contained in:
parent
a0fb239729
commit
75537deea7
1 changed files with 19 additions and 0 deletions
19
binlib/io/line/multiple.rb
Normal file
19
binlib/io/line/multiple.rb
Normal 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
|
Loading…
Reference in a new issue