MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / open

Method open

src/app/script/api/app_script.cpp:228–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226 }
227
228 script::Value open(const std::string& fn) {
229 if (fn.empty())
230 return {};
231 auto oldDoc = static_cast<doc::Document*>(UIContext::instance()->activeDocument());
232 Command* openCommand = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
233 Params params;
234 params.set("filename", fn.c_str());
235 UIContext::instance()->executeCommand(openCommand, params);
236 auto newDoc = static_cast<doc::Document*>(UIContext::instance()->activeDocument());
237 if (newDoc == oldDoc)
238 return {};
239 return getEngine()->getScriptObject(newDoc);
240 }
241
242 bool launch(const std::string& cmd) {
243 return base::launcher::open_file(cmd);

Callers 4

exportSheetMethod · 0.45
drawMaskMethod · 0.45
traceBrushBoundariesMethod · 0.45
render_textFunction · 0.45

Calls 7

instanceFunction · 0.85
getCommandByNameMethod · 0.80
executeCommandMethod · 0.80
getScriptObjectMethod · 0.80
emptyMethod · 0.45
activeDocumentMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected