From 3019442c02bd301dd9ce61f76c2a007aed202577 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 2 May 2022 08:36:56 -0700 Subject: [PATCH] confirm that we have access to all of the love API love.graphics.line(1, 1, 500, 500) However, we're now no longer printing results or errors. Time now to design the data model. When do we (re)evaluate code. When do we display results. Where do errors go. --- main.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/main.lua b/main.lua index 272e72b..c3aa8f4 100644 --- a/main.lua +++ b/main.lua @@ -3,6 +3,7 @@ local utf8 = require 'utf8' lines = {} width, height, flags = 0, 0, nil +exec_payload = nil function love.load() table.insert(lines, '') @@ -24,6 +25,10 @@ function love.draw() end -- cursor love.graphics.print('_', 12+text:getWidth(), #lines*15) + + if exec_payload then + call_gather(exec_payload) + end end function love.update(dt) @@ -47,8 +52,9 @@ function keychord_pressed(chord) end end elseif chord == 'C-r' then - lines[#lines+1] = eval(lines[#lines])[1] - lines[#lines+1] = '' + eval(lines[#lines]) +--? lines[#lines+1] = eval(lines[#lines])[1] +--? lines[#lines+1] = '' end end @@ -64,11 +70,15 @@ end function eval(buf) local f = load('return '..buf, 'REPL') if f then - return call_gather(f) + exec_payload = f + return +--? return call_gather(f) end local f, err = load(buf, 'REPL') if f then - return call_gather(f) + exec_payload = f + return +--? return call_gather(f) else return {err} end