module RatatuiRuby::Backend
Backend abstractions for terminal rendering.
This module contains types related to terminal backend operations. It mirrors upstream Ratatuiās backend module structure.
Public Class Methods
Source
# File lib/ratatui_ruby/backend.rb, line 44 def window_size window_size = Terminal._terminal_window_size return nil unless window_size columns, rows, px_width, px_height = window_size WindowSize.new( columns_rows: Layout::Size.new(width: columns, height: rows), pixels: Layout::Size.new(width: px_width, height: px_height) ) rescue nil end
Queries terminal window size in characters and pixels.
Some operations need both the character grid and pixel dimensions. Querying them separately wastes syscalls. Most backends fetch both at once anyway.
This method queries crossterm for window dimensions. It returns a Backend::WindowSize with columns_rows and pixels fields, each as Layout::Size instances. Returns nil if the query fails.
Note: Pixel dimensions may be zero on some systems. Unix marks these fields āunusedā in TIOCGWINSZ. Windows does not implement them.
Example
ws = RatatuiRuby::Backend.window_size if ws puts "#{ws.columns_rows.width}x#{ws.columns_rows.height} chars" puts "#{ws.pixels.width}x#{ws.pixels.height} pixels" end