Skip to content

vtf txb _buffercomponents items

srccircumflex edited this page Apr 24, 2023 · 4 revisions

↑ vtf-txb-_buffercomponents

items

The module contains items used by the TextBuffer and its _buffercomponents for data management.

Objects

class items.ChunkData(NamedTuple)

A chunk data item created by the _Swap when querying a slot and contains the content and metadata of a chunk. Is used internally by the swap as parameterization for _load_chunk.

The attributes starting with start_point_* each store the starting points of the chunk data in relation to the total data. nrows indicates how many _Row's are stored in the chunk and nnl how many line breaks (non-breaking and real).

The rows are stored in a list of ( <content>, <end of row> ), the end of a row is defined as 0 if the row has no line break, a line break or non-breaking line break is specified as 1 or 2.

nnl: int

nrows: int

rows: list[tuple[str, 0 | 1 | 2]]

slot_id: int

start_point_content: int

start_point_data: int

start_point_linenum: int

start_point_row: int

class items.ChunkLoad(NamedTuple)

An object of information about the processing on the _Swap. The general values top_id and btm_id are always set as integer when a swap is in use, otherwise they are _NullComponent. The other values are called work values.

item-index work-step-index name type description
0 0 top_id : int | <_NullComponent> -- The id of the upper chunk before working on swap.
1 0 btm_id : int | <_NullComponent> -- The id of the lower chunk before working on swap.
2 4 top_cut : list[list[ _Row ]] | None -- Cut rows from the top of the buffer.
3 4 btm_cut : list[list[ _Row ]] | None -- Cut rows from the bottom of the buffer.
4 3 top_nload : int | None -- Numer of loaded chunks to the top.
5 3 btm_nload : int | None -- Numer of loaded chunks to the bottom.
6 2 spec_position : int | None -- The position id of a specific loaded chunk.
7 1 edited_ran : tuple[int | None, int | None] | None -- The first and last position id of chunks (None means the current buffer) edited within the database slot (inplace).

bool(chunk_load) -> whether a work value is not None

class items.ChunkMetaItem

A memory unit for metadata of a chunk stored in _Swap.

The attributes starting with start_point_ each store the starting points of the chunk data in relation to the total data. nrows indicates how many _Row's are stored in the chunk and nnl how many line breaks (non-breaking and real).

nnl: int

nrows: int

start_point_content: int

start_point_data: int

start_point_linenum: int

start_point_row: int

class items.DumpData(NamedTuple)

An item for cut data from the buffer. Is created by the _Trimmer and can be processed by _Swap. From which side the data was cut is defined as 0 (above the currently loaded data in the buffer) or 1 (below).

rows: list[_Row]

side: Literal[0, 1]

start_point_content: int

start_point_data: int

start_point_linenum: int

start_point_row: int

db_rows() -> list[tuple[str, int]]

Converts the rows stored in the item for SQL parameterization.

Format: [ ( <content>, <end of row> ), ...]; the end of an row is defined as 0 if the row has no line break, a line break or non-breaking line break is specified as 1 or 2.

staticmethod rows_to_db_format(rows) -> list[tuple[str, int]]

Converts rows for parameterization of SQL.

Format: [ ( <content>, <end of row> ), ...]; the end of an row is defined as 0 if the row has no line break, a line break or non-breaking line break is specified as 1 or 2.

class items.HistoryItem(NamedTuple)

An item to store a chronological progress, created by _add_* methods in _LocalHistory. Is used internally by _LocalHistory as parameterization for _dump and _do.

item-index name type description
0 id_ : int -- Chronological position, is negative for redo items.
8 order_ : int = None -- Chronological order for united actions.
1 type_ : int -- Action type.
2 typeval : int -- Action value, subset of type_.
3 work_row : int = None -- (( Action data and information ))
4 coord : list[list[int, int]] | list[int] | list[int, int] = None -- (( Action data and information ))
5 removed : list[list[str, "" | "\n" | Literal[False] | None]] = None -- (( Action data and information ))
6 restrict_removed : list[list[str, "" | "\n" | Literal[False] | None]] | str = None -- (( Action data and information ))
7 cursor : int = None -- (( Action data and information ))

