32 lines
837 B
JavaScript
32 lines
837 B
JavaScript
/** Guest sample: summon-shaped TUI without a live fetch. */
|
|
|
|
async function run(ctx) {
|
|
if (!ctx.tui || !ctx.tui.isTTY()) {
|
|
ctx.console.error('tui-summon example: needs a TTY')
|
|
ctx.exitCode = 1
|
|
return
|
|
}
|
|
await ctx.tui.run(
|
|
{
|
|
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(
|
|
'summon example (no network)\n\n' +
|
|
'summon — text browser for Bare OS\n' +
|
|
'JS is off. HTTP via ctx.httpFetch.\n\n' +
|
|
'Real client: /bin/summon\n' +
|
|
'q quit'
|
|
)
|
|
}
|
|
},
|
|
{ buffer: 'cell' }
|
|
)
|
|
}
|