mirror of
https://github.com/kepler155c/opus
synced 2025-01-30 09:04: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
|
||||
return { code = ch }
|
||||
end
|
||||
else
|
||||
elseif code then
|
||||
self.state[code] = true
|
||||
self.fired = false
|
||||
end
|
||||
|
@ -192,8 +192,11 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
|
||||
end
|
||||
|
||||
function win.restoreCursor()
|
||||
win.setCursorPos(cx, cy)
|
||||
win.setCursorBlink(blink)
|
||||
if isVisible then
|
||||
win.setCursorPos(cx, cy)
|
||||
win.setTextColor(fg)
|
||||
win.setCursorBlink(blink)
|
||||
end
|
||||
end
|
||||
|
||||
function win.getPosition()
|
||||
|
@ -63,8 +63,22 @@ function Canvas:resize(w, h)
|
||||
table.remove(self.lines, #self.lines)
|
||||
end
|
||||
|
||||
if w ~= self.width then
|
||||
self:clear()
|
||||
if w < self.width then
|
||||
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
|
||||
|
||||
self.ex = self.x + w - 1
|
||||
|
@ -121,14 +121,6 @@ function keyboard.removeHotkey(code)
|
||||
keyboard.hotkeys[code] = nil
|
||||
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 dev = {
|
||||
name = name,
|
||||
|
Loading…
Reference in New Issue
Block a user