diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index b670fc2..d8cb0ef 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -97,6 +97,7 @@ local page = UI.Page { width = 8, selectedBackgroundColor = 'primary', backgroundColor = 'tertiary', + unselectedTextColor = 'lightGray', layout = function(self) self.height = nil UI.TabBar.layout(self) diff --git a/sys/etc/fstab b/sys/etc/fstab index 60fb9e1..76f0a4e 100644 --- a/sys/etc/fstab +++ b/sys/etc/fstab @@ -2,5 +2,4 @@ sys/apps/pain.lua urlfs https://github.com/LDDestroier/CC/raw/master/pain.lua sys/apps/update.lua urlfs http://pastebin.com/raw/UzGHLbNC sys/apps/Enchat.lua urlfs https://raw.githubusercontent.com/LDDestroier/enchat/master/enchat3.lua sys/apps/cloud.lua urlfs https://cloud-catcher.squiddev.cc/cloud.lua -sys/apps/nfttrans.lua urlfs https://pastebin.com/raw/e8XrzeDY rom/modules/main/opus linkfs sys/modules/opus \ No newline at end of file diff --git a/sys/init/7.multishell.lua b/sys/init/7.multishell.lua index e7bb1e2..728a380 100644 --- a/sys/init/7.multishell.lua +++ b/sys/init/7.multishell.lua @@ -100,13 +100,33 @@ function multishell.launch(env, path, ...) }) end +local function chain(orig, fn) + if not orig then + return fn + end + + if type(orig) == 'table' then + table.insert(orig, fn) + return orig + end + + return setmetatable({ orig, fn }, { + __call = function(self, ...) + for _,v in pairs(self) do + v(...) + end + end + }) +end + function multishell.openTab(env, tab) if not tab.title and tab.path then tab.title = fs.getName(tab.path):match('([^%.]+)') end tab.title = tab.title or 'untitled' tab.window = tab.window or window.create(parentTerm, 1, 2, w, h - 1, false) - tab.onExit = tab.onExit or function(self, result, err, stack) + -- require('opus.terminal').window(parentTerm, 1, 2, w, h - 1, false) + tab.onExit = chain(tab.onExit, function(self, result, err, stack) if not result and err and err ~= 'Terminated' then self.terminal.setTextColor(colors.white) self.terminal.setCursorBlink(false) @@ -144,10 +164,7 @@ function multishell.openTab(env, tab) end end end - if tab.chainExit then - tab.chainExit(self, result, err, stack) - end - end + end) local routine, message = kernel.run(env, tab) diff --git a/sys/kernel.lua b/sys/kernel.lua index 446d227..3a86708 100644 --- a/sys/kernel.lua +++ b/sys/kernel.lua @@ -29,10 +29,8 @@ local focusedRoutineEvents = Util.transpose { } _G._syslog = function(pattern, ...) - local oldTerm = term.redirect(kernel.window) kernel.window.scrollBottom() - Util.print(pattern, ...) - term.redirect(oldTerm) + kernel.window.print(Util.tostring(pattern, ...)) end -- any function that runs in a kernel hook does not run in diff --git a/sys/modules/opus/terminal.lua b/sys/modules/opus/terminal.lua index 21fce97..88f4815 100644 --- a/sys/modules/opus/terminal.lua +++ b/sys/modules/opus/terminal.lua @@ -277,6 +277,79 @@ function Terminal.window(parent, sx, sy, w, h, isVisible) return parent end + function win.writeX(sText) + -- expect(1, sText, "string", "number") + local nLinesPrinted = 0 + local function newLine() + if cy + 1 <= win.canvas.height then + cx, cy = 1, cy + 1 + else + cx, cy = 1, win.canvas.height + win.scroll(1) + end + nLinesPrinted = nLinesPrinted + 1 + end + + -- Print the line with proper word wrapping + sText = tostring(sText) + while #sText > 0 do + local whitespace = string.match(sText, "^[ \t]+") + if whitespace then + -- Print whitespace + win.write(whitespace) + sText = string.sub(sText, #whitespace + 1) + end + + local newline = string.match(sText, "^\n") + if newline then + -- Print newlines + newLine() + sText = string.sub(sText, 2) + end + + local text = string.match(sText, "^[^ \t\n]+") + if text then + sText = string.sub(sText, #text + 1) + if #text > win.canvas.width then + -- Print a multiline word + while #text > 0 do + if cx > win.canvas.width then + newLine() + end + win.write(text) + text = string.sub(text, win.canvas.width - cx + 2) + end + else + -- Print a word normally + if cx + #text - 1 > win.canvas.width then + newLine() + end + win.write(text) + end + end + end + + return nLinesPrinted + end + + function win.print(...) + local vis = isVisible + isVisible = false + local nLinesPrinted = 0 + local nLimit = select("#", ...) + for n = 1, nLimit do + local s = tostring(select(n, ...)) + if n < nLimit then + s = s .. "\t" + end + nLinesPrinted = nLinesPrinted + win.writeX(s) + end + nLinesPrinted = nLinesPrinted + win.writeX("\n") + isVisible = vis + update() + return nLinesPrinted + end + win.canvas:clear() return win diff --git a/sys/modules/opus/ui.lua b/sys/modules/opus/ui.lua index 25c5083..87865ee 100644 --- a/sys/modules/opus/ui.lua +++ b/sys/modules/opus/ui.lua @@ -763,7 +763,7 @@ function UI.Window:fillArea(x, y, width, height, fillChar, bg, fg) end end -UI.Window.docs.write = [[write(NUMBER x, NUMBER y, String text, opt COLOR bg, opt COLOR fg) +UI.Window.docs.write = [[write(NUMBER x, NUMBER y, STRING text, opt COLOR bg, opt COLOR fg) Write text to the canvas. If colors are not specified, the colors from the base class will be used. If the base class does not have colors defined, colors will be inherited from the parent container.]] diff --git a/sys/modules/opus/ui/components/TabBar.lua b/sys/modules/opus/ui/components/TabBar.lua index 0f75e05..bed07c3 100644 --- a/sys/modules/opus/ui/components/TabBar.lua +++ b/sys/modules/opus/ui/components/TabBar.lua @@ -7,8 +7,6 @@ UI.TabBar.defaults = { UIElement = 'TabBar', buttonClass = 'TabBarMenuItem', backgroundColor = 'black', - selectedBackgroundColor = 'primary', - unselectedBackgroundColor = 'tertiary', } function UI.TabBar:enable() UI.MenuBar.enable(self) diff --git a/sys/modules/opus/ui/components/TabBarMenuItem.lua b/sys/modules/opus/ui/components/TabBarMenuItem.lua index 0ade0b0..0e28002 100644 --- a/sys/modules/opus/ui/components/TabBarMenuItem.lua +++ b/sys/modules/opus/ui/components/TabBarMenuItem.lua @@ -5,15 +5,16 @@ UI.TabBarMenuItem = class(UI.Button) UI.TabBarMenuItem.defaults = { UIElement = 'TabBarMenuItem', event = 'tab_select', - textInactiveColor = 'lightGray', } function UI.TabBarMenuItem:draw() if self.selected then self.backgroundColor = self:getProperty('selectedBackgroundColor') self.backgroundFocusColor = self.backgroundColor + self.textColor = self:getProperty('selectedTextColor') else self.backgroundColor = self:getProperty('unselectedBackgroundColor') self.backgroundFocusColor = self.backgroundColor + self.textColor = self:getProperty('unselectedTextColor') end UI.Button.draw(self) end diff --git a/sys/modules/opus/ui/components/Tabs.lua b/sys/modules/opus/ui/components/Tabs.lua index f2b61a8..566993a 100644 --- a/sys/modules/opus/ui/components/Tabs.lua +++ b/sys/modules/opus/ui/components/Tabs.lua @@ -6,6 +6,10 @@ UI.Tabs = class(UI.Window) UI.Tabs.docs = { } UI.Tabs.defaults = { UIElement = 'Tabs', + selectedBackgroundColor = 'primary', + unselectedBackgroundColor = 'tertiary', + unselectedTextColor = 'lightGray', + selectedTextColor = 'black', } function UI.Tabs:postInit() self:add(self)