module ConsoleGlitter::Screen

Public Instance Methods

clear(direction = :both) click to toggle source

Public: From the cursor’s position clear either the whole screen, or from the cursor’s position to the beginning or end of the screen.

direction - Symbol denoting the direction the screen should be cleared,

between :both :end or :beginning.  (default: :both)

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 12
def clear(direction = :both)
  options = [:both, :beginning, :end]
  target  = "clear_to_#{direction}"
  return(self.send(target)) if options.grep(direction).any?

  raise(ArgumentError,
        "Expected :both, :end, or :beginning, got #{direction}.")
end
Also aliased as: clear_to
clear_screen()
Alias for: clear_to_both
clear_to(direction = :both)
Alias for: clear
clear_to_beginning() click to toggle source

Public: Return the VT control code to clear from the cursor to the beginning of the screen.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 34
def clear_to_beginning
  ConsoleGlitter.escape('1J')
end
clear_to_both() click to toggle source

Public: Return the VT control code to clear the screen.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 41
def clear_to_both
  ConsoleGlitter.escape('2J')
end
Also aliased as: clear_screen
clear_to_end() click to toggle source

Public: Return the VT control code to clear from the cursor to the end of the screen.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 26
def clear_to_end
  ConsoleGlitter.escape('0J')
end
erase_line(direction = :both) click to toggle source

Public: From the cursor’s position clear either the whole line, or from the cursor’s position to the beginning or end of the line.

direction - Symbol denoting the direction the line should be cleared,

between :both :end or :beginning.  (default: :both)

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 53
def erase_line(direction = :both)
  options = [:both, :beginning, :end]
  target  = "erase_line_to_#{direction}"
  return(self.send(target)) if options.grep(direction).any?

  raise(ArgumentError,
        "Expected :both, :end, or :beginning, got #{direction}.")
end
Also aliased as: erase_line_to
erase_line_to(direction = :both)
Alias for: erase_line
erase_line_to_beginning() click to toggle source

Public: Return the VT control code to clear from the cursor to the beginning of the line.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 75
def erase_line_to_beginning
  ConsoleGlitter.escape('1K')
end
erase_line_to_both() click to toggle source

Public: Return the VT control code to clear the line where the cursor is.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 82
def erase_line_to_both
  ConsoleGlitter.escape('2K')
end
erase_line_to_end() click to toggle source

Public: Return the VT control code to clear from the cursor to the end of the line.

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 67
def erase_line_to_end
  ConsoleGlitter.escape('0K')
end
scroll_down(distance = 1) click to toggle source

Public: Return the VT control code to scroll the screen down by a given amount.

distance - Number of lines to scroll the screen. (default: 1)

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 102
def scroll_down(distance = 1)
  ConsoleGlitter.escape("#{distance}T")
end
scroll_up(distance = 1) click to toggle source

Public: Return the VT control code to scroll the screen up by a given amount.

distance - Number of lines to scroll the screen. (default: 1)

Returns a String containing the VT control code.

# File lib/console-glitter/screen.rb, line 92
def scroll_up(distance = 1)
  ConsoleGlitter.escape("#{distance}S")
end