class TermBuf::Region

Overview

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.

Defined in:

termbuf/core/region.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(bounds : Rect, scrollback : Int32 = 0) #

[View source]

Instance Method Detail

def bounds : Rect #

The rectangle the region covers.


[View source]
def 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.


[View source]
def clear_scrollback : Nil #

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


[View source]
def 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.


[View source]
def 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.


[View source]
def scrollback : Deque(Array(Cell)) #

Rows that have scrolled off the top, oldest first.


[View source]
def scrollback_capacity : Int32 #

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


[View source]
def scrolled_back? : Bool #

Whether the region is showing history rather than live content.


[View source]
def to_s(io : IO) : Nil #
Description copied from class Reference

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>

[View source]
def view_offset : Int32 #

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.


[View source]
def view_offset=(value : Int32) : Int32 #

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


[View source]