class
Opal::UI::Buffer
- Opal::UI::Buffer
- Reference
- Object
Overview
In-memory 2D grid of screen cells representing a terminal frame.
Defined in:
opal/ui/buffer.crConstructors
Class Method Summary
- .flip_h_glyph(ch : Char) : Char
- .flip_v_glyph(ch : Char) : Char
-
.rotate_glyph(ch : Char, turns : Int32) : Char
Box-drawing glyph transposition helpers
Instance Method Summary
-
#active_mask : MaskMap | Nil
Active mask for masked rendering operations
-
#active_mask=(active_mask : MaskMap | Nil)
Active mask for masked rendering operations
-
#apply_shader(pass : Shader::Pass, time : Float64 = 0.0, frame : UInt64 = 0_u64) : self
Applies a shader pass to this buffer
-
#blit(src : Buffer, dst_x : Int32, dst_y : Int32, ignore_spaces : Bool = false) : Nil
Blits (copies) another buffer onto this buffer at the given coordinates.
- #cells : Array(Cell)
- #clear : Nil
- #clip_rect : Rect | Nil
- #clip_rect=(clip_rect : Rect | Nil)
- #clone : Buffer
- #copy(x : Int32, y : Int32, w : Int32, h : Int32) : Buffer
-
#copy(rect : Rect) : Buffer
Copies a subregion of this buffer into a new standalone Buffer.
-
#copy_from(other : Buffer) : Nil
In-place copies all cells and dimensions from another buffer without reallocating
- #crop(x : Int32, y : Int32, w : Int32, h : Int32) : Buffer
-
#crop(rect : Rect) : Buffer
Alias for copy
-
#dim_all : Nil
Dims the entire buffer to create a backdrop effect.
-
#dim_rect(x : Int32, y : Int32, w : Int32, h : Int32) : Nil
Applies dimming attribute to all cells within the given rectangle.
- #fill(x : Int32, y : Int32, w : Int32, h : Int32, cell : Cell = Cell.empty) : Nil
- #fill(x : Int32, y : Int32, w : Int32, h : Int32, char : Char, fg : Color = Color.none, bg : Color = Color.none) : Nil
- #fill_rect(x : Int32, y : Int32, w : Int32, h : Int32, cell : Cell = Cell.empty) : Nil
-
#fill_rect(rect : Rect, cell : Cell = Cell.empty) : Nil
Fills a rectangle with a specified cell
- #flip_h : Buffer
- #flip_v : Buffer
- #get(x : Int32, y : Int32) : Cell
- #height : Int32
- #in_bounds?(x : Int32, y : Int32) : Bool
-
#in_clip?(x : Int32, y : Int32) : Bool
Returns true if the coordinate is within the buffer bounds and the active clip rect (if any).
- #invert(x : Int32, y : Int32, w : Int32, h : Int32) : Nil
-
#invert(rect : Rect) : Nil
Inverts foreground and background colors in a rectangle
- #mask_feather : Bool
- #mask_feather=(mask_feather : Bool)
- #mask_offset_x : Int32
- #mask_offset_x=(mask_offset_x : Int32)
- #mask_offset_y : Int32
- #mask_offset_y=(mask_offset_y : Int32)
-
#paste(src : Buffer, dst_x : Int32, dst_y : Int32, mode : BlitMode = BlitMode::Replace, alpha : Float64 = 1.0) : Nil
Pastes another buffer onto this buffer with selectable BlitMode and optional alpha
- #put_char(x : Int32, y : Int32, char : Char, fg : Color = Color.none, bg : Color = Color.none, bold : Bool = false, dim : Bool = false, italic : Bool = false, underline : Bool = false, reverse : Bool = false, keep_bg : Bool = false, hyperlink : String | Nil = nil) : Nil
-
#put_line(x : Int32, y : Int32, text : String, width : Int32, fg : Color = Color.none, bg : Color = Color.none, bold : Bool = false, dim : Bool = false) : Nil
Writes string and pads remaining columns up to
#widthwith spaces, ensuring clean erasure -
#put_link(x : Int32, y : Int32, url : String, label : String | Nil = nil, fg : Color = Color.cyan, bg : Color = Color.none, bold : Bool = false, dim : Bool = false, italic : Bool = false, underline : Bool = true, reverse : Bool = false, max_width : Int32 | Nil = nil, keep_bg : Bool = false) : Int32
Writes an OSC 8 clickable hyperlink into the buffer cells at
(x, y). - #put_string(x : Int32, y : Int32, text : String, fg : Color = Color.none, bg : Color = Color.none, bold : Bool = false, dim : Bool = false, italic : Bool = false, underline : Bool = false, reverse : Bool = false, max_width : Int32 | Nil = nil, keep_bg : Bool = false, hyperlink : String | Nil = nil) : Int32
-
#render_to_string(with_ansi : Bool = true) : String
Renders the buffer content to a string, optionally including ANSI color and style sequences.
- #rotate_180 : Buffer
-
#rotate_90(clockwise : Bool = true) : Buffer
Transforms: Rotate 90 degrees clockwise or counterclockwise
-
#screenshot(path : String | Nil = nil, format : Symbol = :ansi, copy_to_clipboard : Bool = false) : String
Captures this buffer as a screenshot string in the specified format (:ansi, :text, or :html).
-
#screenshot_to_clipboard(format : Symbol = :text) : String
Captures this buffer as a screenshot and immediately copies it to the system clipboard.
-
#scroll_rect(rect : Rect, dx : Int32, dy : Int32, fill_char : Char = ' ') : Nil
Shifts cells within a rect by dx and dy, filling exposed regions with fill_char
- #set(x : Int32, y : Int32, cell : Cell) : Nil
-
#shade(region : Shader::Rect | Nil = nil, time : Float64 = 0.0, frame : UInt64 = 0_u64, &block : Shader::ShaderContext -> Nil) : self
Applies a custom text shader block to this buffer (or a specific region)
-
#to_html(title : String = "Opal Terminal Frame") : String
Exports the buffer as a self-contained HTML representation with styled CSS 24-bit colors.
-
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
- #width : Int32
-
#with_clip(x : Int32, y : Int32, w : Int32, h : Int32, &)
Executes a block with an active clipping rectangle.
-
#with_clip(rect : Rect, &)
Clip execution using a Rect struct
-
#with_mask(mask : MaskMap, offset_x : Int32 = 0, offset_y : Int32 = 0, feather : Bool = true, &)
Executes a block with an active mask map.
- #with_scissor(x : Int32, y : Int32, w : Int32, h : Int32, &)
-
#with_scissor(rect : Rect, &)
Executes a block with an active scissor clipping rectangle.
Constructor Detail
Class Method Detail
Instance Method Detail
Active mask for masked rendering operations
Applies a shader pass to this buffer
Blits (copies) another buffer onto this buffer at the given coordinates. If ignore_spaces is true, empty cells without background do not overwrite existing cells.
Copies a subregion of this buffer into a new standalone Buffer.
In-place copies all cells and dimensions from another buffer without reallocating
Applies dimming attribute to all cells within the given rectangle.
Fills a rectangle with a specified cell
Returns true if the coordinate is within the buffer bounds and the active clip rect (if any).
Inverts foreground and background colors in a rectangle
Pastes another buffer onto this buffer with selectable BlitMode and optional alpha
Writes string and pads remaining columns up to #width with spaces, ensuring clean erasure
Writes an OSC 8 clickable hyperlink into the buffer cells at (x, y).
Renders the buffer content to a string, optionally including ANSI color and style sequences.
Transforms: Rotate 90 degrees clockwise or counterclockwise
Captures this buffer as a screenshot string in the specified format (:ansi, :text, or :html).
If path is provided, writes the content to disk.
If copy_to_clipboard is true, copies the screenshot to the system clipboard.
Captures this buffer as a screenshot and immediately copies it to the system clipboard.
Shifts cells within a rect by dx and dy, filling exposed regions with fill_char
Applies a custom text shader block to this buffer (or a specific region)
Exports the buffer as a self-contained HTML representation with styled CSS 24-bit colors.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Executes a block with an active clipping rectangle. If a clip rectangle is already active, computes their intersection.
Executes a block with an active mask map.
Executes a block with an active scissor clipping rectangle.