v0.5.1 - Squashed a few bugs, added the startup message to shell.cfg to make it modifiable.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
local shellcfg = {
|
local shellcfg = {
|
||||||
|
["startupMessage"] = "\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │\n ', -- message shown on startup
|
||||||
["prompt"] = "\x1b[92m%s > \x1b[0m" -- shell prompt, %s will be replaced with working directory. example: "%s > " turns to "/current/working/directory > "
|
["prompt"] = "\x1b[92m%s > \x1b[0m" -- shell prompt, %s will be replaced with working directory. example: "%s > " turns to "/current/working/directory > "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local loadfile = ...
|
local loadfile = ...
|
||||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||||
|
|
||||||
_G._OSVERSION = "Halyde 0.5.0"
|
_G._OSVERSION = "Halyde 0.5.1"
|
||||||
|
|
||||||
function _G.import(module, ...)
|
function _G.import(module, ...)
|
||||||
local args = table.pack(...)
|
local args = table.pack(...)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local event = import("event")
|
|||||||
_G.shell = {}
|
_G.shell = {}
|
||||||
_G.shell.workingDirectory = "/"
|
_G.shell.workingDirectory = "/"
|
||||||
|
|
||||||
print("\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │\n ')
|
print(shellcfg["startupMessage"])
|
||||||
while true do
|
while true do
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
-- print(shell.workingDirectory .. " >")
|
-- print(shell.workingDirectory .. " >")
|
||||||
|
|||||||
+14
-13
@@ -2,7 +2,7 @@ local event = import("event")
|
|||||||
--local keyboard = import("keyboard")
|
--local keyboard = import("keyboard")
|
||||||
|
|
||||||
local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented
|
local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented
|
||||||
--local ocelot = component.proxy(component.list("ocelot")())
|
local ocelot = component.proxy(component.list("ocelot")())
|
||||||
_G.termlib = {}
|
_G.termlib = {}
|
||||||
termlib.cursorPosX = 1
|
termlib.cursorPosX = 1
|
||||||
termlib.cursorPosY = 1
|
termlib.cursorPosY = 1
|
||||||
@@ -34,24 +34,25 @@ local ANSIColorPalette = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultForegroundColor = ANSIColorPalette["dark"][7]
|
defaultForegroundColor = ANSIColorPalette["bright"][7]
|
||||||
defaultBackgroundColor = ANSIColorPalette["dark"][0]
|
defaultBackgroundColor = ANSIColorPalette["dark"][0]
|
||||||
|
|
||||||
gpu.setForeground(defaultForegroundColor)
|
gpu.setForeground(defaultForegroundColor)
|
||||||
gpu.setBackground(defaultBackgroundColor)
|
gpu.setBackground(defaultBackgroundColor)
|
||||||
|
|
||||||
function _G.scrollDown()
|
local function scrollDown()
|
||||||
if gpu.copy(0,1,width,height-1,0,-1) then
|
ocelot.log("scrolling")
|
||||||
gpu.set(0,height-1,string.rep(" ",width))
|
if gpu.copy(0,1,width,height,0,-1) then
|
||||||
|
gpu.set(1,height,string.rep(" ",width))
|
||||||
|
termlib.cursorPosY=height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _G.newLine()
|
local function newLine()
|
||||||
termlib.cursorPosX=1
|
termlib.cursorPosX=1
|
||||||
termlib.cursorPosY = termlib.cursorPosY + 1
|
termlib.cursorPosY = termlib.cursorPosY + 1
|
||||||
if termlib.cursorPosY>height then
|
if termlib.cursorPosY>height then
|
||||||
_G.scrollDown()
|
scrollDown()
|
||||||
termlib.cursorPosY=height
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ end
|
|||||||
|
|
||||||
function _G.print(text,endNewLine)
|
function _G.print(text,endNewLine)
|
||||||
|
|
||||||
-- you don't know how tiring this took just for ANSI escape code support
|
-- you don't know how tiring this was just for ANSI escape code support
|
||||||
|
|
||||||
if endNewLine==nil then
|
if endNewLine==nil then
|
||||||
endNewLine = true
|
endNewLine = true
|
||||||
@@ -170,21 +171,21 @@ function _G.read()
|
|||||||
local key = keyboard.keys[keycode]
|
local key = keyboard.keys[keycode]
|
||||||
if args[3] >= 32 and args[3] <= 126 then
|
if args[3] >= 32 and args[3] <= 126 then
|
||||||
curtext = curtext .. (unicode.char(args[3]) or "")
|
curtext = curtext .. (unicode.char(args[3]) or "")
|
||||||
|
|
||||||
else
|
else
|
||||||
if key == "back" then
|
if key == "back" then
|
||||||
curtext = curtext:sub(1, #curtext-1)
|
curtext = curtext:sub(1, #curtext-1)
|
||||||
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
||||||
print(curtext.." ")
|
print(curtext.." ", false)
|
||||||
elseif key == "enter" then
|
elseif key == "enter" then
|
||||||
|
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
||||||
|
print(curtext)
|
||||||
return curtext
|
return curtext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
||||||
print(curtext)
|
if curtext == "" then print(" ", false) else print(curtext, false) end
|
||||||
else
|
else
|
||||||
cursorWhite = not cursorWhite
|
cursorWhite = not cursorWhite
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user