xP: add a temporary lock for autoscroll

This commit is contained in:
Přemysl Eric Janouch 2022-09-07 13:52:30 +02:00
parent e3149b9abf
commit d55402234c
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -132,12 +132,14 @@ let rpc = new RelayRpc(proxy)
let buffers = new Map() let buffers = new Map()
let bufferCurrent = undefined let bufferCurrent = undefined
let bufferLog = undefined let bufferLog = undefined
let bufferAutoscroll = true
let connecting = true let connecting = true
rpc.connect().then(result => { rpc.connect().then(result => {
buffers.clear() buffers.clear()
bufferCurrent = undefined bufferCurrent = undefined
bufferLog = undefined bufferLog = undefined
bufferAutoscroll = true
rpc.send({command: 'Hello', version: 1}) rpc.send({command: 'Hello', version: 1})
connecting = false connecting = false
@ -176,6 +178,7 @@ rpc.addEventListener('BufferActivate', event => {
let old = buffers.get(bufferCurrent) let old = buffers.get(bufferCurrent)
bufferCurrent = e.bufferName bufferCurrent = e.bufferName
bufferLog = undefined bufferLog = undefined
bufferAutoscroll = true
let textarea = document.getElementById('input') let textarea = document.getElementById('input')
if (textarea === null) if (textarea === null)
@ -327,7 +330,8 @@ let Content = {
let Buffer = { let Buffer = {
oncreate: vnode => { oncreate: vnode => {
if (vnode.dom === undefined || bufferLog !== undefined) if (vnode.dom === undefined ||
bufferLog !== undefined || !bufferAutoscroll)
return return
let el = vnode.dom.children[1] let el = vnode.dom.children[1]
@ -368,6 +372,10 @@ let Buffer = {
} }
let Toolbar = { let Toolbar = {
toggleAutoscroll: () => {
bufferAutoscroll = !bufferAutoscroll
},
toggleLog: () => { toggleLog: () => {
if (bufferLog) { if (bufferLog) {
bufferLog = undefined bufferLog = undefined
@ -385,6 +393,8 @@ let Toolbar = {
view: vnode => { view: vnode => {
return m('.toolbar', {}, [ return m('.toolbar', {}, [
m('button', {onclick: Toolbar.toggleAutoscroll},
bufferAutoscroll ? 'Pause autoscroll' : 'Unpause autoscroll'),
m('button', {onclick: Toolbar.toggleLog}, m('button', {onclick: Toolbar.toggleLog},
bufferLog === undefined ? 'Show log' : 'Hide log'), bufferLog === undefined ? 'Show log' : 'Hide log'),
]) ])