xP: handle the M-Tab binding from xC
This commit is contained in:
parent
3330683ad6
commit
0bc2c12eec
@ -132,6 +132,7 @@ class RelayRpc extends EventTarget {
|
|||||||
let rpc = new RelayRpc(proxy)
|
let rpc = new RelayRpc(proxy)
|
||||||
|
|
||||||
let buffers = new Map()
|
let buffers = new Map()
|
||||||
|
let bufferLast = undefined
|
||||||
let bufferCurrent = undefined
|
let bufferCurrent = undefined
|
||||||
let bufferLog = undefined
|
let bufferLog = undefined
|
||||||
let bufferAutoscroll = true
|
let bufferAutoscroll = true
|
||||||
@ -142,9 +143,14 @@ function resetBufferStats(b) {
|
|||||||
b.highlighted = false
|
b.highlighted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bufferActivate(name) {
|
||||||
|
rpc.send({command: 'BufferActivate', bufferName: name})
|
||||||
|
}
|
||||||
|
|
||||||
let connecting = true
|
let connecting = true
|
||||||
rpc.connect().then(result => {
|
rpc.connect().then(result => {
|
||||||
buffers.clear()
|
buffers.clear()
|
||||||
|
bufferLast = undefined
|
||||||
bufferCurrent = undefined
|
bufferCurrent = undefined
|
||||||
bufferLog = undefined
|
bufferLog = undefined
|
||||||
bufferAutoscroll = true
|
bufferAutoscroll = true
|
||||||
@ -193,6 +199,8 @@ rpc.addEventListener('BufferRename', event => {
|
|||||||
rpc.addEventListener('BufferRemove', event => {
|
rpc.addEventListener('BufferRemove', event => {
|
||||||
let e = event.detail
|
let e = event.detail
|
||||||
buffers.delete(e.bufferName)
|
buffers.delete(e.bufferName)
|
||||||
|
if (e.bufferName === bufferLast)
|
||||||
|
bufferLast = undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
rpc.addEventListener('BufferActivate', event => {
|
rpc.addEventListener('BufferActivate', event => {
|
||||||
@ -200,6 +208,7 @@ rpc.addEventListener('BufferActivate', event => {
|
|||||||
if (old !== undefined)
|
if (old !== undefined)
|
||||||
resetBufferStats(old)
|
resetBufferStats(old)
|
||||||
|
|
||||||
|
bufferLast = bufferCurrent
|
||||||
let e = event.detail, b = buffers.get(e.bufferName)
|
let e = event.detail, b = buffers.get(e.bufferName)
|
||||||
bufferCurrent = e.bufferName
|
bufferCurrent = e.bufferName
|
||||||
bufferLog = undefined
|
bufferLog = undefined
|
||||||
@ -324,10 +333,6 @@ let Toolbar = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let BufferList = {
|
let BufferList = {
|
||||||
activate: name => {
|
|
||||||
rpc.send({command: 'BufferActivate', bufferName: name})
|
|
||||||
},
|
|
||||||
|
|
||||||
view: vnode => {
|
view: vnode => {
|
||||||
let items = Array.from(buffers, ([name, b]) => {
|
let items = Array.from(buffers, ([name, b]) => {
|
||||||
let classes = [], displayName = name
|
let classes = [], displayName = name
|
||||||
@ -342,7 +347,7 @@ let BufferList = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m('.item', {
|
return m('.item', {
|
||||||
onclick: event => BufferList.activate(name),
|
onclick: event => bufferActivate(name),
|
||||||
class: classes.join(' '),
|
class: classes.join(' '),
|
||||||
}, displayName)
|
}, displayName)
|
||||||
})
|
})
|
||||||
@ -578,11 +583,13 @@ let Input = {
|
|||||||
let handled = false
|
let handled = false
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case 9:
|
case 9:
|
||||||
if (!event.shiftKey)
|
if (!event.ctrlKey && !event.metaKey && !event.altKey &&
|
||||||
|
!event.shiftKey)
|
||||||
handled = Input.complete(textarea)
|
handled = Input.complete(textarea)
|
||||||
break
|
break
|
||||||
case 13:
|
case 13:
|
||||||
if (!event.shiftKey)
|
if (!event.ctrlKey && !event.metaKey && !event.altKey &&
|
||||||
|
!event.shiftKey)
|
||||||
handled = Input.submit(textarea)
|
handled = Input.submit(textarea)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -619,21 +626,23 @@ document.addEventListener('keydown', event => {
|
|||||||
if (rpc.ws == undefined || event.ctrlKey || event.metaKey)
|
if (rpc.ws == undefined || event.ctrlKey || event.metaKey)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (event.altKey && event.key == 'a') {
|
if (event.altKey && event.key == 'Tab') {
|
||||||
|
if (bufferLast !== undefined)
|
||||||
|
bufferActivate(bufferLast)
|
||||||
|
} else if (event.altKey && event.key == 'a') {
|
||||||
for (const [name, b] of buffers)
|
for (const [name, b] of buffers)
|
||||||
if (name !== bufferCurrent && b.newMessages) {
|
if (name !== bufferCurrent && b.newMessages) {
|
||||||
rpc.send({command: 'BufferActivate', bufferName: name})
|
bufferActivate(name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return event.preventDefault()
|
} else if (event.altKey && event.key == '!') {
|
||||||
}
|
|
||||||
|
|
||||||
if (event.altKey && event.key == '!') {
|
|
||||||
for (const [name, b] of buffers)
|
for (const [name, b] of buffers)
|
||||||
if (name !== bufferCurrent && b.highlighted) {
|
if (name !== bufferCurrent && b.highlighted) {
|
||||||
rpc.send({command: 'BufferActivate', bufferName: name})
|
bufferActivate(name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return event.preventDefault()
|
} else
|
||||||
}
|
return
|
||||||
|
|
||||||
|
event.preventDefault()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user