add console.log(...)

This commit is contained in:
MihailRis 2024-06-07 23:14:16 +03:00
parent dd027e38fe
commit e8ea34fa31
2 changed files with 19 additions and 6 deletions

View File

@ -38,12 +38,7 @@ function submit(text)
document.log.caret = -1
local status, result = pcall(function() return console.execute(text) end)
if result ~= nil then
local prevtext = document.log.text
if #prevtext == 0 then
document.log:paste(tostring(result))
else
document.log:paste('\n'..tostring(result))
end
console.log(result)
end
document.prompt.text = ""
document.prompt.focused = true

View File

@ -203,6 +203,24 @@ function time.post_runnable(runnable)
table.insert(__post_runnables, runnable)
end
local log_element = Document.new("core:console").log
function console.log(...)
local args = {...}
local text = ''
for i,v in ipairs(args) do
if i ~= 1 then
text = text..' '..v
else
text = text..v
end
end
log_element.caret = -1
if log_element.caret > 0 then
text = '\n'..text
end
log_element:paste(text)
end
function gui.template(name, params)
local text = file.read(file.find("layouts/templates/"..name..".xml"))
for k,v in pairs(params) do