summaryrefslogtreecommitdiff
path: root/xP/public/xP.js
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-21 07:32:18 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-21 07:34:17 +0200
commit414859d309df7282fbb044c5303f8ce7a32461c8 (patch)
tree6d4ca9c054a4505c1e065f5caec770372b6be6dc /xP/public/xP.js
parent5a7f2d16dfed15dc8bfefc507abe3866f205af98 (diff)
downloadxK-414859d309df7282fbb044c5303f8ce7a32461c8.tar.gz
xK-414859d309df7282fbb044c5303f8ce7a32461c8.tar.xz
xK-414859d309df7282fbb044c5303f8ce7a32461c8.zip
xP: improve paging
Diffstat (limited to 'xP/public/xP.js')
-rw-r--r--xP/public/xP.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index cbc37d7..8820251 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -199,6 +199,7 @@ function bufferToggleUnimportant(name) {
}
function bufferToggleLog() {
+ // TODO: Try to restore the previous scroll offset.
if (bufferLog) {
setTimeout(() =>
document.getElementById('input')?.focus())
@@ -347,6 +348,7 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
let visible = document.visibilityState !== 'hidden' &&
bufferLog === undefined &&
+ bufferAutoscroll &&
(e.bufferName == bufferCurrent || e.leakToActive)
b.lines.push({...line})
if (!(visible || e.leakToActive) ||
@@ -427,21 +429,6 @@ let linkRE = [
/[^\[\](){}<>"'\s,.:]/,
].map(r => r.source).join('')
-let Toolbar = {
- toggleAutoscroll: () => {
- bufferAutoscroll = !bufferAutoscroll
- },
-
- view: vnode => {
- return m('.toolbar', {}, [
- m('button', {onclick: Toolbar.toggleAutoscroll},
- bufferAutoscroll ? 'Scroll lock' : 'Scroll unlock'),
- m('button', {onclick: event => bufferToggleLog()},
- bufferLog === undefined ? 'Show log' : 'Hide log'),
- ])
- },
-}
-
let BufferList = {
view: vnode => {
let highlighted = false
@@ -624,7 +611,11 @@ let Buffer = {
let dateMark = new Date().toLocaleDateString()
if (dateMark !== lastDateMark && lastDateMark !== undefined)
lines.push(m('.date', {}, dateMark))
- return m('.buffer', {}, lines)
+ return m('.buffer', {onscroll: event => {
+ const dom = event.target
+ bufferAutoscroll =
+ dom.scrollTop + dom.clientHeight + 0.5 >= dom.scrollHeight
+ }}, lines)
},
}
@@ -678,6 +669,16 @@ let BufferContainer = {
},
}
+let Toolbar = {
+ view: vnode => {
+ return m('.toolbar', {}, [
+ bufferLog === undefined && !bufferAutoscroll ? '⇩' : undefined,
+ m('button', {onclick: event => bufferToggleLog()},
+ bufferLog === undefined ? 'Log' : 'Hide log'),
+ ])
+ },
+}
+
let Status = {
view: vnode => {
let b = buffers.get(bufferCurrent)
@@ -687,7 +688,7 @@ let Status = {
let status = `${bufferCurrent}`
if (b.hideUnimportant)
status += `<H>`
- return m('.status', {}, status)
+ return m('.status', {}, [status, m(Toolbar)])
},
}
@@ -944,7 +945,7 @@ let Main = {
return m('.xP', {}, [
overlay,
- m('.title', {}, [`xP`, m(Toolbar)]),
+ m('.title', {}, `xP`),
m('.middle', {}, [m(BufferList), m(BufferContainer)]),
m(Status),
m('.input', {}, [m(Prompt), m(Input)]),