Skip to content

vtf textbuffer ChunkBuffer

srccircumflex edited this page Jan 6, 2023 · 3 revisions

↑ vtf-textbuffer

buffer

class buffer.ChunkBuffer(TextBuffer)

[ ADVANCED USAGE ]

Create a restricted editable buffer from a chunk in memory.

>>> with ChunkBuffer(<buffer>, <position>, <do not overwrite chunk slot>, <delete chunk from swap if empty>) as cb:
>>>    cb.[...]
>>> ... # overwrites chunk and adjusts the metadata index here

Basically the methods of the TextBuffer should not be used in the ChunkBuffer to avoid recursion and data corruption. However, if methods are used, the following may raise an AttributeError, since the entries for ChunkIter and ChunkBuffer in the ChunkBuffer are deleted:

  • write (when a substitution mode is selected)
  • rowwork
  • remove
  • find
  • goto_row
  • __marker__.marked_remove
  • __local_history__.undo
  • __local_history__.redo
  • __local_history__.branch_fork

If the sandbox is not set, these following components are avalable in the ChunkBuffer but referencing to TextBuffer:

  • __marker__
  • __local_history__
  • __display__
  • __glob_cursor__

The __diffs__ and __empty__ attributes are not set until the override. __diffs__ consists of the differences of (data length, content length, row number, line number) and __empty__ indicates whether the chunk is empty after overwriting, can be None if the current buffer is loaded into a ChunkBuffer.

__chunk_pos_id__: int | None

__chunk_slot__: int | None

__diffs__: tuple[int, int, int, int]

__empty__: bool | None

strip() -> None

An empty row is automatically appended by the buffer after a line break, this method removes the row line in the buffer if it is empty.

Date: 21 Dec 2022
Version: 0.1
Author: Adrian Hoefflin [srccircumflex]
Doc-Generator: "pyiStructure-RSTGenerator" <prototype>
Clone this wiki locally