aboutsummaryrefslogtreecommitdiff
path: root/xP
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-06 22:30:23 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-06 22:33:00 +0200
commit93b66b6a2693ebbd8eb234a9436b457b0bdaba12 (patch)
treed99882d3ffd67b87cfed73ee1de8df2ced8a54e9 /xP
parentee1750c23c1e40c2c1cb4f7e33f622ea86e84ef8 (diff)
downloadxK-93b66b6a2693ebbd8eb234a9436b457b0bdaba12.tar.gz
xK-93b66b6a2693ebbd8eb234a9436b457b0bdaba12.tar.xz
xK-93b66b6a2693ebbd8eb234a9436b457b0bdaba12.zip
xP: scroll to bottom and focus the input on switch
Diffstat (limited to 'xP')
-rw-r--r--xP/public/xP.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index af20c2b..dba8a99 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -165,8 +165,11 @@ rpc.addEventListener('BufferRemove', event => {
rpc.addEventListener('BufferActivate', event => {
let e = event.detail
bufferCurrent = e.bufferName
- // TODO: Somehow scroll to the end of it immediately.
- // TODO: Focus the textarea.
+ setTimeout(() => {
+ let el = document.getElementById('input')
+ if (el !== null)
+ el.focus()
+ })
})
rpc.addEventListener('BufferLine', event => {
@@ -306,6 +309,19 @@ let Content = {
}
let Buffer = {
+ oncreate: vnode => {
+ if (vnode.dom === undefined)
+ return
+
+ let el = vnode.dom.children[1]
+ if (el !== null)
+ el.scrollTop = el.scrollHeight
+ },
+
+ onupdate: vnode => {
+ Buffer.oncreate(vnode)
+ },
+
view: vnode => {
let lines = []
let b = buffers.get(bufferCurrent)
@@ -376,7 +392,7 @@ function onKeyDown(event) {
// and we'll probably have to intercept /all/ key presses.
let Input = {
view: vnode => {
- return m('textarea', {
+ return m('textarea#input', {
rows: 1,
onkeydown: onKeyDown,
})