From b464270e602b5f3e4420c77be970ddbae07391b1 Mon Sep 17 00:00:00 2001 From: Rivulet Date: Sat, 25 Oct 2025 16:10:49 -0700 Subject: [PATCH] toggleable fullscreen button --- apps/worm.lua | 1 + libs/window.lua | 1 + modules/interactions.lua | 4 ++-- startup.lua | 4 +++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/worm.lua b/apps/worm.lua index 2c65682..17c10bb 100644 --- a/apps/worm.lua +++ b/apps/worm.lua @@ -3,6 +3,7 @@ local window = require("libs.window") local x, y = term.getSize() local win = window.create("Worm", x / 1.4, y / 1.4, x / 2 - ((x / 1.4) / 2), y / 2 - ((y / 1.5) / 2)) win.resizable = false +win.fullscreenButton = false sleep() compat.runFile("/rom/programs/fun/worm.lua", win) win.close() diff --git a/libs/window.lua b/libs/window.lua index 9e81923..1b95b4b 100644 --- a/libs/window.lua +++ b/libs/window.lua @@ -83,6 +83,7 @@ function lib.create(name, w, h, x, y, do_not_add) decorations = true, alwaysOnTop = false, alwaysBelow = false, + fullscreenButton = true, closing = false, _palette = {}, -- optional local palette store } diff --git a/modules/interactions.lua b/modules/interactions.lua index 733d2a0..784e360 100644 --- a/modules/interactions.lua +++ b/modules/interactions.lua @@ -50,7 +50,7 @@ while true do dragging = win resizing = true bringtofront(indx) - elseif ((y - 1 == data[4] and x + 2 <= data[3] and x + w >= data[3] and data[2] == 1 and win.decorations) or (y <= data[4] and x <= data[3] and y + h > data[4] and x + w > data[3] and key[keys["leftAlt"]] and win.draggable)) and not win.isFullscreen then + elseif ((y - 1 == data[4] and x + 1 + (win.fullscreenButton and 1 or 0) <= data[3] and x + w >= data[3] and data[2] == 1 and win.decorations) or (y <= data[4] and x <= data[3] and y + h > data[4] and x + w > data[3] and key[keys["leftAlt"]] and win.draggable)) and not win.isFullscreen then dragging = win offsetX = x - data[3] offsetY = y - data[4] @@ -60,7 +60,7 @@ while true do threading.addThread(function() win.closeRequested() end) bringtofront(indx) break - elseif y - 1 == data[4] and x+1 == data[3] and win.decorations then + elseif y - 1 == data[4] and x+1 == data[3] and win.decorations and win.fullscreenButton then threading.addThread(function() win.fullscreen() end) bringtofront(indx) break diff --git a/startup.lua b/startup.lua index 7f5befe..16666d7 100644 --- a/startup.lua +++ b/startup.lua @@ -99,7 +99,9 @@ local function windows() term.setCursorPos(x, y - 1) term.setTextColor(colors.white) term.setBackgroundColor(colors.blue) - term.write(string.sub("XO " .. win.name .. string.rep(" ", w - #win.name - 3),1,w)) + local window_buttons = "X" + if win.fullscreenButton then window_buttons = window_buttons.."O" end + term.write(string.sub(window_buttons.." " .. win.name .. string.rep(" ", w - #win.name -1 -#window_buttons),1,w)) if win.resizable and not win.isFullscreen then term.setCursorPos(x+w-1,y+h-1) term.write("\127")