fix shell going crazy when hitting bottom of screen
This commit is contained in:
@@ -12,7 +12,7 @@ local fs = require("sys.fs")
|
|||||||
syscall.devctl(1,"clear")
|
syscall.devctl(1,"clear")
|
||||||
syscall.devctl(1,"sfgc",1)
|
syscall.devctl(1,"sfgc",1)
|
||||||
syscall.devctl(1,"spos",1,1)
|
syscall.devctl(1,"spos",1,1)
|
||||||
print("HyperionOS Bash Shell "..tostring(syscall.getpid()))
|
print("HyperionOS Bash Shell")
|
||||||
|
|
||||||
local userhost = (syscall.getUsername() or "Unknown").."@"..(syscall.getHostname() or "Unknown")
|
local userhost = (syscall.getUsername() or "Unknown").."@"..(syscall.getHostname() or "Unknown")
|
||||||
local commandHistory = {}
|
local commandHistory = {}
|
||||||
@@ -22,14 +22,10 @@ syscall.setEnviron("PATH","/bin/")
|
|||||||
syscall.chdir("/")
|
syscall.chdir("/")
|
||||||
|
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
syscall.devctl(1,"spos",(i * 3)-2,2)
|
|
||||||
syscall.devctl(1,"sbgc",i)
|
syscall.devctl(1,"sbgc",i)
|
||||||
printInline(" ");
|
printInline(" ");
|
||||||
syscall.devctl(1,"spos",(i * 3)-2,3)
|
|
||||||
syscall.devctl(1,"sbgc",16)
|
|
||||||
printInline(i);
|
|
||||||
end
|
end
|
||||||
syscall.devctl(1,"spos",1,4)
|
print("\n")
|
||||||
|
|
||||||
syscall.sigcatch(function(sig)
|
syscall.sigcatch(function(sig)
|
||||||
if sig == 1 then
|
if sig == 1 then
|
||||||
@@ -69,22 +65,30 @@ function getUserInput()
|
|||||||
end
|
end
|
||||||
elseif key == "=" then --TODO: REPLACE WITH UP ARROW
|
elseif key == "=" then --TODO: REPLACE WITH UP ARROW
|
||||||
if history < #commandHistory then
|
if history < #commandHistory then
|
||||||
|
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
||||||
|
printInline((" "):rep(#input + 1))
|
||||||
history = history + 1
|
history = history + 1
|
||||||
input = commandHistory[#commandHistory - history + 1]
|
input = commandHistory[#commandHistory - history + 1]
|
||||||
cursorPos = #input + 1
|
cursorPos = #input + 1
|
||||||
end
|
end
|
||||||
elseif key == "]" then --TODO: REPLACE WITH DOWN ARROW
|
elseif key == "]" then --TODO: REPLACE WITH DOWN ARROW
|
||||||
if history > 1 then
|
if history > 1 then
|
||||||
|
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
||||||
|
printInline((" "):rep(#input + 1))
|
||||||
history = history - 1
|
history = history - 1
|
||||||
input = commandHistory[#commandHistory - history + 1]
|
input = commandHistory[#commandHistory - history + 1]
|
||||||
cursorPos = #input + 1
|
cursorPos = #input + 1
|
||||||
elseif history == 1 then
|
elseif history == 1 then
|
||||||
|
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
||||||
|
printInline((" "):rep(#input + 1))
|
||||||
history = 0
|
history = 0
|
||||||
input = ""
|
input = ""
|
||||||
cursorPos = 1
|
cursorPos = 1
|
||||||
end
|
end
|
||||||
elseif key == "\b" then
|
elseif key == "\b" then
|
||||||
if cursorPos > 1 then
|
if cursorPos > 1 then
|
||||||
|
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
||||||
|
printInline((" "):rep(#input + 1))
|
||||||
input = string.sub(input, 1, cursorPos-2)..string.sub(input, cursorPos)
|
input = string.sub(input, 1, cursorPos-2)..string.sub(input, cursorPos)
|
||||||
cursorPos = cursorPos - 1
|
cursorPos = cursorPos - 1
|
||||||
end
|
end
|
||||||
@@ -96,6 +100,16 @@ function getUserInput()
|
|||||||
input = string.sub(input, 1, cursorPos-1)..key..string.sub(input, cursorPos)
|
input = string.sub(input, 1, cursorPos-1)..key..string.sub(input, cursorPos)
|
||||||
cursorPos = cursorPos + 1
|
cursorPos = cursorPos + 1
|
||||||
end
|
end
|
||||||
|
local screenSizeStr = syscall.devctl(1, "size")
|
||||||
|
local sizeX = tonumber(screenSizeStr:sub(1, screenSizeStr:find(";")-1))
|
||||||
|
local sizeY = tonumber(screenSizeStr:sub(screenSizeStr:find(";")+1))
|
||||||
|
local totalChars = sizeX * sizeY
|
||||||
|
local eocCharNum = ((curOffsetY - 1) * sizeX) + curOffsetX + #input
|
||||||
|
if eocCharNum >= totalChars then
|
||||||
|
syscall.devctl(1,"spos",sizeX,sizeY)
|
||||||
|
printInline(" ")
|
||||||
|
curOffsetY = curOffsetY - 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
|
||||||
printInline(string.sub(input, 1, cursorPos-1))
|
printInline(string.sub(input, 1, cursorPos-1))
|
||||||
@@ -111,7 +125,9 @@ function getUserInput()
|
|||||||
syscall.devctl(1,"sfgc",1)
|
syscall.devctl(1,"sfgc",1)
|
||||||
syscall.devctl(1,"sbgc",16)
|
syscall.devctl(1,"sbgc",16)
|
||||||
printInline(string.sub(input, cursorPos+1))
|
printInline(string.sub(input, cursorPos+1))
|
||||||
printInline((" "):rep(200))
|
if cursorPos <= #input then
|
||||||
|
printInline(" ")
|
||||||
|
end
|
||||||
local curBlink = ((math.floor(syscall.getUptime() / 500) % 2) == 0)
|
local curBlink = ((math.floor(syscall.getUptime() / 500) % 2) == 0)
|
||||||
if curBlink ~= blinkState then
|
if curBlink ~= blinkState then
|
||||||
blinkState = curBlink
|
blinkState = curBlink
|
||||||
@@ -181,6 +197,11 @@ function runCommand(command)
|
|||||||
end
|
end
|
||||||
if terminate then
|
if terminate then
|
||||||
local success, err = syscall.kill(proc)
|
local success, err = syscall.kill(proc)
|
||||||
|
if success then
|
||||||
|
syscall.devctl(1,"sfgc",2)
|
||||||
|
print("\nProgram Terminated.")
|
||||||
|
syscall.devctl(1,"sfgc",1)
|
||||||
|
end
|
||||||
terminate = false
|
terminate = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local syscalls=syscall.sysdump()
|
local syscalls=syscall.sysdump()
|
||||||
for i=1, #syscalls do
|
for i=1, #syscalls do
|
||||||
print(syscalls[i])
|
print(syscalls[i])
|
||||||
end
|
end
|
||||||
|
print("Total # of syscalls: "..tostring(#syscalls))
|
||||||
Reference in New Issue
Block a user