Trigger more Terminal Console "Resize". Hope it'll fix some tricky problems

This commit is contained in:
NI
2020-07-16 10:05:17 +08:00
parent 4c15c1d2f9
commit 7d2e5491d9

View File

@@ -136,7 +136,7 @@ class Term {
cursorStyle: "block", cursorStyle: "block",
fontFamily: termTypeFace + ", " + termFallbackTypeFace, fontFamily: termTypeFace + ", " + termFallbackTypeFace,
fontSize: this.fontSize, fontSize: this.fontSize,
logLevel: process.env.NODE_ENV === "development" ? "info" : "off" logLevel: process.env.NODE_ENV === "development" ? "info" : "off",
}); });
this.fit = new FitAddon(); this.fit = new FitAddon();
@@ -144,10 +144,10 @@ class Term {
this.term.loadAddon(new WebLinksAddon()); this.term.loadAddon(new WebLinksAddon());
this.term.setOption("theme", { this.term.setOption("theme", {
background: control.activeColor() background: control.activeColor(),
}); });
this.term.onData(data => { this.term.onData((data) => {
if (this.closed) { if (this.closed) {
return; return;
} }
@@ -155,7 +155,7 @@ class Term {
control.send(data); control.send(data);
}); });
this.term.onBinary(data => { this.term.onBinary((data) => {
if (this.closed) { if (this.closed) {
return; return;
} }
@@ -163,7 +163,7 @@ class Term {
control.sendBinary(data); control.sendBinary(data);
}); });
this.term.onKey(ev => { this.term.onKey((ev) => {
if (this.closed) { if (this.closed) {
return; return;
} }
@@ -201,7 +201,7 @@ class Term {
oldRows = 0, oldRows = 0,
oldCols = 0; oldCols = 0;
this.term.onResize(dim => { this.term.onResize((dim) => {
if (this.closed) { if (this.closed) {
return; return;
} }
@@ -229,7 +229,7 @@ class Term {
control.resize({ control.resize({
rows: dim.rows, rows: dim.rows,
cols: dim.cols cols: dim.cols,
}); });
resizeDelay = null; resizeDelay = null;
@@ -247,7 +247,7 @@ class Term {
this.term.textarea.addEventListener("focus", callbacks.focus); this.term.textarea.addEventListener("focus", callbacks.focus);
this.term.textarea.addEventListener("blur", callbacks.blur); this.term.textarea.addEventListener("blur", callbacks.blur);
this.term.textarea.addEventListener("keyup", async ev => { this.term.textarea.addEventListener("keyup", async (ev) => {
if (this.closed) { if (this.closed) {
return; return;
} }
@@ -431,32 +431,32 @@ export default {
tail = "</span>"; tail = "</span>";
return head + key.split("+").join(tail + "+" + head) + tail; return head + key.split("+").join(tail + "+" + head) + tail;
} },
}, },
props: { props: {
active: { active: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
control: { control: {
type: Object, type: Object,
default: () => null default: () => null,
}, },
change: { change: {
type: Object, type: Object,
default: () => null default: () => null,
}, },
toolbar: { toolbar: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
data() { data() {
return { return {
screenKeys: consoleScreenKeys, screenKeys: consoleScreenKeys,
term: new Term(this.control), term: new Term(this.control),
typeface: termTypeFace, typeface: termTypeFace,
runner: null runner: null,
}; };
}, },
watch: { watch: {
@@ -471,8 +471,8 @@ export default {
this.fit(); this.fit();
}, },
deep: true deep: true,
} },
}, },
async mounted() { async mounted() {
await this.init(); await this.init();
@@ -485,8 +485,8 @@ export default {
return Promise.all([ return Promise.all([
new FontFaceObserver(typeface).load(null, timeout), new FontFaceObserver(typeface).load(null, timeout),
new FontFaceObserver(typeface, { new FontFaceObserver(typeface, {
weight: "bold" weight: "bold",
}).load(null, timeout) }).load(null, timeout),
]); ]);
}, },
async retryLoadRemoteFont(typeface, timeout, onSuccess) { async retryLoadRemoteFont(typeface, timeout, onSuccess) {
@@ -566,15 +566,15 @@ export default {
warn(msg, toDismiss) { warn(msg, toDismiss) {
self.$emit("warning", { self.$emit("warning", {
text: msg, text: msg,
toDismiss: toDismiss toDismiss: toDismiss,
}); });
}, },
info(msg, toDismiss) { info(msg, toDismiss) {
self.$emit("info", { self.$emit("info", {
text: msg, text: msg,
toDismiss: toDismiss toDismiss: toDismiss,
}); });
} },
} }
); );
@@ -601,8 +601,8 @@ export default {
e.preventDefault(); e.preventDefault();
}, },
activate() { activate() {
this.fit();
window.addEventListener("resize", this.fit); window.addEventListener("resize", this.fit);
this.fit();
this.term.focus(); this.term.focus();
}, },
async deactivate() { async deactivate() {
@@ -657,7 +657,7 @@ export default {
}, },
fontSizeDown() { fontSizeDown() {
this.term.fontSizeDown(); this.term.fontSizeDown();
} },
} },
}; };
</script> </script>