class

TermBuf::Input::Pattern

Inherits Reference < Object

A sequence the application is interested in, and what to make of one.

This exists because a reply and a keystroke are not distinguishable by looking at them. An arrow key sends ESC [ A; so could a terminal. The only thing that separates them is that the application asked for one and not the other, which is what registering a pattern records.

The handler returning nil means "not mine after all", so a pattern that can only tell from the body whether it wants a sequence can let it carry on to the next pattern and, failing that, to the key decoder.

Constructors

new(prefix : Prefix, head : String = "", terminator : String | Nil = nil, &handler : Sequence -> Event | Nil)
Source

Instance methods

call(sequence : Sequence) : Event | Nil

What this pattern makes of sequence, or nil if it turns out not to want it.

Source
head

What has to come straight after the introducer, such as "?" for a mode report or "<" for an SGR mouse report. Empty matches anything.

Source
matches?(sequence : Sequence) : Bool

Whether sequence has this pattern's shape, which is as far as the bytes go; whether it is really this pattern's is up to the handler.

Source
prefix

Which introducer this is about.

Source
terminator

What has to come at the end, such as "$y" or "\e\\". nil matches anything.

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