delta10762%python.module
fault.syntax

Element change logs for managing deltas, undo, and redo.

itertools
import

Protocol0
import

struct0
import

Summary0
class

Interface for communicating changes to lines and codepoints.

Used by Log.track to communicate change summaries for cursor motion and view stabilization.

SummaryEngineering

Implementing this using an abstraction that received changes the same way that a log's storage target does was not entirely trivial. Line deltas could be easily summarized, but reconstructing the codepoint deltas from Update.apply's usage required multiple levels of reconstruction.

Creating an explicit protocol is somewhat undiresable, but using an abstraction that required such tight coupling to Update.apply's implementation appeared inferior. Additionally, this provides a relevant location for checkpoint or commit reporting given the need.

Summaryline_delta10%
method

line_delta(self, ln_offset, deleted, inserted)

Report that lines were deleted and inserted at ln_offset.

Summarycodepoint_delta10%
method

codepoint_delta(self, ln_offset, cp_offset, deleted, inserted)

Report that codepoints were deleted and inserted at cp_offset in the line identified by ln_offset.

Record0
class

An indvidial record of change.

Recordspan10%
property

The element offset and count of elements that were changed.

Recordchange10%
property

The change in the elements' length that occurred. Length of insertions minus length of deletions.

Recordusage20%
method

usage(self)

Memory usage of the record. The given count will measure an object's size if it hasn't already been seen.

Recordsize10%
method

size(self, encoding)

Change in bytes of the target resource after the record is applied.

Recordinvert10%
method

invert(self)

Construct the version of the record that reverses the effect of the change.

Recordrevert10%
method

revert(self)

Reconstruct self to perform an ineffective operation.

Recordtrack10%
method

track(self, target)

Communicate the change to target.

Recordapply10%
method

apply(self, target)

Perform the change to the given target.

Recordretract150%
method

retract(self, target)

Perform the inverse, restoring the target to the state that it was in prior to apply being performed.

Checkpoint0
class

A no-op change holding a creation timestamp.

Used to delimit Record groups for Log.undo and Log.redo.

Checkpointchange
property

Checkpointspan10%
property

Checkpointelement
data

element = None

Checkpointinsertion
data

insertion = None

Checkpointdeletion
data

deletion = None

Checkpointusage0
method

usage(self)

Checkpointinvert0
method

invert(self)

Checkpointtrack10%
method

track(self, target)

Checkpointapply0
method

apply(self, target)

Checkpointretract10%
method

retract(self, target)

Checkpointrevert10%
method

revert(self)

Checkpointcombine233%
method

combine(self, following)

Update0
class

Individual record update.

Updatechange10%
property

Change in elements. Always zero for Update.

Updatespan10%
property

Updateusage0
method

usage(self)

Updatesize10%
method

size(self, encoding)

Updateinvert0
method

invert(self)

Recreate the record where insertion and deletion are swapped.

Updatetrack70%
method

track(self, target)

Updateapply0
method

apply(self, target)

Updateretract40%
method

retract(self, target)

Updaterevert60%
method

revert(self)

Updatecombine770%
method

combine(self, following)

Construct a new Update instance by combining self with following. None when following cannot be combined with self.

Lines0
class

Insertion and/or deletion of zero or more elements.

Lineschange10%
property

Linesspan166%
property

Linesusage0
method

usage(self)

Linessize175%
method

size(self, encoding)

Linesinvert0
method

invert(self)

Recreate the record where insertion and deletion are swapped.

Linestrack70%
method

track(self, target)

Linesapply0
method

apply(self, target)

Linesretract340%
method

retract(self, target)

Linesrevert60%
method

revert(self)

Linescombine0
method

combine(self, following)

Cursor0
class

Change

Cursorchange10%
property

Cursorspan166%
property

Cursorusage0
method

usage(self)

Cursorsize0
method

size(self, encoding)

Cursorinvert20%
method

invert(self)

Recreate the record where insertion and deletion are swapped.

Cursortrack80%
method

track(self, target)

Cursorapply166%
method

apply(self, target)

Cursorretract166%
method

retract(self, target)

Cursorcombine
method

combine(self, following)

Log0
class

The Record vector tracking the changes.

Log__init__0
method

__init__(self)

Logrevert30%
method

revert(self, target)

Retract all committed changes on target.

Logtruncate0
method

truncate(self)

Logsize20%
method

size(self, encoding)

Total size of the logged changes.

Logusage271%
method

usage(self)

Logsnapshot0
method

snapshot(self)

Construct a reference to the current version.

Logsince378%
method

since(self, snapshot)

Generate a sequence of changes since version.

Logwrite0
method

write(self, record)

Append a delta to the log.

Logpending20%
method

pending(self)

Return the uncommitted deltas.

Logtrack40%
method

track(self, target)

Update target by reporting the change summaries.

Logapply0
method

apply(self, target)

Update target by applying the current transaction.

Logretract40%
method

retract(self, target)

Update target by previously applied retracting records.

Logcollapse286%
method

collapse(self)

Commit the leading deltas of the current transaction by combining records.

Primarily intended to eliminate successive character insertions and deletions when typing in insert mode.

Logcommit0
method

commit(self)

Update the commit position. Normally called directly after apply.

Logabort40%
method

abort(self)

Remove any records written since committed and update count to reflect the new records state.

Not normally used as deleting records will likely cause display inconsistencies. In most cases, undo should be used.

Logcheckpoint277%
method

checkpoint(self)

Write a checkpoint clearing any uncommitted writes.

Logundo0
method

undo(self)

Retract delta records effecting target until the given quantity of checkpoints have been traversed or the beginning of the log has been reached.

Logredo193%
method

redo(self, target)

Replay delta records effecting target until the given quantity of checkpoints have been traversed or the end of the log has been reached.