From 15acc38da950bfc0c7c3eec4d1ce8d86989921c7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 14 Jun 2022 22:06:08 -0700 Subject: test: autosave after any shape --- app.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'app.lua') diff --git a/app.lua b/app.lua index 20fd027..99cef81 100644 --- a/app.lua +++ b/app.lua @@ -276,8 +276,21 @@ end function App.open_for_writing(filename) App.filesystem[filename] = '' return { - write = function(self, s) - App.filesystem[filename] = App.filesystem[filename]..s + write = function(self, ...) + local args = {...} + for i,s in ipairs(args) do + App.filesystem[filename] = App.filesystem[filename]..s + end + end, + close = function(self) + end + } +end + +function App.open_for_reading(filename) + return { + lines = function(self) + return App.filesystem[filename]:gmatch('[^\n]+') end, close = function(self) end @@ -331,6 +344,7 @@ function App.disable_tests() App.newText = love.graphics.newText App.screen.draw = love.graphics.draw App.width = function(text) return text:getWidth() end + App.open_for_reading = function(filename) return io.open(filename, 'r') end App.open_for_writing = function(filename) return io.open(filename, 'w') end App.getClipboardText = love.system.getClipboardText App.setClipboardText = love.system.setClipboardText -- cgit 1.4.1-2-gfad0