v1.2.0 - Added GPU binding on startup and resolution matching to aspect ratio. Fixed a bug in the text wrapping as well.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
local agcfg = {
|
local agcfg = {
|
||||||
["halyde"] = {
|
["halyde"] = {
|
||||||
["maindir"] = "",
|
["maindir"] = "",
|
||||||
["version"] = "1.1.0",
|
["version"] = "1.2.0",
|
||||||
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
||||||
["directories"] = {
|
["directories"] = {
|
||||||
"halyde/apps",
|
"halyde/apps",
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Ahalyde/lib/component.lua
|
|||||||
Ahalyde/lib/event.lua
|
Ahalyde/lib/event.lua
|
||||||
Ahalyde/lib/filesystem.lua
|
Ahalyde/lib/filesystem.lua
|
||||||
Ahalyde/lib/raster.lua"
|
Ahalyde/lib/raster.lua"
|
||||||
V1.0.0
|
V1.2.0
|
||||||
Ahalyde/
|
Ahalyde/
|
||||||
Ahalyde/apps/
|
Ahalyde/apps/
|
||||||
Ahalyde/apps/helpdb/
|
Ahalyde/apps/helpdb/
|
||||||
|
|||||||
+32
-1
@@ -1,7 +1,38 @@
|
|||||||
local loadfile = ...
|
local loadfile = ...
|
||||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(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, ...)
|
function _G.import(module, ...)
|
||||||
local args = table.pack(...)
|
local args = table.pack(...)
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ termlib.cursorPosY = 1
|
|||||||
termlib.readHistory = {}
|
termlib.readHistory = {}
|
||||||
|
|
||||||
local width, height = gpu.getResolution()
|
local width, height = gpu.getResolution()
|
||||||
termlib.width = width
|
|
||||||
termlib.height = height
|
|
||||||
|
|
||||||
local ANSIColorPalette = {
|
local ANSIColorPalette = {
|
||||||
["dark"] = {
|
["dark"] = {
|
||||||
@@ -42,6 +40,7 @@ gpu.setForeground(defaultForegroundColor)
|
|||||||
gpu.setBackground(defaultBackgroundColor)
|
gpu.setBackground(defaultBackgroundColor)
|
||||||
|
|
||||||
local function scrollDown()
|
local function scrollDown()
|
||||||
|
width, height = gpu.getResolution()
|
||||||
if gpu.copy(1,1,width,height,0,-1) then
|
if gpu.copy(1,1,width,height,0,-1) then
|
||||||
local prevForeground = gpu.getForeground()
|
local prevForeground = gpu.getForeground()
|
||||||
local prevBackground = gpu.getBackground()
|
local prevBackground = gpu.getBackground()
|
||||||
@@ -71,6 +70,7 @@ local function parseCodeNumbers(code)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _G.print(text, endNewLine, textWrap)
|
function _G.print(text, endNewLine, textWrap)
|
||||||
|
width, height = gpu.getResolution()
|
||||||
|
|
||||||
-- you don't know how tiring this was just for ANSI escape code support
|
-- 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.
|
-- unfortunately, changing the "i" variable would have unpredictable effects, so to not risk anything, this workaround was done.
|
||||||
section = ""
|
section = ""
|
||||||
|
|
||||||
function printSection()
|
local function printSection()
|
||||||
if #section==0 then
|
if #section==0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
while true do
|
while true do
|
||||||
gpu.set(termlib.cursorPosX,termlib.cursorPosY,section)
|
gpu.set(termlib.cursorPosX,termlib.cursorPosY,section)
|
||||||
termlib.cursorPosX = termlib.cursorPosX+unicode.wlen(section)
|
if unicode.wlen(section) > width - termlib.cursorPosX + 1 and textWrap then
|
||||||
if unicode.wlen(section) > width and textWrap then
|
section = section:sub(width - termlib.cursorPosX + 2)
|
||||||
newLine()
|
newLine()
|
||||||
else
|
else
|
||||||
|
termlib.cursorPosX = termlib.cursorPosX+unicode.wlen(section)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
section = section:sub(width + 1)
|
|
||||||
end
|
end
|
||||||
section = ""
|
section = ""
|
||||||
end
|
end
|
||||||
@@ -173,10 +173,10 @@ function _G.print(text, endNewLine, textWrap)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _G.clear()
|
function _G.clear()
|
||||||
local xRes, yRes = gpu.getResolution()
|
width, height = gpu.getResolution()
|
||||||
gpu.setForeground(defaultForegroundColor)
|
gpu.setForeground(defaultForegroundColor)
|
||||||
gpu.setBackground(defaultBackgroundColor)
|
gpu.setBackground(defaultBackgroundColor)
|
||||||
gpu.fill(1,1,xRes,yRes," ")
|
gpu.fill(1,1,width,height," ")
|
||||||
termlib.cursorPosX, termlib.cursorPosY = 1, 1
|
termlib.cursorPosX, termlib.cursorPosY = 1, 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user