webterm: update slog handling for new formats

Secretly, [data.slog] here implies the entire slog text to be a single
semantic character. But this kind of detail isn't present in the slog
event, and can't be trivially reconstructed, so we're fine with this.
This commit is contained in:
fang 2020-11-11 20:59:45 +01:00
parent 86f048d3b6
commit 32e1235edb
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
2 changed files with 12 additions and 1 deletions

View File

@ -18,6 +18,16 @@ export default class Store {
}
handleEvent(data) {
// process slogs
//
if (data.slog) {
this.state.lines.splice(this.state.lines.length-1, 0, {lin: [data.slog]});
this.setState({ lines: this.state.lines });
return;
}
// process blits
//
const blit = data.data;
switch (Object.keys(blit)[0]) {
case 'bel':
@ -31,6 +41,7 @@ export default class Store {
// since lines are lists of characters that might span multiple
// codepoints, we need to calculate the byte-wise cursor position
// to avoid incorrect cursor rendering.
//
let line = this.state.lines[this.state.lines.length - 1];
let hops;
if (line.lin) {

View File

@ -27,7 +27,7 @@ export default class Subscription {
}
slog.onmessage = e => {
this.handleEvent({ txt: e.data });
this.handleEvent({ slog: e.data });
}
slog.onerror = e => {