As discussed in #96 and #97, Buildkite timestamps (<ESC>_bk;t=123456<BEL>) were corrupting virtual terminal X position when moving the cursor backwards through them (“CUB”: <ESC>[<distance>D). This is because they occupied a position on the terminal intermediate representation X,Y grid, and parsing/appending them incremented the internal X-position state. Buildkite timestamps should generally only appear at the start of lines, where this isn't a problem, but certain ANSI sequences cause buildkite/agent to place them mid-line.
This pull request introduces a “line metadata” structure, supporting namespaced key:value data attached to entire lines. For example the Buildkite APC <ESC>_bk;t=1234<BEL> places t→1234 under the bk namespace. Subsequent _bk;t APCs on the same line are ignored. The bk namespace is then rendered as <?bk t="1234"?> prior to the line's terminal data, so it's always at the start of the line.
Some refactoring to achieve that:
_bk data is no longer represented as a subtype of struct element, but as metadata map[string]map[string]string on a new struct screenLine which wraps the bare []node that previously represented a line.
A new screen.setnxLineMetadata() method, with a Redis-inspired name indicating that it only sets keys that don't already exist.
screen.getCurrentLineForWriting() *screenLine replaces the previous growScreenHeight() and growLineWidth() since those were always used in conjunction to prepare for writing data that might be out of existing bounds, and this was also required prior to adding _bk;t metadata to a new line.
rendering <?bk …?> to HTML is separated out of the rendering of struct element because it's no longer one of those.
As discussed in #96 and #97, Buildkite timestamps (
<ESC>_bk;t=123456<BEL>
) were corrupting virtual terminal X position when moving the cursor backwards through them (“CUB”:<ESC>[<distance>D
). This is because they occupied a position on the terminal intermediate representation X,Y grid, and parsing/appending them incremented the internal X-position state. Buildkite timestamps should generally only appear at the start of lines, where this isn't a problem, but certain ANSI sequences cause buildkite/agent to place them mid-line.This pull request introduces a “line metadata” structure, supporting namespaced key:value data attached to entire lines. For example the Buildkite APC
<ESC>_bk;t=1234<BEL>
placest
→1234
under thebk
namespace. Subsequent_bk;t
APCs on the same line are ignored. Thebk
namespace is then rendered as<?bk t="1234"?>
prior to the line's terminal data, so it's always at the start of the line.Some refactoring to achieve that:
_bk
data is no longer represented as a subtype ofstruct element
, but asmetadata map[string]map[string]string
on a newstruct screenLine
which wraps the bare[]node
that previously represented a line.screen.setnxLineMetadata()
method, with a Redis-inspired name indicating that it only sets keys that don't already exist.screen.getCurrentLineForWriting() *screenLine
replaces the previousgrowScreenHeight()
andgrowLineWidth()
since those were always used in conjunction to prepare for writing data that might be out of existing bounds, and this was also required prior to adding_bk;t
metadata to a new line.<?bk …?>
to HTML is separated out of the rendering ofstruct element
because it's no longer one of those.This PR is currently based on some other more minor refactoring that was extracted from a previous approach that I don't want to merge.
Related:
98