Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onExit(callback) {
ipc.on(`pty-exit-${this.id}`, callback)
return new Disposable(() => {
ipc.removeListener(`pty-exit-${this.id}`, callback)
})
}
bindListeners() {
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
}
}
bindListeners() {
this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
}
}
bindListeners() {
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
this.addSubscription(new Disposable(
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
))
}
}
bindListeners() {
this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
}
}
bindListeners() {
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
}
}
bindListeners() {
const boundChanger = this.handleDarkModeChange.bind(this)
ipc.on('dark-mode-changed', boundChanger)
this.addSubscription(
new Disposable(() => ipc.removeListener('dark-mode-changed', boundChanger))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
this.addSubscription(new Disposable(
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
this.webLinksAddon = new WebLinksAddon((event, uri) => {
if (document.querySelector('webview')) {
document.querySelector('webview').remove()
}
if (platform({macos: event.metaKey, default: event.ctrlKey})) {
const webview = document.createElement('webview')
webview.setAttribute('src', uri)
document.querySelector('body').append(webview)
}
})
this.xterm.loadAddon(this.webLinksAddon)
this.xterm.attachCustomKeyEventHandler(this.keybindingHandler)
ipc.on(`pty-data-${this.id}`, this.writePtyData)
this.subscriptions.add(new Disposable(() => {
ipc.removeListener(`pty-data-${this.id}`, this.writePtyData)
}))
this.subscriptions.add(this.onData(data => {
ipc.send(`pty-write-${this.id}`, data)
}))
this.subscriptions.add(this.onTitle(this.setTitle))
this.subscriptions.add(this.onFocus(this.fit))
this.subscriptions.add(this.onFocus(this.resetBlink))
this.subscriptions.add(this.onSelection(this.copySelection))
this.subscriptions.add(new Disposable(ipc.answerMain('active-profile-changed', this.onActiveProfileChange)))
this.subscriptions.add(new Disposable(ipc.answerMain('setting-changed', this.onSettingChanged)))
}
}
bindListeners() {
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', this.closeViaMenu))
)
ipc.on('close-via-menu', this.closeViaMenu)
this.addSubscription(new Disposable(ipc.answerMain('split', this.split)))
this.addSubscription(new Disposable(ipc.answerMain('new-tab', this.addTab)))
this.addSubscription(new Disposable(ipc.answerMain('search-next', this.searchNext)))
this.addSubscription(new Disposable(ipc.answerMain('search-previous', this.searchPrevious)))
this.addSubscription(new Disposable(ipc.answerMain('setting-changed', this.handleSettingChanged)))
this.addSubscription(new Disposable(ipc.answerMain('active-profile-changed', this.handleActiveProfileChanged)))
this.addSubscription(new Disposable(ipc.answerMain('close', this.handleClose)))
}
}