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
+15 -7
View File
@@ -61,16 +61,24 @@ events.on("core:open_traceback", function(traceback_b64)
else else
framestr = frame.source..":"..tostring(frame.currentline).." " framestr = frame.source..":"..tostring(frame.currentline).." "
if file.exists(frame.source) then if file.exists(frame.source) then
callback = "local source = file.read('"..frame.source.."') ".. callback = string.format(
"document.editor.text = source ".. "local editor = document.editor "..
"document.editor.focused = true ".. "local source = file.read('%s') "..
"time.post_runnable(function() document.editor.caret = document.editor:linePos(".. "editor.text = source "..
tostring(frame.currentline-1)..") end)" "editor.focused = true "..
"time.post_runnable(function()"..
"editor.caret = editor:linePos(%s) "..
"end)",
frame.source, frame.currentline-1
)
else else
callback = "document.editor.text = 'Could not open source file'" callback = "document.editor.text = 'Could not open source file'"
end end
callback = callback.." document.title.text = gui.str('File')..' - " callback = string.format(
..frame.source.."'" "%s document.title.text = gui.str('File')..' - %s'",
callback,
frame.source
)
end end
if frame.name then if frame.name then
framestr = framestr.."("..tostring(frame.name)..")" framestr = framestr.."("..tostring(frame.name)..")"
+1 -1
View File
@@ -337,7 +337,7 @@ xmldocument Parser::parse() {
return document; 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); Parser parser(filename, source);
return parser.parse(); return parser.parse();
} }
+1 -1
View File
@@ -140,6 +140,6 @@ namespace xml {
/// @param source xml source code string /// @param source xml source code string
/// @return xml document /// @return xml document
extern xmldocument parse( extern xmldocument parse(
const std::string& filename, const std::string& source std::string_view filename, std::string_view source
); );
} }