Compare commits
No commits in common. "a61789637a5af03b06655c9ce03a92ddd57fe383" and "3b6c29d676c569a7081dc9322b49ce80ba6fe2f2" have entirely different histories.
a61789637a
...
3b6c29d676
@ -132,9 +132,13 @@ class RelayRpc extends EventTarget {
|
|||||||
function utf8Encode(s) { return new TextEncoder().encode(s) }
|
function utf8Encode(s) { return new TextEncoder().encode(s) }
|
||||||
function utf8Decode(s) { return new TextDecoder().decode(s) }
|
function utf8Decode(s) { return new TextDecoder().decode(s) }
|
||||||
|
|
||||||
|
// On macOS, the Alt/Option key transforms characters, which basically breaks
|
||||||
|
// all event.altKey shortcuts, so require combining them with Control as well
|
||||||
|
// on that system.
|
||||||
function hasShortcutModifiers(event) {
|
function hasShortcutModifiers(event) {
|
||||||
return (event.altKey || event.escapePrefix) &&
|
// This method of detection only works with Blink browsers, as of writing.
|
||||||
!event.metaKey && !event.ctrlKey
|
return event.altKey && !event.metaKey &&
|
||||||
|
(navigator.userAgentData?.platform === 'macOS') === event.ctrlKey
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioContext = new AudioContext()
|
const audioContext = new AudioContext()
|
||||||
@ -166,11 +170,7 @@ function updateIcon(highlighted) {
|
|||||||
|
|
||||||
let ctx = canvas.getContext('2d')
|
let ctx = canvas.getContext('2d')
|
||||||
ctx.arc(16, 16, 12, 0, 2 * Math.PI)
|
ctx.arc(16, 16, 12, 0, 2 * Math.PI)
|
||||||
ctx.fillStyle = '#000'
|
ctx.fillStyle = highlighted ? '#ff5f00' : '#ccc'
|
||||||
if (highlighted === true)
|
|
||||||
ctx.fillStyle = '#ff5f00'
|
|
||||||
if (highlighted === false)
|
|
||||||
ctx.fillStyle = '#ccc'
|
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
|
|
||||||
if (iconLink === undefined) {
|
if (iconLink === undefined) {
|
||||||
@ -305,8 +305,6 @@ rpc.addEventListener('BufferActivate', event => {
|
|||||||
bufferCurrent = e.bufferName
|
bufferCurrent = e.bufferName
|
||||||
bufferLog = undefined
|
bufferLog = undefined
|
||||||
bufferAutoscroll = true
|
bufferAutoscroll = true
|
||||||
if (b !== undefined && document.visibilityState !== 'hidden')
|
|
||||||
b.highlighted = false
|
|
||||||
|
|
||||||
let textarea = document.getElementById('input')
|
let textarea = document.getElementById('input')
|
||||||
if (textarea === null)
|
if (textarea === null)
|
||||||
@ -343,8 +341,7 @@ rpc.addEventListener('BufferLine', event => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let visible = document.visibilityState !== 'hidden' &&
|
let visible = !document.hidden && bufferLog === undefined &&
|
||||||
bufferLog === undefined &&
|
|
||||||
(e.bufferName == bufferCurrent || e.leakToActive)
|
(e.bufferName == bufferCurrent || e.leakToActive)
|
||||||
b.lines.push({...line})
|
b.lines.push({...line})
|
||||||
if (!(visible || e.leakToActive) ||
|
if (!(visible || e.leakToActive) ||
|
||||||
@ -449,13 +446,15 @@ let BufferList = {
|
|||||||
let classes = [], displayName = name
|
let classes = [], displayName = name
|
||||||
if (name == bufferCurrent) {
|
if (name == bufferCurrent) {
|
||||||
classes.push('current')
|
classes.push('current')
|
||||||
} else if (b.newMessages) {
|
} else {
|
||||||
classes.push('activity')
|
if (b.highlighted) {
|
||||||
displayName += ` (${b.newMessages})`
|
classes.push('highlighted')
|
||||||
}
|
highlighted = true
|
||||||
if (b.highlighted) {
|
}
|
||||||
classes.push('highlighted')
|
if (b.newMessages) {
|
||||||
highlighted = true
|
classes.push('activity')
|
||||||
|
displayName += ` (${b.newMessages})`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m('.item', {
|
return m('.item', {
|
||||||
onclick: event => bufferActivate(name),
|
onclick: event => bufferActivate(name),
|
||||||
@ -463,7 +462,7 @@ let BufferList = {
|
|||||||
}, displayName)
|
}, displayName)
|
||||||
})
|
})
|
||||||
|
|
||||||
updateIcon(rpc.ws === undefined ? null : highlighted)
|
updateIcon(highlighted)
|
||||||
return m('.list', {}, items)
|
return m('.list', {}, items)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -814,30 +813,7 @@ let Main = {
|
|||||||
|
|
||||||
window.addEventListener('load', () => m.mount(document.body, Main))
|
window.addEventListener('load', () => m.mount(document.body, Main))
|
||||||
|
|
||||||
document.addEventListener('visibilitychange', event => {
|
|
||||||
let b = buffers.get(bufferCurrent)
|
|
||||||
if (b !== undefined && document.visibilityState !== 'hidden') {
|
|
||||||
b.highlighted = false
|
|
||||||
m.redraw()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// On macOS, the Alt/Option key transforms characters, which basically breaks
|
|
||||||
// all event.altKey shortcuts, so implement Escape prefixing on that system.
|
|
||||||
// This method of detection only works with Blink browsers, as of writing.
|
|
||||||
let lastWasEscape = false
|
|
||||||
document.addEventListener('keydown', event => {
|
document.addEventListener('keydown', event => {
|
||||||
event.escapePrefix = lastWasEscape
|
|
||||||
if (lastWasEscape) {
|
|
||||||
lastWasEscape = false
|
|
||||||
} else if (event.code == 'Escape' &&
|
|
||||||
navigator.userAgentData?.platform === 'macOS') {
|
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
lastWasEscape = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rpc.ws == undefined || !hasShortcutModifiers(event))
|
if (rpc.ws == undefined || !hasShortcutModifiers(event))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -885,4 +861,4 @@ document.addEventListener('keydown', event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}, true)
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user