Files
bare-operating-system/examples/tui-irc/index.js
T
Raven Scott 1187e30cf6
Release rolling / release (push) Successful in 9m31s
Add irc
2026-08-12 23:50:49 -04:00

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' }
)
}