Merge pull request #1811 from ethereum/tabChanged

Switch tab shortkey
pull/1/head
yann300 6 years ago committed by GitHub
commit cca207fe00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/app/panels/editor-panel.js
  2. 33
      src/app/panels/tab-proxy.js

@ -190,6 +190,11 @@ class EditorPanel {
` `
// INIT // INIT
self._adjustLayout('top', self.data._layout.top.offset) self._adjustLayout('top', self.data._layout.top.offset)
document.addEventListener('keydown', (e) => {
if (e.altKey && e.keyCode === 84) self.tabProxy.switchNextTab()
})
return self._view.el return self._view.el
} }
registerCommand (name, command, opts) { registerCommand (name, command, opts) {

@ -10,7 +10,6 @@ export class TabProxy {
this.fileManager = fileManager this.fileManager = fileManager
this.appManager = appManager this.appManager = appManager
this.editor = editor this.editor = editor
this.entities = {}
this.data = {} this.data = {}
this._view = {} this._view = {}
this._handlers = {} this._handlers = {}
@ -61,6 +60,7 @@ export class TabProxy {
this.appManager.deactivateOne(name) this.appManager.deactivateOne(name)
} }
) )
this.switchTab(name)
} }
}) })
@ -69,6 +69,37 @@ export class TabProxy {
}) })
} }
switchTab (tabName) {
if (this._handlers[tabName]) {
this._handlers[tabName].switchTo()
this._view.filetabs.activateTab(tabName)
}
}
switchNextTab () {
const active = this._view.filetabs.active
if (active && this._handlers[active]) {
const handlers = Object.keys(this._handlers)
let i = handlers.indexOf(active)
if (i >= 0) {
i = handlers[i + 1] ? i + 1 : 0
this.switchTab(handlers[i])
}
}
}
switchPreviousTab () {
const active = this._view.filetabs.active
if (active && this._handlers[active]) {
const handlers = Object.keys(this._handlers)
let i = handlers.indexOf(active)
if (i >= 0) {
i = handlers[i - 1] ? i - 1 : handlers.length - 1
this.switchTab(handlers[i])
}
}
}
addTab (name, switchTo, close, kind) { addTab (name, switchTo, close, kind) {
var slash = name.split('/') var slash = name.split('/')
let title = name.indexOf('/') !== -1 ? slash[slash.length - 1] : name let title = name.indexOf('/') !== -1 ? slash[slash.length - 1] : name

Loading…
Cancel
Save