diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-09-05 12:50:33 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-09-05 12:50:33 -0700 |
commit | 569f34fb5b23dc68cbb9be431c14050a0b194945 (patch) | |
tree | 2c758c926bb447403aa8588fa293e3e32d88d086 /app.lua | |
parent | 386c4c1967a9790d14e9e01195a35a57528b8b3b (diff) | |
parent | e0f750913fa653c03a666203e04c59e847e73bff (diff) | |
download | view.love-569f34fb5b23dc68cbb9be431c14050a0b194945.tar.gz |
Merge text.love
Diffstat (limited to 'app.lua')
-rw-r--r-- | app.lua | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/app.lua b/app.lua index 2135fb0..69507ec 100644 --- a/app.lua +++ b/app.lua @@ -383,8 +383,32 @@ 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 + if Current_app == nil or Current_app == 'run' then + App.open_for_reading = function(filename) return io.open(filename, 'r') end + App.open_for_writing = function(filename) return io.open(filename, 'w') end + elseif Current_app == 'source' then + -- HACK: source editor requires a couple of different foundational definitions + App.open_for_reading = + function(filename) + local result = love.filesystem.newFile(filename) + local ok, err = result:open('r') + if ok then + return result + else + return ok, err + end + end + App.open_for_writing = + function(filename) + local result = love.filesystem.newFile(filename) + local ok, err = result:open('w') + if ok then + return result + else + return ok, err + end + end + end App.getTime = love.timer.getTime App.getClipboardText = love.system.getClipboardText App.setClipboardText = love.system.setClipboardText |