Compare commits
3 Commits
0d7e6eb8e5
...
3c235a7513
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c235a7513 | |||
| f29770e3f0 | |||
| 63c3e4e273 |
@@ -231,12 +231,16 @@ registerEventListener("modem_message", handleMessages)
|
||||
--[[
|
||||
key handling
|
||||
]]
|
||||
local GLFW_KEY_DOWN = 264
|
||||
local GLFW_KEY_UP = 265
|
||||
local GLFW_KEY_ENTER = 257
|
||||
|
||||
local logOffset = 0
|
||||
|
||||
function scrollLogs(key, isHeld)
|
||||
if key == 264 then
|
||||
if key == GLFW_KEY_DOWN then
|
||||
logOffset = logOffset - 1
|
||||
elseif key == 265 then
|
||||
elseif key == GLFW_KEY_UP then
|
||||
logOffset = logOffset + 1
|
||||
end
|
||||
|
||||
@@ -246,6 +250,29 @@ end
|
||||
|
||||
registerEventListener("key", scrollLogs)
|
||||
|
||||
--[[
|
||||
console
|
||||
]]
|
||||
local commandBuffer = ""
|
||||
function drawConsole(y)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function handleConsoleInput(char)
|
||||
commandBuffer = commandBuffer..char
|
||||
end
|
||||
registerEventListener("char", handleConsoleInput)
|
||||
|
||||
function handleConsoleKeys(key)
|
||||
if key == GLFW_KEY_ENTER then
|
||||
-- executeCommand(commandBuffer)
|
||||
log.info("Executed command: %s", commandBuffer)
|
||||
commandBuffer = ""
|
||||
end
|
||||
end
|
||||
registerEventListener("key", handleConsoleKeys)
|
||||
|
||||
--[[
|
||||
drawing functions
|
||||
]]
|
||||
@@ -323,6 +350,23 @@ function drawStatusBar(y)
|
||||
term.write(str)
|
||||
end
|
||||
|
||||
function drawCommandBar(w, y)
|
||||
term.setCursorPos(0, y)
|
||||
term.clearLine()
|
||||
|
||||
term.setBackgroundColor(colors.white)
|
||||
term.setTextColor(colors.black)
|
||||
|
||||
term.write("$ ")
|
||||
|
||||
local startingIndex = commandBuffer:len() - w - 3
|
||||
if startingIndex < 0 then
|
||||
startingIndex = 0
|
||||
end
|
||||
|
||||
term.write(commandBuffer:sub(startingIndex))
|
||||
end
|
||||
|
||||
--[[
|
||||
main loop functions
|
||||
]]
|
||||
@@ -352,8 +396,9 @@ function updateScreen()
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setTextColour(colors.white)
|
||||
|
||||
drawLogs(1, 2, w, h - 1)
|
||||
drawStatusBar(h)
|
||||
drawLogs(1, 2, w, h - 2)
|
||||
drawStatusBar(2)
|
||||
drawCommandBar(w, h)
|
||||
end
|
||||
|
||||
function pollEvents()
|
||||
|
||||
Reference in New Issue
Block a user