Skip to content

Commit

Permalink
EMCO: Allow creation without tabs (#67)
Browse files Browse the repository at this point in the history
Currently, if EMCO is initialized by passing an empty table it throws an error. This fix allows it to be initialized without tabs.

Co-authored-by: Borna <>
  • Loading branch information
Bornasm committed Dec 21, 2023
1 parent 1ee2687 commit 006d3e3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/resources/emco.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local EMCO = Geyser.Container:new({
tabBoxColor = "black",
consoleContainerCSS = "",
consoleContainerColor = "black",
noTabMessage = [[<center>No tabs added...</center>]],
tabHeight = 25,
leftMargin = 0,
rightMargin = 0,
Expand Down Expand Up @@ -236,6 +237,11 @@ end
-- <td>"black"</td>
-- </tr>
-- <tr>
-- <td>noTabMessage</td>
-- <td>Message shown in the parent label when there are no tabs added.</td>
-- <td>[[<center>No tabs added...</center>]]</td>
-- </tr>
-- <tr>
-- <td>gap</td>
-- <td>How many pixels to place between the tabs and the miniconsoles?</td>
-- <td>1</td>
Expand Down Expand Up @@ -1045,6 +1051,12 @@ end
--- resets the object, redrawing everything
function EMCO:reset()
self:createContainers()

if next(self.consoles) == nil then
-- Stop execution if there are no consoles, this happens if EMCO is initialized by passing an empty table into consoles property
return
end

for _, tabName in ipairs(self.consoles) do
self:createComponentsForTab(tabName)
end
Expand Down Expand Up @@ -1074,6 +1086,7 @@ function EMCO:createContainers()
width = "100%",
height = "-0px",
name = self.name .. "ConsoleContainer",
message = self.noTabMessage
}, self)
self.consoleContainer:setStyleSheet(self.consoleContainerCSS)
self.consoleContainer:setColor(self.consoleContainerColor)
Expand Down Expand Up @@ -2212,6 +2225,7 @@ function EMCO:save()
tabBoxColor = self.tabBoxColor,
consoleContainerCSS = self.consoleContainerCSS,
consoleContainerColor = self.consoleContainerColor,
noTabMessage = self.noTabMessage,
gap = self.gap,
consoles = self.consoles,
allTabExclusions = self.allTabExclusions,
Expand Down Expand Up @@ -2288,6 +2302,7 @@ function EMCO:load()
self.tabBoxColor = configTable.tabBoxColor
self.consoleContainerCSS = configTable.consoleContainerCSS
self.consoleContainerColor = configTable.consoleContainerColor
self.noTabMessage = configTable.noTabMessage
self.gap = configTable.gap
self.consoles = configTable.consoles
self.allTabExclusions = configTable.allTabExclusions
Expand Down

0 comments on commit 006d3e3

Please sign in to comment.