Skip to content

Geometry

The dimensions of a terminal-backed Console.

Returned by geometry().

rows and cols are independently nil: a console may know one dimension without the other. The host console (term.console) always returns a Geometry, never nil itself.

Subclassing

Geometry is the interface; reading rows or cols on a bare instance raises UnsupportedError. A Do console that implements geometry() subclasses this to describe itself:

class FixedGeometry: term.Geometry
  pub field rows
  pub field cols

  def (init) self rows cols
    term.Geometry.(init) $self
    self.rows = rows
    self.cols = cols

Constructor

Geometry()

Initializes the base. A subclass calls this from its own (init).

Fields

cols @ (Int | nil)

Width in character cells, or nil if unknown.

let g = term.console.geometry()
if g.cols
  echo $ term.preformat $ "-" * g.cols
rows @ (Int | nil)

Height in character cells, or nil if unknown.