Manages a collection of lines (the raw text) plus related text operations like insert, delete, and substring extraction.
More...
|
|
| TextBuffer () |
| | Create an empty text buffer.
|
| void | setText (std::string_view text) |
| | Replace the entire buffer with new text.
|
|
std::string | getText () const |
| | Get the entire text buffer as a single string, joined by newlines.
|
|
std::string | getText (const Coordinates &start, const Coordinates &end) const |
| | Get the text in [start, end), inclusive of start and exclusive of end, or adapt as needed for your coordinate conventions.
|
| const Line & | getLineGlyphs (int line) const |
| | Get the text in a given line.
|
| Line & | getLineGlyphsMutable (int line) |
| | Get the text in a given line.
|
| int | insertTextAt (Coordinates &where, std::string_view text, bool indent=false) |
| | Insert text at a given position.
|
| void | deleteRange (const Coordinates &start, const Coordinates &end) |
| | Remove text in [start, end).
|
| Line & | insertLine (int index, int column=0) |
| | Insert an empty line at index, or optionally split at a column in an existing line.
|
|
void | removeLine (int index) |
| | Remove a single line at the given index if valid.
|
|
void | removeLine (int start, int end) |
| | Remove lines in the range [start, end).
|
| int | getLineMaxColumn (int line) const |
| | Query the max column index of a given line (i.e.
|
|
int | getLineCharacterCount (int line) const |
| | Query how many characters (glyphs) are on a given line.
|
|
int | getCharacterIndex (const Coordinates &coords) const |
| | Convert (line, column) to the internal character index within its line.
|
| int | getCharacterColumn (int line, int index) const |
| | Given a line and character index within that line, return the 'visual' column.
|
| std::size_t | getByteOffset (const Coordinates &coords) const |
| | Resolve a coordinate to a byte offset in the full buffer text.
|
| Coordinates | getCoordinatesAtByteOffset (std::size_t offset) const |
| | Resolve a full-buffer byte offset to editor coordinates.
|
|
int | getTotalLines () const |
| | The total number of lines in the buffer.
|
Manages a collection of lines (the raw text) plus related text operations like insert, delete, and substring extraction.
Remove text in [start, end).
Merges lines if needed.
Example:
If you remove 'Line0' entirely, you'd pass start.column=0 and end.column=5. If you want to remove multi-line, for example removing 0Lin, pass start (0,4) and end (1,3).
- Parameters
-
| start | The start of the range to remove (inclusive). |
| end | The end of the range to remove (exclusive). |