Loading static/js/jslinux.api.mjs +15 −4 Original line number Diff line number Diff line Loading @@ -136,6 +136,18 @@ export function getTerminalContents(includeLastInteraction) { return contents } /** * Return the current prompt, or null, if no prompt is currently shown */ function getCurrentPrompt() { const lastInteraction = getTerminalContents(true).at(-1) if(lastInteraction.prompt && !lastInteraction.input?.trim()) { return lastInteraction.prompt } else { return null } } /** * Returns the current prompt as soon as one is shown */ Loading @@ -144,11 +156,10 @@ function prompt() { const intervalId = setInterval(checkAndResolve, 100) function checkAndResolve() { const lastInteraction = getTerminalContents(true).at(-1) if(lastInteraction.prompt && !lastInteraction.input?.trim()) { const currentPrompt = getCurrentPrompt() if(currentPrompt !== null) { clearInterval(intervalId) resolve(prompt) resolve(currentPrompt) } } }) Loading Loading
static/js/jslinux.api.mjs +15 −4 Original line number Diff line number Diff line Loading @@ -136,6 +136,18 @@ export function getTerminalContents(includeLastInteraction) { return contents } /** * Return the current prompt, or null, if no prompt is currently shown */ function getCurrentPrompt() { const lastInteraction = getTerminalContents(true).at(-1) if(lastInteraction.prompt && !lastInteraction.input?.trim()) { return lastInteraction.prompt } else { return null } } /** * Returns the current prompt as soon as one is shown */ Loading @@ -144,11 +156,10 @@ function prompt() { const intervalId = setInterval(checkAndResolve, 100) function checkAndResolve() { const lastInteraction = getTerminalContents(true).at(-1) if(lastInteraction.prompt && !lastInteraction.input?.trim()) { const currentPrompt = getCurrentPrompt() if(currentPrompt !== null) { clearInterval(intervalId) resolve(prompt) resolve(currentPrompt) } } }) Loading