sum-grid.love/0017-on.keychord_press

28 lines
688 B
Plaintext

on.keychord_press = function(chord, key)
if chord == 'C-n' then
new()
elseif chord == '`' then
if Draw == 'problem' then
Draw = 'char'
elseif Draw == 'char' then
Draw = 'solution'
elseif Draw == 'solution' then
Draw = 'problem'
end
elseif chord:match('%d') then
-- cursor visible
local x,y = Cursor[1], Cursor[2]
if x > 0 and y > 0 then
-- it's not in the provided square
if x ~= Problem.x or y ~= Problem.y then
local c = Problem.data[y][x]
local d = (string.byte(chord) - 48)
if c == '' then
Problem.data[y][x] = d
elseif c < 2 then -- not overfull
Problem.data[y][x] = Problem.data[y][x]*10 + d
end
end
end
end
end