Method: TTY::Reader#count_screen_lines
- Defined in:
- lib/tty/reader.rb
#count_screen_lines(line_or_size, screen_width = TTY::Screen.width) ⇒ Integer
Count the number of screen lines given line takes up in terminal
362 363 364 365 366 367 368 369 370 371 |
# File 'lib/tty/reader.rb', line 362 def count_screen_lines(line_or_size, screen_width = TTY::Screen.width) line_size = if line_or_size.is_a?(Integer) line_or_size else Line.sanitize(line_or_size).size end # new character + we don't want to add new line on screen_width new_chars = self.class.windows? ? -1 : 1 1 + [0, (line_size - new_chars) / screen_width].max end |