Assemblies:

  • type_ = -8 : [ restrict removement ]

    Created only by the restrictive morph of _Trimmer. Saves the data removed by the mode.

    • order_: Is always at least -1 or lower, because even if unification is not active, a second entry is made in the database for the action.
    • restrict_removed: The removed data. Only set in undo items. Is always a literal when the item is read from the database; is only parsed within the processing by an interface in the _Trimmer.
    • cursor: Is set only in redo-items and specifies the order-id of the associated chronological item.
  • type_ = -2 : removed range

    Storage of a remote area. Can also be created within the undo/redo process as a result of the counter action.

    • removed: The removed data.
    • cursor: The data start position.
  • type_ = -1 : removed

    Created in consequence of characters removed one by one and can be held inside _LocalHistory for extension.

    • typeval = -2: deleted
    • typeval = -1: backspaced
    • typeval = -12: deleted newline
    • typeval = -11: backspaced newline
    • coord: The start position stored in mutable type.
    • removed: The removed data.
    • work_row: The line number in which was removed.
  • type_ = 0 : cursor

    Used for special cursor operations.

    • typeval: Is always 0.
    • cursor: The position.
  • type_ = 1 : written

    Memory for write actions. Except of type values -16 and -8, items are held for extensions by _LocalHistory.

    • typeval = -16 : removed

      Created when the write process has removed data only (for example tab-backshift).

      • coord: The start position stored in mutable type (standardization).
      • removed: The removed data.
      • work_row: The row number in which was removed.
    • typeval = -8 : line substituted

      Will be created for line substitutions.

      • coord: The start and end position of written characters.
      • removed: The removed data.
      • work_row: The row number in which the substitution has started.
    • typeval = -4 : substituted

      Created for character substitutions.

      • coord: The start and end position of written characters.
      • removed: The removed data.
      • work_row: The row number in which the substitution has started.
      • [ restrict_removed ]: Is only present in held items for extensions and only when the _Trimmer is active in restrictive morph; is entered separately when the transit to the database is made.
    • typeval = 1 : written

      Storage of simple write actions.

      • coord: The start and end position of written characters.
      • work_row: The row number in which was written.
      • [ restrict_removed ]: Is only present in held items for extensions and only when the _Trimmer is active in restrictive morph; is entered separately when the transit to the database is made.
    • typeval = 2 : has newline

      Storage of simple write actions with line breaks.

      • coord: The start and end position of written characters.
      • work_row: The row number in which was written.
      • [ restrict_removed ]: Is only present in held items for extensions and only when the _Trimmer is active in restrictive morph; is entered separately when the transit to the database is made.
  • type_ = 2 : rewritten

    Created within undo and redo actions.

    • typeval = -32: re-substitution

      Undone substitution.

      • coord: The start and end position of written characters.
      • work_row: The row number in which the substitution has started.
    • typeval = 4: rewrite

      Simple rewrite.

      • coord: The start and end position of written characters.
      • work_row: The line number in which the writing was started.
  • type_ = 4 : marks

    Saving of current marker coordinates before editing. Always all markers are entered. The type values for this type are only comments and are not relevant for redo and undo.

    • typeval = -105: removed by adjust
    • typeval = -103: pop
    • typeval = -102: conflicts with input
    • typeval = -101: lapping
    • typeval = -100: marker purged
    • typeval = 100: new mark added
    • typeval = 101: external adding
    • typeval = 126: undo/redo
    • coord: The markings as a list of areas.
    • cursor: Is optionally set to automatically set the cursor after undo/redo.
  • type_ = 32 : metadata (intern)

    Created internally by _LocalHistory to store object data for a branch in branch forking mode. Cannot be reached by Undo and Redo.

    • id_: Is always 0.

class items.TYPES

Types values containers.

RESTRICT_REMOVEMENT = -8

REMOVE_RANGE = -2

REMOVE = -1

CURSOR = 0

WRITE = 1

RE_WRITE = 2

MARKS = 4

BRANCH_METADATA = 32

class items.TYPEVALS

Types sub-values container.

RE_SUBSTITUTION = -32

W_REMOVE = -16

DELETED_NEWLINE = -12

BACKSPACED_NEWLINE = -11

LINE_SUBSTITUTED = -8

SUBSTITUTED = -4

DELETE = -2

BACKSPACE = -1

POSITION = 0

WRITE = 1

W_HAS_NEWLINE = 2

RE_WRITE = 4

class items.MARKERCOMMENTS

Types sub-values of the marker comments.

REMOVED_BY_ADJUST = -105

POP = -103

INPUT_CONFLICT = -102

LAPPING = -101

PURGED = -100

NEW_MARKING = 100

EXTERNAL_ADDING = 101

UNDO_REDO = 126

classmethod from_db(dbrow) -> HistoryItem

Create the item from a db row.

class items.WriteItem(NamedTuple)

An object with information and follow-up parameterization for processing _Row data.

item-index name type description
0 write : int -- The string length of the entered data.
1 newlines : bool -- Whether a line break is written.
2 write_rows : int | None -- The number of lines processed (not mandatory coinciding with the number of line breaks).
3 begin : int -- The total position in the data at which writing was started.
4 work_row : int -- The row number at which writing was started.
5 deleted : int -- The number of characters removed from the row during an edit.
6 removed : str | None -- The data of the row removed during an edit.
7 removed_end : str | None -- The end removed from the row. If it is None, none has been removed, otherwise it can be "" for a non-breaking or "\n" for an ordinary line break.
8 diff : int -- The difference in the row after writing.
9 overflow : WriteItem.Overflow | None -- Overflow object for the parameterization of the subsequent processing by TextBuffer.

class items.Overflow(NamedTuple)

Overflow object for the parameterization of the subsequent processing (element of WriteItem).

item-index name type description
0 lines : list[str] -- Overflowing data (is processed in place, the list is thus finally empty).
1 end : None | str -- Overflowing line break ("" for a non-breaking or "\n" for an ordinary line break) or None.
2 substitution : bool -- Whether to process the overflow in substitution mode.
3 nbnl : bool -- Whether to write non-breaking line breaks.
4 len : int -- The length of the overflow without overflowing line break.

len(overflow) -> The total length (incl. line break).


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