class TextBuffer
- TextBuffer
- Reference
- Object
Overview
TextBuffer
is an abstraction over a string and an array
of line bounds (see Line
) in that string. These bounds are
recomputed after every #update
(e.g. on every keystroke).
The latter is done as quickly as possible, so there is little performance penalty in exchange for great ease-of-use.
Defined in:
aspis/buffer.crConstant Summary
-
AVG_CPL =
40
-
Characters per line, on average. A heuristic used to pre- allocate the line array.
-
WORDSTOP =
"`~!@#$%^&*()-=+[{]}|;:'\",.<>/?"
-
Non-whitespace characters that terminate word boundary search.
Constructors
Instance Method Summary
-
#==(other : self)
Two buffers are equal if their strings are equal.
-
#[](index : Int)
Returns the index-th character in this buffer.
-
#hash(hasher)
Two buffers are equal if their strings are equal.
-
#line(index : Int)
Returns the index-th line, or raises.
-
#line?(index : Int)
Returns the index-th line, or nil.
-
#line_at(index : Int)
Returns the line at the given character index, or raises.
-
#line_at?(index : Int)
Returns the line at the given character index, or nil.
-
#lines
Returns the amount of lines in this buffer.
-
#size(*args, **options)
Returns the amount of characters in this buffer.
-
#size(*args, **options, &)
Returns the amount of characters in this buffer.
-
#slice(b : Int, e : Int)
Slices this buffer from begin index to end index.
-
#update(string : String, lineno = 0)
Sets buffer string to string.
-
#update(lineno = 0, &)
Yields buffer string to the block.
-
#word_begin_at(index : Int)
Finds word begin position by going back as far as possible, stopping either on word stop characters
WORDSTOP
or the first whitespace. -
#word_end_at(index : Int)
Find end position by going forth as far as possible, stopping either on word stop characters or the first whitespace.
Constructor Detail
Instance Method Detail
Slices this buffer from begin index to end index. Both ends are included.
Yields buffer string to the block. Updates buffer string with block result.
Finds word begin position by going back as far as possible,
stopping either on word stop characters WORDSTOP
or the
first whitespace.
Find end position by going forth as far as possible, stopping either on word stop characters or the first whitespace.