minor refactor

This commit is contained in:
MihailRis 2024-11-19 08:04:30 +03:00
parent 53c54dc91d
commit b9d085c1b3
3 changed files with 17 additions and 9 deletions

View File

@ -61,16 +61,24 @@ events.on("core:open_traceback", function(traceback_b64)
else
framestr = frame.source..":"..tostring(frame.currentline).." "
if file.exists(frame.source) then
callback = "local source = file.read('"..frame.source.."') "..
"document.editor.text = source "..
"document.editor.focused = true "..
"time.post_runnable(function() document.editor.caret = document.editor:linePos("..
tostring(frame.currentline-1)..") end)"
callback = string.format(
"local editor = document.editor "..
"local source = file.read('%s') "..
"editor.text = source "..
"editor.focused = true "..
"time.post_runnable(function()"..
"editor.caret = editor:linePos(%s) "..
"end)",
frame.source, frame.currentline-1
)
else
callback = "document.editor.text = 'Could not open source file'"
end
callback = callback.." document.title.text = gui.str('File')..' - "
..frame.source.."'"
callback = string.format(
"%s document.title.text = gui.str('File')..' - %s'",
callback,
frame.source
)
end
if frame.name then
framestr = framestr.."("..tostring(frame.name)..")"

View File

@ -337,7 +337,7 @@ xmldocument Parser::parse() {
return document;
}
xmldocument xml::parse(const std::string& filename, const std::string& source) {
xmldocument xml::parse(std::string_view filename, std::string_view source) {
Parser parser(filename, source);
return parser.parse();
}

View File

@ -140,6 +140,6 @@ namespace xml {
/// @param source xml source code string
/// @return xml document
extern xmldocument parse(
const std::string& filename, const std::string& source
std::string_view filename, std::string_view source
);
}