43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
--:Minify:--
|
|
local kernel = ...
|
|
function print(...)
|
|
local args = {...}
|
|
local output = ""
|
|
for i = 1, #args do output = output .. tostring(args[i]) .. "\t" end
|
|
output = output:sub(1, -2)
|
|
syscall.write(1, output.."\n")
|
|
end
|
|
|
|
function printf(fmt, ...)
|
|
local output = string.format(fmt, ...)
|
|
syscall.write(1, output.."\n")
|
|
end
|
|
|
|
function printInline(...)
|
|
local args = {...}
|
|
local output = ""
|
|
for i = 1, #args do output = output .. tostring(args[i]) .. "\t" end
|
|
output = output:sub(1, -2)
|
|
syscall.write(1, output)
|
|
end
|
|
|
|
function userinput(fd, helpstr, replacestr, fdo)
|
|
local str = ""
|
|
if helpstr then print(helpstr) end
|
|
while true do
|
|
local inp = syscall.read(fd)
|
|
if inp~="" and inp~=nil then
|
|
if inp~="\n" then
|
|
if replacestr then
|
|
syscall.write(fdo, replacestr)
|
|
else
|
|
syscall.write(fdo, inp)
|
|
end
|
|
str = inp
|
|
else
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return str
|
|
end |