Module: RatatuiRuby::Draw
- Defined in:
- lib/ratatui_ruby/draw.rb
Overview
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
– SPDX-SnippetBegin SPDX-FileCopyrightText: 2025 Kerrick Long SPDX-License-Identifier: MIT-0 ++
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
– SPDX-SnippetEnd ++
Defined Under Namespace
Class Method Summary collapse
-
.cell(x, y, cell) ⇒ Object
Creates a cell draw command.
-
.string(x, y, string, style = {}) ⇒ Object
Creates a string draw command.
Class Method Details
.cell(x, y, cell) ⇒ Object
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.
61 |
# File 'lib/ratatui_ruby/draw.rb', line 61 def self.cell(x, y, cell) = CellCmd.new(x: Integer(x), y: Integer(y), cell:) |
.string(x, y, string, style = {}) ⇒ Object
Creates a string draw command.
- x
-
X coordinate (Integer, duck-typed via
to_int). - y
-
Y coordinate (Integer, duck-typed via
to_int). - string
-
Text to draw.
- style
-
Optional style (Hash or Style).
54 |
# 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:) |