35 lines
870 B
JavaScript
35 lines
870 B
JavaScript
/** Guest sample: IRC-shaped TUI without a live socket. */
|
|
|
|
async function run(ctx) {
|
|
if (!ctx.tui || !ctx.tui.isTTY()) {
|
|
ctx.console.error('tui-irc example: needs a TTY')
|
|
ctx.exitCode = 1
|
|
return
|
|
}
|
|
const lines = [
|
|
'12:00 -server- connected (example)',
|
|
'12:01 <demo> hello from Bare OS'
|
|
]
|
|
await ctx.tui.run(
|
|
{
|
|
n: 0,
|
|
update: function (msg) {
|
|
if (ctx.tui.key.matches(msg, 'q', 'ctrl+c')) return [this, ctx.tui.quit]
|
|
return [this, null]
|
|
},
|
|
view: function () {
|
|
return ctx.tui
|
|
.style()
|
|
.border(ctx.tui.style.borders.rounded)
|
|
.width(60)
|
|
.render(
|
|
'irc example (no network)\n\n' +
|
|
lines.join('\n') +
|
|
'\n\nReal client: /bin/irc → irc.libera.chat:6697\nq quit'
|
|
)
|
|
}
|
|
},
|
|
{ buffer: 'cell' }
|
|
)
|
|
}
|