mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
TextBuffer: treat short buffers as a status
This commit is contained in:
parent
9db390c76c
commit
d95ee172bb
1 changed files with 18 additions and 4 deletions
|
|
@ -3,6 +3,9 @@ import { useEffect, useRef, useState } from 'preact/hooks'
|
||||||
|
|
||||||
import TextMessage from './TextMessage'
|
import TextMessage from './TextMessage'
|
||||||
|
|
||||||
|
const isFakeStatus = w =>
|
||||||
|
w.height < 5
|
||||||
|
|
||||||
const trimInputPrompt = messages =>
|
const trimInputPrompt = messages =>
|
||||||
messages.length < 1
|
messages.length < 1
|
||||||
? messages
|
? messages
|
||||||
|
|
@ -22,7 +25,7 @@ const parseInbox = (inbox, currentWindow) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { clear, text: inboxMessagesRaw } =
|
const { text: inboxMessagesRaw } =
|
||||||
currentInbox
|
currentInbox
|
||||||
|
|
||||||
const eol = { style: 'endOfLine' }
|
const eol = { style: 'endOfLine' }
|
||||||
|
|
@ -38,7 +41,12 @@ const parseInbox = (inbox, currentWindow) => {
|
||||||
.reduce((acc, x) =>
|
.reduce((acc, x) =>
|
||||||
acc.concat(x), [])
|
acc.concat(x), [])
|
||||||
|
|
||||||
return { clear, incoming }
|
return {
|
||||||
|
incoming,
|
||||||
|
clear: isFakeStatus(currentWindow)
|
||||||
|
? true
|
||||||
|
: currentInbox.clear
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ({ inbox, currentWindow }) {
|
export default function ({ inbox, currentWindow }) {
|
||||||
|
|
@ -66,11 +74,17 @@ export default function ({ inbox, currentWindow }) {
|
||||||
}, 0)
|
}, 0)
|
||||||
}, [inbox])
|
}, [inbox])
|
||||||
|
|
||||||
|
const classes = [
|
||||||
|
isFakeStatus(currentWindow)
|
||||||
|
? 'gridBuffer'
|
||||||
|
: 'textBuffer',
|
||||||
|
'buffer'].join(' ')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
ref={textBufferEl}
|
ref={textBufferEl}
|
||||||
className='buffer textBuffer'>
|
className={classes}>
|
||||||
{messages.map(TextMessage)}
|
{messages.map(TextMessage)}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue