mirror of
https://github.com/kepler155c/opus
synced 2025-01-30 17:14:46 +00:00
canvas update for resizing
This commit is contained in:
parent
f4bcd61116
commit
59552d4217
@ -91,7 +91,7 @@ function input:translate(event, code, p1, p2)
|
|||||||
end
|
end
|
||||||
return { code = ch }
|
return { code = ch }
|
||||||
end
|
end
|
||||||
else
|
elseif code then
|
||||||
self.state[code] = true
|
self.state[code] = true
|
||||||
self.fired = false
|
self.fired = false
|
||||||
end
|
end
|
||||||
|
@ -192,8 +192,11 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function win.restoreCursor()
|
function win.restoreCursor()
|
||||||
win.setCursorPos(cx, cy)
|
if isVisible then
|
||||||
win.setCursorBlink(blink)
|
win.setCursorPos(cx, cy)
|
||||||
|
win.setTextColor(fg)
|
||||||
|
win.setCursorBlink(blink)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function win.getPosition()
|
function win.getPosition()
|
||||||
|
@ -63,8 +63,22 @@ function Canvas:resize(w, h)
|
|||||||
table.remove(self.lines, #self.lines)
|
table.remove(self.lines, #self.lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
if w ~= self.width then
|
if w < self.width then
|
||||||
self:clear()
|
for i = 1, h do
|
||||||
|
self.lines[i].text = _sub(self.lines[i].text, 1, w)
|
||||||
|
self.lines[i].fg = _sub(self.lines[i].fg, 1, w)
|
||||||
|
self.lines[i].bg = _sub(self.lines[i].bg, 1, w)
|
||||||
|
end
|
||||||
|
elseif w > self.width then
|
||||||
|
local d = w - self.width
|
||||||
|
local text = _rep(' ', d)
|
||||||
|
local fg = _rep(self.palette[self.fg or colors.white], d)
|
||||||
|
local bg = _rep(self.palette[self.bg or colors.black], d)
|
||||||
|
for i = 1, h do
|
||||||
|
self.lines[i].text = self.lines[i].text .. text
|
||||||
|
self.lines[i].fg = self.lines[i].fg .. fg
|
||||||
|
self.lines[i].bg = self.lines[i].bg .. bg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.ex = self.x + w - 1
|
self.ex = self.x + w - 1
|
||||||
|
@ -121,14 +121,6 @@ function keyboard.removeHotkey(code)
|
|||||||
keyboard.hotkeys[code] = nil
|
keyboard.hotkeys[code] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
kernel.hook('monitor_touch', function(event, eventData)
|
|
||||||
local monitor = Peripheral.getBySide(eventData[1])
|
|
||||||
if monitor and monitor.eventChannel then
|
|
||||||
monitor.eventChannel(event, table.unpack(eventData))
|
|
||||||
return true -- stop propagation
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
local function createDevice(name, devType, method, manipulator)
|
local function createDevice(name, devType, method, manipulator)
|
||||||
local dev = {
|
local dev = {
|
||||||
name = name,
|
name = name,
|
||||||
|
Loading…
Reference in New Issue
Block a user