mwm bug fixes
This commit is contained in:
@@ -598,6 +598,7 @@ end)
|
|||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
|
|
||||||
|
--[[
|
||||||
Event.onTerminate(function()
|
Event.onTerminate(function()
|
||||||
spt = Point.above(locate())
|
spt = Point.above(locate())
|
||||||
for _, v in pairs(pool) do
|
for _, v in pairs(pool) do
|
||||||
@@ -606,6 +607,7 @@ Event.onTerminate(function()
|
|||||||
end
|
end
|
||||||
abort = true
|
abort = true
|
||||||
end)
|
end)
|
||||||
|
]]
|
||||||
|
|
||||||
Event.pullEvents()
|
Event.pullEvents()
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,15 @@ local monDim, termDim = { }, { }
|
|||||||
monDim.width, monDim.height = parentMon.getSize()
|
monDim.width, monDim.height = parentMon.getSize()
|
||||||
termDim.width, termDim.height = parentTerm.getSize()
|
termDim.width, termDim.height = parentTerm.getSize()
|
||||||
|
|
||||||
local monitor = Terminal.window(parentMon, 1, 1, monDim.width, monDim.height, false)
|
-- even though the monitor window is set to visible
|
||||||
|
-- the canvas is not (possibly change default in terminal.lua)
|
||||||
|
|
||||||
|
-- canvas is not visible so that redraws
|
||||||
|
-- are done once in the event loop
|
||||||
|
local monitor = Terminal.window(parentMon, 1, 1, monDim.width, monDim.height, true)
|
||||||
monitor.setBackgroundColor(colors.gray)
|
monitor.setBackgroundColor(colors.gray)
|
||||||
monitor.clear()
|
monitor.clear()
|
||||||
|
|
||||||
monitor.canvas:setVisible(true)
|
|
||||||
|
|
||||||
local function nextUID()
|
local function nextUID()
|
||||||
UID = UID + 1
|
UID = UID + 1
|
||||||
return UID
|
return UID
|
||||||
@@ -72,7 +75,9 @@ end
|
|||||||
local function redraw()
|
local function redraw()
|
||||||
--monitor.clear()
|
--monitor.clear()
|
||||||
monitor.canvas:dirty()
|
monitor.canvas:dirty()
|
||||||
for k,process in ipairs(processes) do
|
--monitor.setBackgroundColor(colors.gray)
|
||||||
|
monitor.canvas:clear(colors.gray)
|
||||||
|
for k, process in ipairs(processes) do
|
||||||
process.container.canvas:dirty()
|
process.container.canvas:dirty()
|
||||||
process:focus(k == #processes)
|
process:focus(k == #processes)
|
||||||
end
|
end
|
||||||
@@ -94,11 +99,11 @@ end
|
|||||||
local Process = { }
|
local Process = { }
|
||||||
|
|
||||||
function Process:new(args)
|
function Process:new(args)
|
||||||
|
|
||||||
args.env = args.env or Util.shallowCopy(defaultEnv)
|
args.env = args.env or Util.shallowCopy(defaultEnv)
|
||||||
args.width = args.width or termDim.width
|
args.width = args.width or termDim.width
|
||||||
args.height = args.height or termDim.height
|
args.height = args.height or termDim.height
|
||||||
|
|
||||||
|
-- TODO: randomize start position
|
||||||
local self = setmetatable({
|
local self = setmetatable({
|
||||||
uid = nextUID(),
|
uid = nextUID(),
|
||||||
x = args.x or 1,
|
x = args.x or 1,
|
||||||
@@ -111,18 +116,22 @@ function Process:new(args)
|
|||||||
}, { __index = Process })
|
}, { __index = Process })
|
||||||
|
|
||||||
self:adjustDimensions()
|
self:adjustDimensions()
|
||||||
|
if not args.x then
|
||||||
|
self.x = math.random(1, monDim.width - self.width + 1)
|
||||||
|
self.y = math.random(1, monDim.height - self.height + 1)
|
||||||
|
end
|
||||||
|
|
||||||
self.container = Terminal.window(monitor, self.x, self.y, self.width, self.height, false)
|
self.container = Terminal.window(monitor, self.x, self.y, self.width, self.height, true)
|
||||||
self.window = window.create(self.container, 2, 3, args.width, args.height, true)
|
self.window = window.create(self.container, 2, 3, args.width, args.height, true)
|
||||||
|
|
||||||
self.terminal = self.window
|
self.terminal = self.window
|
||||||
|
|
||||||
self.container.canvas.parent = monitor.canvas
|
self.container.canvas.parent = monitor.canvas
|
||||||
table.insert(monitor.canvas.layers, self.container.canvas)
|
table.insert(monitor.canvas.layers, 1, self.container.canvas)
|
||||||
self.container.canvas:setVisible(true)
|
self.container.canvas:setVisible(true)
|
||||||
|
|
||||||
self.co = coroutine.create(function()
|
--self.container.getSize = self.window.getSize
|
||||||
|
|
||||||
|
self.co = coroutine.create(function()
|
||||||
local result, err
|
local result, err
|
||||||
|
|
||||||
if args.fn then
|
if args.fn then
|
||||||
@@ -217,9 +226,10 @@ function Process:reposition()
|
|||||||
self.container.reposition(self.x, self.y, self.width, self.height)
|
self.container.reposition(self.x, self.y, self.width, self.height)
|
||||||
self.container.setBackgroundColor(colors.black)
|
self.container.setBackgroundColor(colors.black)
|
||||||
self.container.clear()
|
self.container.clear()
|
||||||
|
|
||||||
self.window.reposition(2, 3, self.width - 2, self.height - 3)
|
self.window.reposition(2, 3, self.width - 2, self.height - 3)
|
||||||
|
if self.window ~= self.terminal then
|
||||||
|
self.terminal.reposition(1, 1, self.width - 2, self.height - 3)
|
||||||
|
end
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -267,7 +277,8 @@ function Process:resume(event, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not self.filter or self.filter == event or event == "terminate" then
|
if not self.filter or self.filter == event or event == "terminate" then
|
||||||
term.redirect(self.terminal)
|
--term.redirect(self.terminal)
|
||||||
|
local previousTerm = term.redirect(self.terminal)
|
||||||
|
|
||||||
local previous = running
|
local previous = running
|
||||||
running = self -- stupid shell set title
|
running = self -- stupid shell set title
|
||||||
@@ -275,6 +286,8 @@ function Process:resume(event, ...)
|
|||||||
running = previous
|
running = previous
|
||||||
|
|
||||||
self.terminal = term.current()
|
self.terminal = term.current()
|
||||||
|
term.redirect(previousTerm)
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
self.filter = result
|
self.filter = result
|
||||||
else
|
else
|
||||||
@@ -355,13 +368,12 @@ function multishell.openTab(tabInfo)
|
|||||||
|
|
||||||
table.insert(processes, 1, process)
|
table.insert(processes, 1, process)
|
||||||
|
|
||||||
--process.container.canvas:setVisible(true)
|
--local previousTerm = term.current()
|
||||||
|
|
||||||
local previousTerm = term.current()
|
|
||||||
process:resume()
|
process:resume()
|
||||||
term.redirect(previousTerm)
|
--term.redirect(previousTerm)
|
||||||
|
|
||||||
multishell.saveSession(sessionFile)
|
multishell.saveSession(sessionFile)
|
||||||
|
|
||||||
return process.uid
|
return process.uid
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -370,12 +382,12 @@ function multishell.removeProcess(process)
|
|||||||
process.container.canvas:removeLayer()
|
process.container.canvas:removeLayer()
|
||||||
|
|
||||||
multishell.saveSession(sessionFile)
|
multishell.saveSession(sessionFile)
|
||||||
--redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function multishell.saveSession(filename)
|
function multishell.saveSession(filename)
|
||||||
local t = { }
|
local t = { }
|
||||||
for _,process in pairs(processes) do
|
for _,process in ipairs(processes) do
|
||||||
if process.path and not process.isShell then
|
if process.path and not process.isShell then
|
||||||
table.insert(t, {
|
table.insert(t, {
|
||||||
x = process.x,
|
x = process.x,
|
||||||
@@ -393,8 +405,8 @@ end
|
|||||||
function multishell.loadSession(filename)
|
function multishell.loadSession(filename)
|
||||||
local config = Util.readTable(filename)
|
local config = Util.readTable(filename)
|
||||||
if config then
|
if config then
|
||||||
for _,v in pairs(config) do
|
for k = #config, 1, -1 do
|
||||||
multishell.openTab(v)
|
multishell.openTab(config[k])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -423,6 +435,7 @@ function multishell.start()
|
|||||||
if process then
|
if process then
|
||||||
if key ~= #processes then
|
if key ~= #processes then
|
||||||
multishell.setFocus(process.uid)
|
multishell.setFocus(process.uid)
|
||||||
|
multishell.saveSession(sessionFile)
|
||||||
end
|
end
|
||||||
process:click(x - process.x + 1, y - process.y + 1)
|
process:click(x - process.x + 1, y - process.y + 1)
|
||||||
|
|
||||||
@@ -464,17 +477,10 @@ function multishell.start()
|
|||||||
end
|
end
|
||||||
|
|
||||||
monitor.canvas:render(parentMon)
|
monitor.canvas:render(parentMon)
|
||||||
local didRedraw = true
|
|
||||||
|
|
||||||
local focused = processes[#processes]
|
local focused = processes[#processes]
|
||||||
if didRedraw and focused then
|
if focused then
|
||||||
--focused.container.canvas:dirty()
|
|
||||||
--focused.container.canvas:redraw(parentTerm)
|
|
||||||
focused.window.restoreCursor()
|
focused.window.restoreCursor()
|
||||||
local cx, cy = focused.container.getCursorPos()
|
|
||||||
monitor.setCursorPos(
|
|
||||||
focused.container.canvas.x + cx - 1,
|
|
||||||
focused.container.canvas.y + cy - 1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -493,7 +499,7 @@ local function addShell()
|
|||||||
}, { __index = Process })
|
}, { __index = Process })
|
||||||
|
|
||||||
function process:focus(focused)
|
function process:focus(focused)
|
||||||
--self.window.setVisible(focused)
|
self.window.setVisible(focused)
|
||||||
if focused then
|
if focused then
|
||||||
self.window.restoreCursor()
|
self.window.restoreCursor()
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user