Class: Terminal::Renderer
- Inherits:
-
Object
- Object
- Terminal::Renderer
- Defined in:
- lib/terminal/renderer.rb
Constant Summary collapse
- MEGABYTES =
1024 * 1024
- EMOJI_UNICODE_REGEXP =
/[\u{1f600}-\u{1f64f}]|[\u{2702}-\u{27b0}]|[\u{1f680}-\u{1f6ff}]|[\u{24C2}-\u{1F251}]|[\u{1f300}-\u{1f5ff}]/- EMOJI_IGNORE =
[ "heavy_check_mark".freeze, "heavy_multiplication_x".freeze ]
- ESCAPE_CONTROL_CHARACTERS =
"qQmKGgKAaBbCcDd".freeze
- ESCAPE_CAPTURE_REGEX =
/\e\[(.*)([#{ESCAPE_CONTROL_CHARACTERS}])/- INTERESTING_PARTS_REGEX =
/[\n\r\b]|\e\[[\d;]*[#{ESCAPE_CONTROL_CHARACTERS}]|./
Instance Method Summary collapse
-
#initialize(output, options = {}) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
Instance Method Details
#render ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/terminal/renderer.rb', line 28 def render return "" if @output.nil? # Don't allow parsing of outputs longer than 4 meg output = dup_check_and_chomp_length(@output) # Force encoding on the output first force_encoding!(output) # Now do the render the output to the screen render_to_screen(output) # Convert the screen to a string output = convert_screen_to_string # Escape any HTML escaped_html = escape_html(output) # Now convert the colors to HTML convert_to_html!(escaped_html) # And emojify replace_unicode_with_emoji!(escaped_html) escaped_html end |