From 551985e383348a0544454030377262aad784055c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 16 May 2022 18:42:58 -0700 Subject: [PATCH] delete experimental REPL We're going to focus on a simple text editor for now. --- main.lua | 13 ------------- repl.lua | 42 ------------------------------------------ 2 files changed, 55 deletions(-) delete mode 100644 repl.lua diff --git a/main.lua b/main.lua index 7536aa5..7cd410c 100644 --- a/main.lua +++ b/main.lua @@ -1,6 +1,5 @@ require 'keychord' require 'button' -require 'repl' local utf8 = require 'utf8' -- lines is an array of lines @@ -46,8 +45,6 @@ function coord(n) -- pixels to parts return math.floor(n*256/drawingw) end -exec_payload = nil - filename = nil function love.load(arg) @@ -155,11 +152,6 @@ function love.draw() -- cursor love.graphics.setColor(0,0,0) love.graphics.print('_', 25+text:getWidth()*1.5, y) - - -- display side effect - if exec_payload then - run(exec_payload) - end end function love.update(dt) @@ -512,11 +504,6 @@ function keychord_pressed(chord) lines[#lines] = string.sub(lines[#lines], 1, byteoffset-1) end end - elseif chord == 'C-r' then - lines[#lines+1] = eval(lines[#lines])[1] - lines[#lines+1] = '' - elseif chord == 'C-x' then - parse_into_exec_payload(lines[#lines]) elseif chord == 'escape' and love.mouse.isDown('1') then local drawing = current_drawing() drawing.pending = {} diff --git a/repl.lua b/repl.lua deleted file mode 100644 index 44bba97..0000000 --- a/repl.lua +++ /dev/null @@ -1,42 +0,0 @@ --- beginnings of a repl - -function eval(buf) - local f = load('return '..buf, 'REPL') - if f then - return run(f) - end - local f, err = load(buf, 'REPL') - if f then - return run(f) - else - return {err} - end -end - --- you could perform parse and run separately --- usually because there's a side-effect like drawing that you want to control the timing of -function parse_into_exec_payload(buf) - local f = load('return '..buf, 'REPL') - if f then - exec_payload = f - return - end - local f, err = load(buf, 'REPL') - if f then - exec_payload = f - return - else - return {err} - end -end - --- based on https://github.com/hoelzro/lua-repl -function run(f) - local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end)) - return results -end - -function gather_results(success, ...) - local n = select('#', ...) - return success, { n = n, ... } -end