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
Overwrite line metadata #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
} | ||
p.screen.setLineMetadata(bkNamespace, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇♂️
strings.Join([]string{ | ||
`<?bk t="234"?>hello world!`, | ||
`<?bk t="456"?>another line!`, | ||
}, "\n"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a test, so it's moot, but I wonder if the compiler in lines this? At least with the alternative using +
, you have this garantee: https://go.dev/ref/spec#Constant_expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't 100% sure, so I compiled a test binary and went to crack it open with Ghidra, except I don't have it installed, and it relies on the JDK. Which reminded me that Java (at some point) compiled repeated string concatenations with + into a StringBuilder
under the hood.
Anyway, I expect the answer is no. Certainly it doesn't create a single string constant.
} | ||
|
||
for i := xStart; i <= xEnd && i < len(line.nodes); i++ { | ||
line.nodes[i] = emptyNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
What timestamp should a rewritten line have?
I argue we should replace old line metadata with new metadata. This will make timestamps look more sensible in
ESC [1A ESC [K
-heavy output.For example, when faced with updating the existing screen (pseudo-rendered):
with a sequence like
ESC [1A ESC [K ESC _bk;t=200 BEL Completed! LF
, we currently getwhich is nonsensical from a timestamp perspective (
Completed!
actually happened at t=200).The current approach does have a benefit: assuming the timestamps are non-decreasing, it is somewhat possible to derive the "duration" of a line (assuming each line is printed at the very start of a chunk of processing). In the example above,
Commencing build...
can be inferred to take Δt = 1; ifCompleted!
has t=200, thenCommencing build...
's inferred Δt = 200, when 199 of that was actually spent starting with package enumeration. But to do this effectively requires making that assumption.I also tweaked the style of
setLineMetadata
, and implemented an optimisation forclear
.