diff --git a/src/bundles/repl/functions.ts b/src/bundles/repl/functions.ts index 948e3c8d1..87f8bc593 100644 --- a/src/bundles/repl/functions.ts +++ b/src/bundles/repl/functions.ts @@ -102,6 +102,16 @@ export function set_font_size(font_size_px: number) { INSTANCE.customizedEditorProps.fontSize = parseInt(font_size_px.toString());// The TypeScript type checker will throw an error as "parseInt" in TypeScript only accepts one string as parameter. } +/** + * Set program text in the Repl editor to the given string + * @param {text} string + * + * @category Main + */ +export function set_program_text(text: string) { + INSTANCE.updateUserCode(text); +} + /** * When use this function as the entrance function in the parameter of "set_evaluator", the Programmable Repl will directly use the default js-slang interpreter to run your program in Programmable Repl editor. Do not directly call this function in your own code. * @param {program} Do not directly set this parameter in your code. diff --git a/src/bundles/repl/index.ts b/src/bundles/repl/index.ts index 124c27694..05ab6548c 100644 --- a/src/bundles/repl/index.ts +++ b/src/bundles/repl/index.ts @@ -42,5 +42,6 @@ export { repl_display, set_background_image, set_font_size, + set_program_text, default_js_slang } from './functions';