-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
3,111 additions
and
1,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
import stripAnsi from 'strip-ansi'; | ||
import stripAnsi from "strip-ansi"; | ||
|
||
// Here we keep the public functions used to mediate communications between | ||
// the background process, tabs and the terminal. | ||
export default (MixinBase) => class extends MixinBase { | ||
sendToCurrentTab(message) { | ||
if (this.currentTab().channel === undefined) { | ||
this.log(`Attempting to send "${message}" to tab without a channel`); | ||
} else { | ||
this.currentTab().channel.postMessage(message); | ||
export default MixinBase => | ||
class extends MixinBase { | ||
sendToCurrentTab(message) { | ||
if (this.currentTab().channel === undefined) { | ||
this.log(`Attempting to send "${message}" to tab without a channel`); | ||
} else { | ||
this.currentTab().channel.postMessage(message); | ||
} | ||
} | ||
} | ||
|
||
sendToTerminal(message) { | ||
if (this.terminal === undefined) { return } | ||
if (this.terminal.readyState === 1) { | ||
this.terminal.send(message); | ||
sendToTerminal(message) { | ||
if (this.terminal === undefined) { | ||
return; | ||
} | ||
if (this.terminal.readyState === 1) { | ||
this.terminal.send(message); | ||
} | ||
} | ||
} | ||
|
||
log(...messages) { | ||
if (messages === undefined) { | ||
messages = "undefined"; | ||
log(...messages) { | ||
if (messages === undefined) { | ||
messages = "undefined"; | ||
} | ||
if (messages.length === 1) { | ||
messages = messages[0].toString(); | ||
messages = stripAnsi(messages); | ||
messages = messages.replace(/\u001b\[/g, "ESC"); | ||
} | ||
this.sendToTerminal(messages); | ||
} | ||
if (messages.length === 1) { | ||
messages = messages[0].toString(); | ||
messages = stripAnsi(messages); | ||
messages = messages.replace(/\u001b\[/g, 'ESC'); | ||
} | ||
this.sendToTerminal(messages); | ||
} | ||
|
||
currentTab() { | ||
return this.tabs[this.active_tab_id]; | ||
} | ||
} | ||
currentTab() { | ||
return this.tabs[this.active_tab_id]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.