Render portfolio pages as terminal commands
This commit is contained in:
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user