Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: Set program text #317

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Loading