diff --git a/include/communication/EmscriptenCommunication.h b/include/communication/EmscriptenCommunication.h index fc2a6897df..d6d07baed3 100644 --- a/include/communication/EmscriptenCommunication.h +++ b/include/communication/EmscriptenCommunication.h @@ -21,6 +21,7 @@ class EmscriptenCommunication : public CommandLine { private: std::string progress_handler_; ///< Handler for progress messages. + std::string gcode_prefix_handler_; /// & { slice_info_handler_ = *ranges::next(slice_info_flag); } + if (auto gcode_prefix_flag = ranges::find(arguments_, "--gcode_prefix_cb"); gcode_prefix_flag != arguments_.end()) + { + gcode_prefix_handler_ = *ranges::next(gcode_prefix_flag); + } +} + +void EmscriptenCommunication::sendGCodePrefix(const std::string& prefix) const +{ + emscripten_run_script(fmt::format("globalThis[\"{}\"]({})", gcode_prefix_handler_, prefix).c_str()); } void EmscriptenCommunication::sendProgress(double progress) const