Verified Commit efd95924 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add getRawTerminalContents() API function

parent 536ec174
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -117,9 +117,7 @@ export function getTerminalContents(includeLastInteraction) {
    const contents = []
    let currentInteraction = {}

    Array
        .from(document.querySelectorAll(".term_content div"))
        .map(div => sanitize(div.textContent))
    getRawTerminalContents()
        .filter(line => line !== " ")
        .map(parseAsPromptOrOutput)
        .forEach(parsed => {
@@ -138,6 +136,21 @@ export function getTerminalContents(includeLastInteraction) {
    return contents
}

/**
 * Get the raw contents of the terminal area that are currently visible (without scrolling).
 * 
 * Returns a list containing every line (even empty ones) of the visible terminal area.
 * Just like getTerminalContents(), the lines are sanitized so that non-breaking spaces are
 * replaced with normal spaces.
 * 
 * @returns List of strings ["firstVisibleLine", "secondVisibleLine", ..., "lastVisibleLine"]
 */
export function getRawTerminalContents() {
    return Array
        .from(document.querySelectorAll(".term_content div"))
        .map(div => sanitize(div.textContent))
}

/**
 * Return if the vm is currently loading, i.e. not accepting commands
 */