mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-12 10:20:28 +00:00
parent
a802f25dd6
commit
49c37857d4
@ -431,16 +431,20 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
||||
return nX, nY
|
||||
end
|
||||
|
||||
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight )
|
||||
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight, newParent )
|
||||
if type(nNewX) ~= "number" then expect(1, nNewX, "number") end
|
||||
if type(nNewY) ~= "number" then expect(2, nNewY, "number") end
|
||||
if nNewWidth ~= nil or nNewHeight ~= nil then
|
||||
expect(3, nNewWidth, "number")
|
||||
expect(4, nNewHeight, "number")
|
||||
end
|
||||
if newParent ~= nil and type(newParent) ~= "table" then expect(5, newParent, "table") end
|
||||
|
||||
nX = nNewX
|
||||
nY = nNewY
|
||||
|
||||
if newParent then parent = newParent end
|
||||
|
||||
if nNewWidth and nNewHeight then
|
||||
local tNewLines = {}
|
||||
createEmptyLines( nNewWidth )
|
||||
|
@ -118,6 +118,26 @@ describe("The window library", function()
|
||||
expect.error(w.reposition, 1, 1, false, 1):eq("bad argument #3 (expected number, got boolean)")
|
||||
expect.error(w.reposition, 1, 1, nil, 1):eq("bad argument #3 (expected number, got nil)")
|
||||
expect.error(w.reposition, 1, 1, 1, nil):eq("bad argument #4 (expected number, got nil)")
|
||||
expect.error(w.reposition, 1, 1, 1, 1, true):eq("bad argument #5 (expected table, got boolean)")
|
||||
end)
|
||||
|
||||
it("can change the buffer", function()
|
||||
local a, b = mk(), mk()
|
||||
local target = window.create(a, 1, 1, a.getSize())
|
||||
|
||||
target.write("Test")
|
||||
expect((a.getLine(1))):equal("Test ")
|
||||
expect({ a.getCursorPos() }):same { 5, 1 }
|
||||
|
||||
target.reposition(1, 1, nil, nil, b)
|
||||
|
||||
target.redraw()
|
||||
expect((a.getLine(1))):equal("Test ")
|
||||
expect({ a.getCursorPos() }):same { 5, 1 }
|
||||
|
||||
target.setCursorPos(1, 1) target.write("More")
|
||||
expect((a.getLine(1))):equal("Test ")
|
||||
expect((b.getLine(1))):equal("More ")
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user