diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 389c1a0..954d8c0 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -144,13 +144,8 @@ function Manager:init() end) singleThread('paste', function(text) - if clipboard.isInternal() then - text = clipboard.getData() - end - if text and type(text) == 'string' then - self:emitEvent({ type = 'paste', text = text }) - self.currentPage:sync() - end + self:emitEvent({ type = 'paste', text = text }) + self.currentPage:sync() end) singleThread('char', function(ch) @@ -1683,7 +1678,6 @@ function UI.Grid:eventHandler(event) elseif event.type == 'copy' then if self.selected then clipboard.setData(Util.tostring(self.selected)) - clipboard.useInternal(true) end else return false diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index e492942..9031817 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -127,6 +127,7 @@ function UI.VerticalTabBar:setParent() for k,c in pairs(self.children) do c.x = 1 c.y = k + 1 + c.ox, c.oy = c.x, c.y c.width = 8 end end diff --git a/sys/apps/multishell b/sys/apps/multishell index aa07d8d..ed967b1 100644 --- a/sys/apps/multishell +++ b/sys/apps/multishell @@ -134,7 +134,7 @@ local function draw() end end -local function selectTab( tab ) +local function selectTab(tab) if not tab then for _,ftab in pairs(tabs) do if not ftab.hidden then @@ -231,6 +231,9 @@ local function launchProcess(tab) local previousTab if tab.previousTabId then previousTab = tabs[tab.previousTabId] + if previousTab and previousTab.hidden then + previousTab = nil + end end selectTab(previousTab) end @@ -396,11 +399,7 @@ function multishell.hideTab(tabId) if tab then tab.hidden = true if currentTab.tabId == tabId then - if tabs[currentTab.previousTabId] then - multishell.setFocus(currentTab.previousTabId) - else - multishell.setFocus(overviewTab.tabId) - end + selectTab(tabs[currentTab.previousTabId]) end redrawMenu() end @@ -423,8 +422,9 @@ multishell.addHotkey(24, function() multishell.setFocus(overviewTab.tabId) end) +-- control-t - toggle clipboard mode multishell.addHotkey(20, function() - clipboard.useInternal(not clipboard.isInternal()) + _G.clipboard.useInternal(not _G.clipboard.isInternal()) end) -- control-backspace @@ -534,9 +534,15 @@ while true do draw() end + elseif sEvent == "paste" then + if _G.clipboard.isInternal() then + resumeTab(currentTab, sEvent, { _G.clipboard.getText() or '' }) + else + resumeTab(currentTab, sEvent, tEventData) + end + elseif sEvent == "char" or sEvent == "key" or - sEvent == "paste" or sEvent == "terminate" then processKeyEvent(sEvent, tEventData[1]) diff --git a/sys/boot/tlco.boot b/sys/boot/tlco.boot index 7939060..9e35802 100644 --- a/sys/boot/tlco.boot +++ b/sys/boot/tlco.boot @@ -1,37 +1,15 @@ local pullEvent = os.pullEventRaw -local redirect = term.redirect -local current = term.current local shutdown = os.shutdown -local cos = { } - -os.pullEventRaw = function(...) - local co = coroutine.running() - if not cos[co] then - cos[co] = true - error('die') - end - return pullEvent(...) -end - -os.shutdown = function() -end - -term.current = function() - term.redirect = function() - os.pullEventRaw = pullEvent - os.shutdown = shutdown - term.current = current - term.redirect = redirect - - term.redirect(term.native()) - --for co in pairs(cos) do - -- print(tostring(co) .. ' ' .. coroutine.status(co)) - --end - os.run(getfenv(1), 'sys/boot/multishell.boot') - os.run(getfenv(1), 'rom/programs/shell') - end +os.pullEventRaw = function() error('die') end +os.shutdown = function() + os.pullEventRaw = pullEvent + os.shutdown = shutdown + + os.run(getfenv(1), 'sys/boot/multishell.boot') +end + os.queueEvent('modem_message') diff --git a/sys/etc/app.db b/sys/etc/app.db index f1215d0..f85b0a9 100644 --- a/sys/etc/app.db +++ b/sys/etc/app.db @@ -243,6 +243,14 @@ \030f\03131\0308\031f \030f\03131\031e3", run = "https://pastebin.com/raw/nsKrHTbN", }, + [ "a2accffe95b2c8be30e8a05e0c6ab7e8f5966f43" ] = { + title = "Strafe", + category = "Games", + icon = "\030f\031f \03131\0308\031f \030f\031d2\ +\030f\031f \031d2\03131\0308\031f \030f\03131\ +\030f\03131\0308\031f \030f\03131\031e3", + run = "https://pastebin.com/raw/bj3qj1Pj", + }, [ "48d6857f6b2869d031f463b13aa34df47e18c548" ] = { title = "Breakout", category = "Games", diff --git a/sys/services/chat.lua b/sys/services/chat.lua index cb6436a..8ac7c45 100644 --- a/sys/services/chat.lua +++ b/sys/services/chat.lua @@ -1,58 +1,43 @@ local device = _G.device local multishell = _ENV.multishell local os = _G.os -local parallel = _G.parallel if device.wireless_modem then - multishell.setTitle(multishell.getCurrent(), 'Chat Daemon') + multishell.setTitle(multishell.getCurrent(), 'Chat') - local tab + multishell.openTab({ + path = 'rom/programs/rednet/chat', + args = { 'host', 'opusChat-' .. os.getComputerID() }, + title = 'Chat Daemon', + hidden = true, + }) - local function chatClient() + local tab = multishell.getTab(multishell.getCurrent()) - _G.requireInjector() + _G.requireInjector() - local Event = require('event') - local Util = require('util') - - local h = Event.addRoutine(function() - while true do - Util.run(_ENV, 'rom/programs/rednet/chat', - 'join', 'opusChat-' .. os.getComputerID(), 'owner') - end - end) + local Event = require('event') + local Util = require('util') + local h = Event.addRoutine(function() while true do - local e = { os.pullEventRaw() } - if e[1] == 'terminate' then - multishell.hideTab(tab.tabId) - else - if e[1] == 'rednet_message' and e[4] == 'chat' and e[3].sType == 'chat' then - if tab.hidden then - multishell.unhideTab(tab.tabId) - end + Util.run(_ENV, 'rom/programs/rednet/chat', + 'join', 'opusChat-' .. os.getComputerID(), 'owner') + end + end) + + while true do + local e = { os.pullEventRaw() } + if e[1] == 'terminate' then + multishell.hideTab(tab.tabId) + else + if e[1] == 'rednet_message' and e[4] == 'chat' and e[3].sType == 'chat' then + if tab.hidden then + multishell.unhideTab(tab.tabId) end - h:resume(unpack(e)) end + h:resume(table.unpack(e)) end end - - parallel.waitForAll( - function() - os.run(_ENV, 'rom/programs/rednet/chat', - 'host', 'opusChat-' .. os.getComputerID()) - end, - function() - os.sleep(3) - local tabId = multishell.openTab({ - fn = chatClient, - title = 'Chat', - hidden = true, - }) - tab = multishell.getTab(tabId) - end - ) - - print('Chat daemon stopped') end