Render portfolio pages as terminal commands

This commit is contained in:
2026-07-27 09:36:40 +09:00
parent ec3f569edc
commit ae0f6bc970
3 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ export function configureTerminal(stream, title) {
stream.write(`\x1b]2;${String(title).replace(/[\x00-\x1f\x7f]/g, '')}\x07`);
}
export function createTuiSession({ channel, ctx, router, renderHome, prompt, onClose }) {
export function createTuiSession({ channel, ctx, router, renderHome, renderPage, prompt, onClose }) {
const state = { input: '', cursor: 0, history: [], historyIndex: 0, closed: false };
const redrawInput = () => {
if (state.closed) return;
@@ -26,7 +26,7 @@ export function createTuiSession({ channel, ctx, router, renderHome, prompt, onC
const name = input.split(/\s+/)[0]?.toLowerCase() || 'home';
if (name === 'home' || name === 'clear') { router.execute(ctx, input); showHome(); return; }
const output = router.execute(ctx, input); if (state.closed || channel.destroyed) return;
if (output) channel.write(`${crlf(output)}\r\n`); channel.write(prompt(ctx));
channel.write(renderPage(ctx, input, output) + prompt(ctx));
};
const history = direction => {
if (!state.history.length) return;