diff --git a/halyde/config/shell.cfg b/halyde/config/shell.cfg index 4c460ae..c6c0594 100644 --- a/halyde/config/shell.cfg +++ b/halyde/config/shell.cfg @@ -1,4 +1,5 @@ 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 > " } diff --git a/halyde/core/boot.lua b/halyde/core/boot.lua index 8324790..b89b14b 100644 --- a/halyde/core/boot.lua +++ b/halyde/core/boot.lua @@ -1,7 +1,7 @@ local 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, ...) local args = table.pack(...) diff --git a/halyde/core/shell.lua b/halyde/core/shell.lua index 8abbcb1..9132b67 100644 --- a/halyde/core/shell.lua +++ b/halyde/core/shell.lua @@ -5,7 +5,7 @@ local event = import("event") _G.shell = {} _G.shell.workingDirectory = "/" -print("\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │\n ') +print(shellcfg["startupMessage"]) while true do coroutine.yield() -- print(shell.workingDirectory .. " >") diff --git a/halyde/lib/termlib.lua b/halyde/lib/termlib.lua index 84b4c69..f1e9b4d 100644 --- a/halyde/lib/termlib.lua +++ b/halyde/lib/termlib.lua @@ -2,7 +2,7 @@ local event = import("event") --local keyboard = import("keyboard") 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 = {} termlib.cursorPosX = 1 termlib.cursorPosY = 1 @@ -34,24 +34,25 @@ local ANSIColorPalette = { } } -defaultForegroundColor = ANSIColorPalette["dark"][7] +defaultForegroundColor = ANSIColorPalette["bright"][7] defaultBackgroundColor = ANSIColorPalette["dark"][0] gpu.setForeground(defaultForegroundColor) gpu.setBackground(defaultBackgroundColor) -function _G.scrollDown() - if gpu.copy(0,1,width,height-1,0,-1) then - gpu.set(0,height-1,string.rep(" ",width)) +local function scrollDown() + ocelot.log("scrolling") + if gpu.copy(0,1,width,height,0,-1) then + gpu.set(1,height,string.rep(" ",width)) + termlib.cursorPosY=height end end -function _G.newLine() +local function newLine() termlib.cursorPosX=1 termlib.cursorPosY = termlib.cursorPosY + 1 if termlib.cursorPosY>height then - _G.scrollDown() - termlib.cursorPosY=height + scrollDown() end end @@ -65,7 +66,7 @@ end 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 endNewLine = true @@ -170,21 +171,21 @@ function _G.read() local key = keyboard.keys[keycode] if args[3] >= 32 and args[3] <= 126 then curtext = curtext .. (unicode.char(args[3]) or "") - else if key == "back" then curtext = curtext:sub(1, #curtext-1) termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY - print(curtext.." ") + print(curtext.." ", false) elseif key == "enter" then + termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY + print(curtext) return curtext end end termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY - print(curtext) + if curtext == "" then print(" ", false) else print(curtext, false) end else cursorWhite = not cursorWhite - end end end