add console.log(...)
This commit is contained in:
parent
dd027e38fe
commit
e8ea34fa31
@ -38,12 +38,7 @@ function submit(text)
|
|||||||
document.log.caret = -1
|
document.log.caret = -1
|
||||||
local status, result = pcall(function() return console.execute(text) end)
|
local status, result = pcall(function() return console.execute(text) end)
|
||||||
if result ~= nil then
|
if result ~= nil then
|
||||||
local prevtext = document.log.text
|
console.log(result)
|
||||||
if #prevtext == 0 then
|
|
||||||
document.log:paste(tostring(result))
|
|
||||||
else
|
|
||||||
document.log:paste('\n'..tostring(result))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
document.prompt.text = ""
|
document.prompt.text = ""
|
||||||
document.prompt.focused = true
|
document.prompt.focused = true
|
||||||
|
|||||||
@ -203,6 +203,24 @@ function time.post_runnable(runnable)
|
|||||||
table.insert(__post_runnables, runnable)
|
table.insert(__post_runnables, runnable)
|
||||||
end
|
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)
|
function gui.template(name, params)
|
||||||
local text = file.read(file.find("layouts/templates/"..name..".xml"))
|
local text = file.read(file.find("layouts/templates/"..name..".xml"))
|
||||||
for k,v in pairs(params) do
|
for k,v in pairs(params) do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user