about summary refs log tree commit diff stats
path: root/app.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-14 22:06:08 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-14 22:06:08 -0700
commit15acc38da950bfc0c7c3eec4d1ce8d86989921c7 (patch)
tree1338e51b40ee6d510a7cbfebf1933f1f602f86b3 /app.lua
parentd077ce7f42efd6deab7543e39ffa253222fac71d (diff)
downloadlines.love-15acc38da950bfc0c7c3eec4d1ce8d86989921c7.tar.gz
test: autosave after any shape
Diffstat (limited to 'app.lua')
-rw-r--r--app.lua18
1 files changed, 16 insertions, 2 deletions
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