Skip to content

Commit

Permalink
REPL: Set program text (#317)
Browse files Browse the repository at this point in the history
* adding function set_program_text

* adding function set_program_text
  • Loading branch information
martin-henz authored Jul 3, 2024
1 parent bccaa0c commit d6baa34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bundles/repl/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/bundles/repl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ export {
repl_display,
set_background_image,
set_font_size,
set_program_text,
default_js_slang
} from './functions';

0 comments on commit d6baa34

Please sign in to comment.