diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-07 13:52:30 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-07 13:53:28 +0200 |
commit | d55402234c038a9bd2bdecbf0cfa02e48ef7a42e (patch) | |
tree | d5f4d2e13b45f13fcb8da320dfb339bc00ef1e1a /xP/public/xP.js | |
parent | e3149b9abfec2a4d8e393b51506403e41e6903d1 (diff) | |
download | xK-d55402234c038a9bd2bdecbf0cfa02e48ef7a42e.tar.gz xK-d55402234c038a9bd2bdecbf0cfa02e48ef7a42e.tar.xz xK-d55402234c038a9bd2bdecbf0cfa02e48ef7a42e.zip |
xP: add a temporary lock for autoscroll
Diffstat (limited to 'xP/public/xP.js')
-rw-r--r-- | xP/public/xP.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js index b02d2af..4d2c439 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -132,12 +132,14 @@ let rpc = new RelayRpc(proxy) let buffers = new Map() let bufferCurrent = undefined let bufferLog = undefined +let bufferAutoscroll = true let connecting = true rpc.connect().then(result => { buffers.clear() bufferCurrent = undefined bufferLog = undefined + bufferAutoscroll = true rpc.send({command: 'Hello', version: 1}) connecting = false @@ -176,6 +178,7 @@ rpc.addEventListener('BufferActivate', event => { let old = buffers.get(bufferCurrent) bufferCurrent = e.bufferName bufferLog = undefined + bufferAutoscroll = true let textarea = document.getElementById('input') if (textarea === null) @@ -327,7 +330,8 @@ let Content = { let Buffer = { oncreate: vnode => { - if (vnode.dom === undefined || bufferLog !== undefined) + if (vnode.dom === undefined || + bufferLog !== undefined || !bufferAutoscroll) return let el = vnode.dom.children[1] @@ -368,6 +372,10 @@ let Buffer = { } let Toolbar = { + toggleAutoscroll: () => { + bufferAutoscroll = !bufferAutoscroll + }, + toggleLog: () => { if (bufferLog) { bufferLog = undefined @@ -385,6 +393,8 @@ let Toolbar = { view: vnode => { return m('.toolbar', {}, [ + m('button', {onclick: Toolbar.toggleAutoscroll}, + bufferAutoscroll ? 'Pause autoscroll' : 'Unpause autoscroll'), m('button', {onclick: Toolbar.toggleLog}, bufferLog === undefined ? 'Show log' : 'Hide log'), ]) |