Module: Cape::XTerm Private
- Defined in:
- lib/cape/xterm.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Formats output for an xterm console.
Convenience class methods are made available dynamically that permit multiple formats to be applied.
Constant Summary collapse
- FORMATS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The xterm formatting codes.
{:bold => '1', :underlined => '4', :blinking => '5', :inverse => '7', :foreground_black => '30', :foreground_red => '31', :foreground_green => '32', :foreground_yellow => '33', :foreground_blue => '34', :foreground_magenta => '35', :foreground_cyan => '36', :foreground_gray => '37', :foreground_default => '39', :background_black => '40', :background_red => '41', :background_green => '42', :background_yellow => '43', :background_blue => '44', :background_magenta => '45', :background_cyan => '46', :background_gray => '47', :background_default => '49'}
Class Method Summary collapse
-
.background_black(string) ⇒ String
private
Formats the specified string with a black background.
-
.background_blue(string) ⇒ String
private
Formats the specified string with a blue background.
-
.background_cyan(string) ⇒ String
private
Formats the specified string with a cyan background.
-
.background_default(string) ⇒ String
private
Formats the specified string in the default background color.
-
.background_gray(string) ⇒ String
private
Formats the specified string with a gray background.
-
.background_green(string) ⇒ String
private
Formats the specified string with a green background.
-
.background_magenta(string) ⇒ String
private
Formats the specified string with a magenta background.
-
.background_red(string) ⇒ String
private
Formats the specified string with a red background.
-
.background_yellow(string) ⇒ String
private
Formats the specified string with a yellow background.
-
.blinking(string) ⇒ String
private
Formats the specified string in blinking type.
-
.bold(string) ⇒ String
private
Formats the specified string in bold type.
-
.foreground_black(string) ⇒ String
private
Formats the specified string in black.
-
.foreground_blue(string) ⇒ String
private
Formats the specified string in blue.
-
.foreground_cyan(string) ⇒ String
private
Formats the specified string in cyan.
-
.foreground_default(string) ⇒ String
private
Formats the specified string in the default foreground color.
-
.foreground_gray(string) ⇒ String
private
Formats the specified string in gray.
-
.foreground_green(string) ⇒ String
private
Formats the specified string in green.
-
.foreground_magenta(string) ⇒ String
private
Formats the specified string in magenta.
-
.foreground_red(string) ⇒ String
private
Formats the specified string in red.
-
.foreground_yellow(string) ⇒ String
private
Formats the specified string in yellow.
-
.format(string, *formats) ⇒ String
private
Applies the specified formats to string.
-
.inverse(string) ⇒ String
private
Formats the specified string in inverse colors.
-
.underlined(string) ⇒ String
private
Formats the specified string in underlined type.
Class Method Details
.background_black(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a black background.
|
# File 'lib/cape/xterm.rb', line 181
|
.background_blue(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a blue background.
|
# File 'lib/cape/xterm.rb', line 225
|
.background_cyan(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a cyan background.
|
# File 'lib/cape/xterm.rb', line 247
|
.background_default(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in the default background color.
|
# File 'lib/cape/xterm.rb', line 269
|
.background_gray(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a gray background.
|
# File 'lib/cape/xterm.rb', line 258
|
.background_green(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a green background.
|
# File 'lib/cape/xterm.rb', line 203
|
.background_magenta(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a magenta background.
|
# File 'lib/cape/xterm.rb', line 236
|
.background_red(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a red background.
|
# File 'lib/cape/xterm.rb', line 192
|
.background_yellow(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string with a yellow background.
|
# File 'lib/cape/xterm.rb', line 214
|
.blinking(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in blinking type.
|
# File 'lib/cape/xterm.rb', line 60
|
.bold(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in bold type.
|
# File 'lib/cape/xterm.rb', line 38
|
.foreground_black(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in black.
|
# File 'lib/cape/xterm.rb', line 82
|
.foreground_blue(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in blue.
|
# File 'lib/cape/xterm.rb', line 126
|
.foreground_cyan(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in cyan.
|
# File 'lib/cape/xterm.rb', line 148
|
.foreground_default(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in the default foreground color.
|
# File 'lib/cape/xterm.rb', line 170
|
.foreground_gray(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in gray.
|
# File 'lib/cape/xterm.rb', line 159
|
.foreground_green(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in green.
|
# File 'lib/cape/xterm.rb', line 104
|
.foreground_magenta(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in magenta.
|
# File 'lib/cape/xterm.rb', line 137
|
.foreground_red(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in red.
|
# File 'lib/cape/xterm.rb', line 93
|
.foreground_yellow(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in yellow.
|
# File 'lib/cape/xterm.rb', line 115
|
.format(string, *formats) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies the specified formats to string.
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/cape/xterm.rb', line 286 def self.format(string, *formats) formatting_codes = formats.collect do |f| unless FORMATS.key?(f) raise ::ArgumentError, "Unrecognized format #{f.inspect}" end FORMATS[f] end return string if formatting_codes.empty? || string.nil? "\e[#{formatting_codes.join ';'}m#{string}\e[0m" end |
.inverse(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in inverse colors.
|
# File 'lib/cape/xterm.rb', line 71
|
.underlined(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the specified string in underlined type.
|
# File 'lib/cape/xterm.rb', line 49
|