module RatatuiRuby::Draw
Draw commands for custom widgets.
Custom widgets return an array of Draw commands instead of writing directly to a buffer. This keeps all pointers safely inside Rust while Ruby works with pure data.
Example
class MyWidget def render(area) [ RatatuiRuby::Draw.string(area.x, area.y, "Hello", {fg: :red}), RatatuiRuby::Draw.cell(area.x + 6, area.y, RatatuiRuby::Cell.char("!")) ] end end
Constants
- CellCmd
-
Command to draw a cell at the given coordinates.
- x
-
X coordinate (absolute).
- y
-
Y coordinate (absolute).
- cell
-
The
Cellto draw.
- StringCmd
-
Command to draw a string at the given coordinates.
Public Class Methods
Source
# File lib/ratatui_ruby/draw.rb, line 61 def self.cell(x, y, cell) = CellCmd.new(x: Integer(x), y: Integer(y), cell:) end
Creates a cell draw command.
- x
-
X coordinate (Integer, duck-typed via
to_int). - y
-
Y coordinate (Integer, duck-typed via
to_int). - cell
-
Cellto draw.
Source
# File lib/ratatui_ruby/draw.rb, line 54 def self.string(x, y, string, style = {}) = StringCmd.new(x: Integer(x), y: Integer(y), string:, style:) # Creates a cell draw command. # # [x] X coordinate (Integer, duck-typed via +to_int+). # [y] Y coordinate (Integer, duck-typed via +to_int+). # [cell] Cell to draw. def self.cell(x, y, cell) = CellCmd.new(x: Integer(x), y: Integer(y), cell:) end end