From d55402234c038a9bd2bdecbf0cfa02e48ef7a42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Wed, 7 Sep 2022 13:52:30 +0200 Subject: [PATCH] xP: add a temporary lock for autoscroll --- xP/public/xP.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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'), ])