@dodona/papyros
Version:
Scratchpad for multiple programming languages in the browser.
88 lines (87 loc) • 2.56 kB
TypeScript
import { State } from "@dodona/lit-state";
import { Papyros } from "./Papyros";
/**
* Shape of Error objects that are easy to interpret
*/
export interface FriendlyError {
/**
* The name of the Error
*/
name: string;
/**
* Traceback for where in the code the Error occurred
*/
traceback?: string;
/**
* General information about this type of Error
*/
info?: string;
/**
* Information about what went wrong in this case
*/
what?: string;
/**
* Information about why this is wrong and how to fix it
*/
why?: string;
/**
* Where specifically in the source code the Error occurred
*/
where?: string;
}
export declare enum OutputType {
stdout = "stdout",
stderr = "stderr",
img = "img",
turtle = "turtle"
}
export type OutputEntry = {
type: OutputType;
content: string | FriendlyError;
contentType?: string;
};
export declare enum InputMode {
batch = "batch",
interactive = "interactive"
}
export interface FileEntry {
name: string;
content: string;
binary: boolean;
}
export declare const CODE_TAB = "code";
export declare const OUTPUT_TAB = "output";
export declare const TURTLE_TAB = "turtle";
export type OutputTab = typeof OUTPUT_TAB | typeof TURTLE_TAB;
export declare function parseFileEntries(data: string, contentType?: string): FileEntry[];
export declare class InputOutput extends State {
private papyros;
inputs: string[];
output: OutputEntry[];
hasTurtleOutput: boolean;
files: FileEntry[];
activeEditorTab: string;
activeOutputTab: OutputTab;
outputTabManuallySet: boolean;
prompt: string;
awaitingInput: boolean;
inputMode: InputMode;
private _inputBuffer;
get inputBuffer(): string;
set inputBuffer(value: string);
private get nextBufferedLine();
constructor(papyros: Papyros);
logError(error: FriendlyError | string): void;
logImage(imageData: string, contentType?: string): void;
logTurtle(imageData: string, contentType?: string): void;
selectOutputTab(tab: OutputTab): void;
logOutput(output: string): void;
provideInput(input: string): void;
removeFile(name: string): void;
addFile(name: string, content?: string, binary?: boolean): boolean;
updateFileContent(name: string, content: string, binary: boolean): void;
renameFile(oldName: string, newName: string): boolean;
upsertFile(name: string, content: string, binary: boolean): void;
clearInputs(): void;
reset(): void;
}