xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.33k stars 1.61k forks source link

BufferLine rewrite [WIP] #4928

Open PerBothner opened 8 months ago

PerBothner commented 8 months ago

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 the newBufferLine option is true; otherwise the old implementation (renamed to OldBufferLine) is used. The goal is to merge the PR with newBufferLine defaulting to false to avoid breaking things, but allowing adventurous users and developers to try newBufferLine set to true. (Some more testing will be needed even for the newBufferLine false case; I believe there are regressions.)

Note that NewBufferLine is abstract and has two implementation classes:

Operations that are O(1) in OldBufferLine may require linear scanning in NewBufferLine. 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 for OldBufferLine and NewBufferLine will be renamed to plain BufferLine.

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:

Tasks that must be done before defaulting to newBufferLine true: