-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BufferLine rewrite [WIP] #4928
Open
PerBothner
wants to merge
69
commits into
xtermjs:master
Choose a base branch
from
PerBothner:buffer-cell-cursor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
BufferLine rewrite [WIP] #4928
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The new data structure is more flexible and more compact. However, mapping column number to cell information is no longer O(1). So we use a cursor as much as possible to reduce the need for that. This is an early check-in to have a backup and baseline. A few basic things work but it is NOT READY FOR USE.
Fix some bugs. Add simple grapheme support.
- Store character values in _data array. Get rid of _text string. (In progress.) This is likely to be faster. - Add a cache in BufferLine for the current position. (In progress.) - Re-implement loadCell to use above cache. - Revert DOM renderer to use laodCell. (webgl and canvas renderer s still to do.)
Replace fg, bg, and eAttrs parameters by single IAttributeData parameter. In addition to making for a simpler/cleaner API, it also increases flexibility for future CellData or BufferLine changes. (Rename function to reduce risk of using accidentally using old function.) Also removed redundant eraseAttr parameter in deleteCells, insertCells, and replaceCells.
Also add some optimizations.
Using the per-BufferLine cache in loadCell should make this reasonably performant.
InputHandler.print just calls insertText, without a loop. (WIP)
Use it in insertText and deleteCells.
Get rid of some old cursor stuff in favor of buffer-local cache.
Controlled by USE_NewBufferLine variable
(Still a bug with extra lines sometimes being added.)
New classes LogicalBufferLine and WrappedBufferLine.
This reflows the lines and calculates WrapperBufferLine offsets. It does *not* yet handle updating y, ybase, ydist, calling onDeleteEmitter handler, and similar tasks.
New CellData.fromChar method intended to replace CellData.fromCharData. Fix logic errors in erasecells and deletecellsOnly. Fixes to InputHandler.print when wrapping - still needs work. Change _cachedStyleFlagsIndex so -1 (not 0) is "none".
Also extended-underline testcase.
Handle soft line breaks in the middle of SKIP_COLUMNS. Change showData to take columns bounds rather than data index bounds.
This reverts commit 8b23f24.
This method (now only used for testing) fixes 4 test-cases.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements #4800. It also sort-of implements #4232 - it does reflow lazily, though it doesn't specifically use the "idle callbacks". Motivation is described in #4800; however, the implementation is different (though the same basic idea).
The
NewBufferLine
implementation is enabled if thenewBufferLine
option is true; otherwise the old implementation (renamed toOldBufferLine
) is used. The goal is to merge the PR withnewBufferLine
defaulting to false to avoid breaking things, but allowing adventurous users and developers to trynewBufferLine
set to true. (Some more testing will be needed even for thenewBufferLine
false case; I believe there are regressions.)Note that
NewBufferLine
is abstract and has two implementation classes:LogicalBufferLine
represents an unwrapped line, but it also contains the data for following wrapped lines.WrappedBufferLine
represents a wrapped line (duh) and basically just indirects to the previousLogicalBufferLine
.Operations that are O(1) in
OldBufferLine
may require linear scanning inNewBufferLine
. However,LogicalBufferLine
has a cache (mapping column index to_data
array index) to avoid linear scanning for common operations. There is some needless overhead in the interest of minimizing API changes.Later, the
newBufferLine
default will change to true. Later still, we will remove the support forOldBufferLine
andNewBufferLine
will be renamed to plainBufferLine
.The
AbstractBufferLine
class is intended as a parent for both[New]BufferLine
and future classes for "other" content. Specifically, general HTML "paragraphs" (<div>
elements) are planned.Tasks that must be done before merger:
oldBufferLine
regressions. (Minor barely-measurable performance regressions may be OK.)Tasks that must be done before defaulting to
newBufferLine
true:IExtendedAttrs
handling is incomplete (though basic data structure support is there).image
addon doesn't work. It uses custom classes that textually copy the old classes.