diff --git a/argentum.cfg b/argentum.cfg index 691763c..86d29be 100644 --- a/argentum.cfg +++ b/argentum.cfg @@ -1,7 +1,7 @@ local agcfg = { ["halyde"] = { ["maindir"] = "", - ["version"] = "1.1.0", + ["version"] = "1.2.0", ["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.", ["directories"] = { "halyde/apps", diff --git a/argentum/store/halyde/package.cfg b/argentum/store/halyde/package.cfg index f026529..cde2b9a 100644 --- a/argentum/store/halyde/package.cfg +++ b/argentum/store/halyde/package.cfg @@ -36,7 +36,7 @@ Ahalyde/lib/component.lua Ahalyde/lib/event.lua Ahalyde/lib/filesystem.lua Ahalyde/lib/raster.lua" -V1.0.0 +V1.2.0 Ahalyde/ Ahalyde/apps/ Ahalyde/apps/helpdb/ diff --git a/halyde/core/boot.lua b/halyde/core/boot.lua index dfcc7a7..4974eec 100644 --- a/halyde/core/boot.lua +++ b/halyde/core/boot.lua @@ -1,7 +1,38 @@ local loadfile = ... local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) -_G._OSVERSION = "Halyde 1.1.0" +_G._OSVERSION = "Halyde 1.2.0" + +local gpu = component.proxy(component.list("gpu")()) +local screenAddress = component.list("screen")() +local screen = component.proxy(screenAddress) + +gpu.bind(screenAddress) +local maxWidth, maxHeight = gpu.maxResolution() +local aspectX, aspectY = screen.getAspectRatio() +local screenRatio = aspectX * 2 / aspectY + +-- Calculate potential dimensions +local widthLimited = math.floor(maxHeight * screenRatio) +local heightLimited = math.floor(maxWidth / screenRatio) + +local targetWidth, targetHeight + +if widthLimited <= maxWidth then + -- Height is the limiting factor + targetWidth = widthLimited + targetHeight = maxHeight +else + -- Width is the limiting factor + targetWidth = maxWidth + targetHeight = heightLimited +end + +-- Ensure we never exceed maximum resolution +targetWidth = math.min(targetWidth, maxWidth) +targetHeight = math.min(targetHeight, maxHeight) + +gpu.setResolution(targetWidth, targetHeight) function _G.import(module, ...) local args = table.pack(...) diff --git a/halyde/core/termlib.lua b/halyde/core/termlib.lua index d2ff0ea..018b1ca 100644 --- a/halyde/core/termlib.lua +++ b/halyde/core/termlib.lua @@ -9,8 +9,6 @@ termlib.cursorPosY = 1 termlib.readHistory = {} local width, height = gpu.getResolution() -termlib.width = width -termlib.height = height local ANSIColorPalette = { ["dark"] = { @@ -42,6 +40,7 @@ gpu.setForeground(defaultForegroundColor) gpu.setBackground(defaultBackgroundColor) local function scrollDown() + width, height = gpu.getResolution() if gpu.copy(1,1,width,height,0,-1) then local prevForeground = gpu.getForeground() local prevBackground = gpu.getBackground() @@ -71,6 +70,7 @@ local function parseCodeNumbers(code) end function _G.print(text, endNewLine, textWrap) + width, height = gpu.getResolution() -- you don't know how tiring this was just for ANSI escape code support @@ -94,19 +94,19 @@ function _G.print(text, endNewLine, textWrap) -- unfortunately, changing the "i" variable would have unpredictable effects, so to not risk anything, this workaround was done. section = "" - function printSection() + local function printSection() if #section==0 then return end while true do gpu.set(termlib.cursorPosX,termlib.cursorPosY,section) - termlib.cursorPosX = termlib.cursorPosX+unicode.wlen(section) - if unicode.wlen(section) > width and textWrap then + if unicode.wlen(section) > width - termlib.cursorPosX + 1 and textWrap then + section = section:sub(width - termlib.cursorPosX + 2) newLine() else + termlib.cursorPosX = termlib.cursorPosX+unicode.wlen(section) break end - section = section:sub(width + 1) end section = "" end @@ -173,10 +173,10 @@ function _G.print(text, endNewLine, textWrap) end function _G.clear() - local xRes, yRes = gpu.getResolution() + width, height = gpu.getResolution() gpu.setForeground(defaultForegroundColor) gpu.setBackground(defaultBackgroundColor) - gpu.fill(1,1,xRes,yRes," ") + gpu.fill(1,1,width,height," ") termlib.cursorPosX, termlib.cursorPosY = 1, 1 end