delete experimental REPL

We're going to focus on a simple text editor for now.
This commit is contained in:
Kartik K. Agaram 2022-05-16 18:42:58 -07:00
parent 21a4d8a67e
commit 551985e383
2 changed files with 0 additions and 55 deletions

View File

@ -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 = {}

View File

@ -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