More rigourous definition of mode

This prevents interactive mode frames and logs being sent during raw
mode.
This commit is contained in:
Thomas Buckley-Houston 2018-06-23 18:11:33 +08:00
parent 70d3f45f60
commit b2f1315c11
3 changed files with 21 additions and 5 deletions

View file

@ -151,6 +151,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
_acknowledgeNewTab(native_tab_object) { _acknowledgeNewTab(native_tab_object) {
let tab = this._applyUpdates(native_tab_object); let tab = this._applyUpdates(native_tab_object);
tab._is_raw_text_mode = this._is_raw_text_mode;
tab.postDOMLoadInit(this.terminal, this.dimensions); tab.postDOMLoadInit(this.terminal, this.dimensions);
} }

View file

@ -11,7 +11,7 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
// The maximum amount of times to try to recover a tab that won't connect // The maximum amount of times to try to recover a tab that won't connect
this._max_number_of_tab_recovery_reloads = 3; this._max_number_of_tab_recovery_reloads = 3;
// Type of raw text mode; HTML or plain // Type of raw text mode; HTML or plain
this.raw_text_mode = ''; this.raw_text_mode_type = '';
} }
postDOMLoadInit(terminal, dimensions) { postDOMLoadInit(terminal, dimensions) {
@ -24,8 +24,16 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
this.channel = channel; this.channel = channel;
this._sendTTYDimensions(); this._sendTTYDimensions();
this._listenForMessages(); this._listenForMessages();
let mode = 'interactive'; this._calculateMode();
if (this.raw_text_mode !== '') { mode = this.raw_text_mode } }
_calculateMode() {
let mode;
if (!this._is_raw_text_mode) {
mode = 'interactive';
} else {
mode = this.raw_text_mode_type;
}
this.channel.postMessage(`/mode,${mode}`); this.channel.postMessage(`/mode,${mode}`);
} }
@ -110,7 +118,12 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
} }
setMode(mode) { setMode(mode) {
this.raw_text_mode = mode; this.raw_text_mode_type = mode;
// Send it here, in case there is a race condition with the postCommsInit() not knowing
// the mode.
if (this._is_raw_text_mode) {
this.channel.postMessage(`/mode,${mode}`);
}
} }
_listenForMessages() { _listenForMessages() {

View file

@ -44,7 +44,7 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
} }
sendAllBigFrames() { sendAllBigFrames() {
if (this._is_raw_mode) { return } if (!this._is_interactive_mode) { return }
if (!this.dimensions.tty.width) { if (!this.dimensions.tty.width) {
this.log("Not sending big frames without TTY data") this.log("Not sending big frames without TTY data")
return return
@ -66,6 +66,7 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
} }
sendSmallPixelFrame() { sendSmallPixelFrame() {
if (!this._is_interactive_mode) { return }
if (!this.dimensions.tty.width) { if (!this.dimensions.tty.width) {
this.log("Not sending small frames without TTY data") this.log("Not sending small frames without TTY data")
return; return;
@ -76,6 +77,7 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
} }
sendSmallTextFrame() { sendSmallTextFrame() {
if (!this._is_interactive_mode) { return }
if (!this.dimensions.tty.width) { if (!this.dimensions.tty.width) {
this.log("Not sending small frames without TTY data") this.log("Not sending small frames without TTY data")
return; return;