mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
Compare commits
5 Commits
69666130da
...
4e276c9ccd
Author | SHA1 | Date | |
---|---|---|---|
|
4e276c9ccd | ||
|
1c416be625 | ||
|
ff321804ee | ||
|
c3347fa188 | ||
|
a428a36c5d |
4
build.sh
4
build.sh
@ -2,4 +2,8 @@
|
||||
rm -r target/*
|
||||
mkdir target
|
||||
lua luapreproc.lua module/init.lua target/init.lua
|
||||
echo _OSVERSION=\"PsychOS 2.0a1-$(git rev-parse --short HEAD)\" > target/version.lua
|
||||
cat target/version.lua target/init.lua > target/tinit.lua
|
||||
mv target/tinit.lua target/init.lua
|
||||
cp -r exec/ service/ lib/ target/
|
||||
lua finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md
|
||||
|
@ -1,12 +1,12 @@
|
||||
xpcall(function()
|
||||
os.setenv("PWD","/boot")
|
||||
os.spawnfile("/boot/service/getty.lua")
|
||||
coroutine.yield()
|
||||
for k,v in pairs(fs.list("/dev/")) do
|
||||
if v:sub(1,3) == "tty" then
|
||||
dprint(tostring(io.input("/dev/"..v)))
|
||||
dprint(tostring(io.output("/dev/"..v)))
|
||||
io.write("PsychOS v2.0a1 - ")
|
||||
print(tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
|
||||
print(_OSVERSION.." - "..tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
|
||||
os.spawnfile("/boot/exec/shell.lua")
|
||||
end
|
||||
end
|
||||
|
@ -3,25 +3,7 @@ local shenv = {}
|
||||
function shenv.quit()
|
||||
os.setenv("run",nil)
|
||||
end
|
||||
function shenv.cd(p)
|
||||
if p:sub(1,1) == "/" then
|
||||
if fs.list(p) then
|
||||
os.setenv("PWD",p)
|
||||
else
|
||||
print("no such directory: "..p)
|
||||
end
|
||||
else
|
||||
local np = {}
|
||||
for k,v in pairs(fs.segments(os.getenv("PWD").."/"..p)) do
|
||||
if v == ".." then
|
||||
np[#np] = nil
|
||||
else
|
||||
np[#np+1] = v
|
||||
end
|
||||
end
|
||||
os.setenv("PWD","/"..table.concat(np,"/"))
|
||||
end
|
||||
end
|
||||
shenv.cd = os.chdir
|
||||
setmetatable(shenv,{__index=function(_,k)
|
||||
if _G[k] then
|
||||
return _G[k]
|
||||
|
@ -1,6 +1,7 @@
|
||||
--#include "module/chatbox-dprint.lua"
|
||||
--#include "module/syslog.lua"
|
||||
--#include "module/sched.lua"
|
||||
--#include "module/osutil.lua"
|
||||
--#include "module/fs.lua"
|
||||
--#include "module/newio.lua"
|
||||
--#include "module/devfs.lua"
|
||||
|
18
module/osutil.lua
Normal file
18
module/osutil.lua
Normal file
@ -0,0 +1,18 @@
|
||||
function os.chdir(p) -- changes the current working directory of the calling process to the directory specified in *p*, returning true or false, error
|
||||
if not (p:sub(1,1) == "/") then
|
||||
local np = {}
|
||||
for k,v in pairs(fs.segments(os.getenv("PWD").."/"..p)) do
|
||||
if v == ".." then
|
||||
np[#np] = nil
|
||||
else
|
||||
np[#np+1] = v
|
||||
end
|
||||
end
|
||||
p = "/"..table.concat(np,"/")
|
||||
end
|
||||
if fs.exists(p) and fs.list(p) then
|
||||
os.setenv("PWD",p)
|
||||
else
|
||||
return false, "no such directory"
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
do
|
||||
--#include "module/vt100.lua"
|
||||
function vtemu(gpua,scra)
|
||||
function vtemu(gpua,scra) -- creates a process to handle the GPU and screen address combination *gpua*/*scra*. Returns read, write and "close" functions.
|
||||
local gpu = component.proxy(gpua)
|
||||
gpu.bind(scra)
|
||||
local write = vt100emu(gpu)
|
||||
|
@ -61,16 +61,16 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
cx, cy = tonumber(tx), tonumber(ty)
|
||||
mode = "n"
|
||||
elseif cc == "A" then -- cursor up
|
||||
cy = cy - tonumber(cs) or 1
|
||||
cy = cy - (tonumber(cs) or 1)
|
||||
mode = "n"
|
||||
elseif cc == "B" then -- cursor down
|
||||
cy = cy + tonumber(cs) or 1
|
||||
cy = cy + (tonumber(cs) or 1)
|
||||
mode = "n"
|
||||
elseif cc == "C" then -- cursor right
|
||||
cx = cx + tonumber(cs) or 1
|
||||
cx = cx + (tonumber(cs) or 1)
|
||||
mode = "n"
|
||||
elseif cc == "D" then -- cursor left
|
||||
cx = cx - tonumber(cs) or 1
|
||||
cx = cx - (tonumber(cs) or 1)
|
||||
mode = "n"
|
||||
elseif cc == "h" and lc == "7" then -- enable line wrap
|
||||
lw = true
|
||||
|
Loading…
Reference in New Issue
Block a user