ace2_inner: Improve rep documentation

This commit is contained in:
Richard Hansen 2021-10-02 02:02:04 -04:00
parent e42e5457c1
commit 37a33042d2

View file

@ -81,24 +81,45 @@ function Ace2Inner(editorInfo, cssManagers) {
let outsideKeyPress = (e) => true; let outsideKeyPress = (e) => true;
let outsideNotifyDirty = noop; let outsideNotifyDirty = noop;
// Document representation. /**
* Document representation.
*/
const rep = { const rep = {
// Each entry in this skip list is an object created by createDomLineEntry(). The object /**
// represents a line (paragraph) of content. * The contents of the document. Each entry in this skip list is an object representing a
* line (actually paragraph) of text. The line objects are created by createDomLineEntry().
*/
lines: new SkipList(), lines: new SkipList(),
// Points at the start of the selection. Represented as [zeroBasedLineNumber, /**
// zeroBasedColumnNumber]. * Start of the selection. Represented as an array of two non-negative numbers that point to the
// TODO: If the selection starts at the beginning of a line, I think this could be either * first character of the selection: [zeroBasedLineNumber, zeroBasedColumnNumber]. Notes:
// [lineNumber, 0] or [previousLineNumber, previousLineLength]. Need to confirm. * - There is an implicit newline character (not actually stored) at the end of every line.
* Because of this, a selection that starts at the end of a line (column number equals the
* number of characters in the line, not including the implicit newline) is not equivalent
* to a selection that starts at the beginning of the next line. The same goes for the
* selection end.
* - If there are N lines, [N, 0] is valid for the start of the selection. [N, 0] indicates
* that the selection starts just after the implicit newline at the end of the document's
* last line (if the document has any lines). The same goes for the end of the selection.
* - If a line starts with a line marker, a selection that starts at the beginning of the line
* may start either immediately before (column = 0) or immediately after (column = 1) the
* line marker, and the two are considered to be semantically equivalent. For safety, all
* code should be written to accept either but only produce selections that start after the
* line marker (the column number should be 1, not 0, when there is a line marker). The same
* goes for the end of the selection.
*/
selStart: null, selStart: null,
// Points at the character just past the last selected character. Same representation as /**
// selStart. * End of the selection. Represented as an array of two non-negative numbers that point to the
// TODO: If the last selected character is the last character of a line, I think this could be * character just after the end of the selection: [zeroBasedLineNumber, zeroBasedColumnNumber].
// either [lineNumber, lineLength] or [lineNumber+1, 0]. Need to confirm. * See the above notes for selStart.
*/
selEnd: null, selEnd: null,
// Whether the selection extends "backwards", so that the focus point (controlled with the arrow /**
// keys) is at the beginning. This is not supported in IE, though native IE selections have that * Whether the selection extends "backwards", so that the focus point (controlled with the arrow
// behavior (which we try not to interfere with). Must be false if selection is collapsed! * keys) is at the beginning. This is not supported in IE, though native IE selections have that
* behavior (which we try not to interfere with). Must be false if selection is collapsed!
*/
selFocusAtStart: false, selFocusAtStart: false,
alltext: '', alltext: '',
alines: [], alines: [],