class Iterm2

Overview

Display images within the terminal using the ITerm2 Inline Images Protocol.

Defined in:

iterm2.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(output : IO = STDOUT) #

Creates a new instance.


[View source]

Instance Method Detail

def display(input : IO, name = nil, size = nil, width = nil, height = nil, preserve_aspect_ratio = true, inline = true) #

Wraps the supplied input in the protocol envelop and writes the result to the output.

By default, ITerm2 will display supported image formats within the terminal. It will download unsupported image formats and non-image inputs.

If downloading, name is the filename of the downloaded file (it defaults to "Unnamed file") and "size" is the file size in bytes (it is optional and only used by the ITerm2 progress indicator).

width and height are the width and height with which to display the image. width and height are specified by a number followed by an optional unit, or the word "auto". Units are pixels ("px") or the percent ("%") of the session's width or height. A number without a unit specifies character cells.

If preserve_aspect_ratio is false, then the image's inherent aspect ratio will not be respected; otherwise, it will fill the specified width and height as much as possible without stretching. It defaults to true.

If inline is false, the input will be downloaded with no visual representation in the terminal session. Otherwise, it will be displayed inline. It defaults to true.


[View source]
def display(name = nil, size = nil, width = nil, height = nil, preserve_aspect_ratio = true, inline = true, &) #

Yields an IO instance; wraps data written to the instance in the protocol envelop and writes the result to the output.

By default, ITerm2 will display supported image formats within the terminal. It will download unsupported image formats and non-image inputs.

If downloading, name is the filename of the downloaded file (it defaults to "Unnamed file") and "size" is the file size in bytes (it is optional and only used by the ITerm2 progress indicator).

width and height are the width and height with which to display the image. width and height are specified by a number followed by an optional unit, or the word "auto". Units are pixels ("px") or the percent ("%") of the session's width or height. A number without a unit specifies character cells.

If preserve_aspect_ratio is false, then the image's inherent aspect ratio will not be respected; otherwise, it will fill the specified width and height as much as possible without stretching. It defaults to true.

If inline is false, the input will be downloaded with no visual representation in the terminal session. Otherwise, it will be displayed inline. It defaults to true.


[View source]