repl
[?]
Apr 26, 2022, 5:08 AM
6IQOBYPTFCFTELRMXTR6RC4R7VVOYL7RZ5YLFQM7RZF6Q26CONSQCDependencies
- [2]
R5QXEHUIsomebody stop me
Change contents
- edit in mu.lua at line 4
curses.echo(false) -- unclear why implicit echo can't handle newlines, regardless of stdscr:nl() - replacement in mu.lua at line 6
stdscr:getch()stdscr:scrollok(true)-- unclear how Lua (post 5.2) is able to selectively print values of variables-- at the repllocal function gather_results(success, ...)local n = select('#', ...)return success, { n = n, ... }endlocal function readline()local result = ''while true dolocal x = stdscr:getch()stdscr:addch(x)local c = string.char(x)result = result .. cif c == '\n' then break endendreturn resultendlocal new_expr = truelocal buf = ''while true doif new_expr thenstdscr:addstr('> ')elsestdscr:addstr('>> ')endbuf = buf .. readline()local f, err = load(buf, 'REPL')if f thenbuf = ''new_expr = truelocal success, results = gather_results(xpcall(f, function(...) return debug.traceback() end))if success thenfor _, result in ipairs(results) doprint(result)endelseprint(results[1])endelsestdscr:addstr(err..'\n')if string.match(err, "'<eof>'$") or string.match(err, "<eof>$") thenbuf = buf .. '\n'new_expr = falseelseprint(err)buf = ''new_expr = trueendendend