diff --git a/main.lua b/main.lua index ee2094e..c1b90e4 100644 --- a/main.lua +++ b/main.lua @@ -1,7 +1,37 @@ local tilesheet = require "lib.tilesheet" +local utf8 = require "utf8" local utility = require "lib.utility" +local window_width, window_height = love.graphics.getDimensions() + local tiles +local current_text = "" + +function love.load() + love.keyboard.setKeyRepeat(true) +end + +function love.draw() + love.graphics.printf("Prompt:", 0, 0, window_width) + love.graphics.printf(current_text, 0, 20, window_width) -- lazy magic numbers +end + +function love.textinput(character) + current_text = current_text .. character +end + +function love.keypressed(key) + if key == "escape" then + love.event.quit() + elseif key == "backspace" then + local byteoffset = utf8.offset(current_text, -1) + if byteoffset then + current_text = current_text:sub(1, byteoffset - 1) + end + elseif key == "enter" then + -- TODO end of a textinput; what to do depends on what was being asked + end +end function love.filedropped(file_path) if file_path:sub(-5) == ".json" then