class

TermBuf::Region

Inherits Reference < Object

Stability: stable — changes only in a major release.

A rectangle of the buffer that scrolls as a unit, optionally keeping the rows that scroll off it.

Scrollback capacity defaults to zero, which is the classic curses model: what scrolls away is gone. Give a region a capacity and it keeps that many rows of history, so a log pane gets scrollback without the application reimplementing it.

Constructors

new(bounds : Rect, scrollback : Int32 = 0)

A region over bounds, keeping up to scrollback rows of what leaves the top. Zero discards them, which is the classic curses model.

Source

Instance methods

bounds

The rectangle the region covers.

Source
bounds=(bounds : Rect) : Rect

Moves or resizes the region.

What the screen-wide region a default cursor lives in needs when the window changes size. A region an application placed itself keeps the rectangle it was given; the buffer does not move regions about.

Source
clear_scrollback

Throws away the history and returns the view to the live rows.

Source
history(distance : Int32) : Array(Cell) | Nil

The scrolled-off row distance rows above the live content, where one is the most recent. nil once the request runs past what is kept.

Source
push_scrollback(row : Slice(Cell)) : Nil

Keeps a row that has scrolled off the top. The slice is copied, so the caller is free to overwrite it immediately.

Source
scrollback

Rows that have scrolled off the top, oldest first.

Source
scrollback_capacity

How many scrolled-off rows to keep. Zero discards them.

Source
scrolled_back?

Whether the region is showing history rather than live content.

Source
to_s(io : IO) : Nil

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>
Source
view_offset

How far back through the scrollback the region is being viewed: zero shows live content, one shows the most recently scrolled-off row at the top, and so on.

Source
view_offset=(value : Int32) : Int32

Scrolls the view back by value rows, clamped to what scrollback holds.

Source