diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index 722127e..b5edf39 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -51,7 +51,7 @@ local config = { } Config.load('Overview', config) -local extSupport = Util.getVersion() >= 1.76 +local extSupport = Util.supportsExtChars() local applications = { } local buttons = { } diff --git a/sys/apps/system/label.lua b/sys/apps/system/label.lua index ba38109..61d3698 100644 --- a/sys/apps/system/label.lua +++ b/sys/apps/system/label.lua @@ -26,12 +26,12 @@ return UI.Tab { x = 2, y = 5, ex = -2, ey = -2, values = { { name = '', value = '' }, - { name = 'CC version', value = Util.getVersion() }, - { name = 'Lua version', value = _VERSION }, - { name = 'MC version', value = Util.getMinecraftVersion() }, - { name = 'Disk free', value = Util.toBytes(fs.getFreeSpace('/')) }, - { name = 'Computer ID', value = tostring(os.getComputerID()) }, - { name = 'Day', value = tostring(os.day()) }, + { name = 'CC version', value = ("%d.%d"):format(Util.getVersion()) }, + { name = 'Lua version', value = _VERSION }, + { name = 'MC version', value = Util.getMinecraftVersion() }, + { name = 'Disk free', value = Util.toBytes(fs.getFreeSpace('/')) }, + { name = 'Computer ID', value = tostring(os.getComputerID()) }, + { name = 'Day', value = tostring(os.day()) }, }, disableHeader = true, inactive = true, diff --git a/sys/init/7.multishell.lua b/sys/init/7.multishell.lua index 728a380..b799584 100644 --- a/sys/init/7.multishell.lua +++ b/sys/init/7.multishell.lua @@ -14,7 +14,7 @@ local parentTerm = _G.device.terminal local w,h = parentTerm.getSize() local overviewId local tabsDirty = false -local closeInd = Util.getVersion() >= 1.76 and '\215' or '*' +local closeInd = Util.supportsExtChars() and '\215' or '*' local multishell = { } _ENV.multishell = multishell diff --git a/sys/modules/opus/ui.lua b/sys/modules/opus/ui.lua index 8451e1d..c5b412e 100644 --- a/sys/modules/opus/ui.lua +++ b/sys/modules/opus/ui.lua @@ -44,7 +44,7 @@ function UI:init() tertiary = colors.gray, } } - self.extChars = Util.getVersion() >= 1.76 + self.extChars = Util.supportsExtChars() local function keyFunction(event, code, held) local ie = Input:translate(event, code, held) diff --git a/sys/modules/opus/util.lua b/sys/modules/opus/util.lua index 484231b..fac9269 100644 --- a/sys/modules/opus/util.lua +++ b/sys/modules/opus/util.lua @@ -170,16 +170,19 @@ function Util.print(pattern, ...) end function Util.getVersion() - local version + local versionString = _G._HOST or _G._CC_VERSION + local versionMajor, versionMinor = versionString:match("(%d+)%.(%d+)") + -- ex.: 1.89 would return 1, 89 + return versionMajor, versionMinor +end - if _G._CC_VERSION then - version = tonumber(_G._CC_VERSION:match('[%d]+%.?[%d][%d]')) - end - if not version and _G._HOST then - version = tonumber(_G._HOST:match('[%d]+%.?[%d][%d]')) - end +function Util.compareVersion(major, minor) + local currentMajor, currentMinor = Util.getVersion() + return currentMajor > major or currentMajor == major and currentMinor >= minor +end - return version or 1.7 +function Util.supportsExtChars() + return Util.compareVersion(1, 76) end function Util.getMinecraftVersion()