monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
633 stars 147 forks source link

handle continuation lines in lua REPL #7

Closed catfact closed 7 years ago

catfact commented 7 years ago

when matron receives a lua code string, it simply tries to evaluate it as a complete chunk. it should be smarter, to accomodate continuation lines.

see lua source code: https://github.com/lua/lua/blob/master/lua.c#L350-L382

indeed, i am thinking of just adading our own version of lua.c to replace our repl.c, with code in weaver.c using a pointer to that LVM state.

catfact commented 7 years ago

optionally, leave the matron REPL very dumb, and put all the smartness in the client.

tehn commented 7 years ago

seems it might be nice to have matron be the smart bit, as we may replicate some maiden functionality in a web thing??

but of course the ncurses and web versions of maiden could share a library as well

On Sat, Mar 4, 2017 at 8:26 PM, ezra buchla notifications@github.com wrote:

optionally, leave the matron REPL very dumb, and put all the smartness in the client.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/catfact/norns/issues/7#issuecomment-284197835, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPEcLtTi9tSNlfQ7hCn2Rd4tJ2S6cjXks5rig82gaJpZM4MTRWN .

catfact commented 7 years ago

<note to self, basically>

option 1

would be nice to just run interpreter module from lua source unmodified. (lua.c) but, it uses blocking input liberally within the continuation logic. it's unclear how to reconcile this with matron threading model (which assumes event loop runs on lua's main thread)

option 2

so, i tried selectively ripping from lua.c, adding new continutation logic that operates on external buffer instead of using gnu readline (see lua-repl branch). i think this will work, but it's still buggy right now

saving line history

gnu readline can manage this for us; it's what lua source uses anyway. but i'd save the history at the top of the IO thread, not in the REPL logic itself.

catfact commented 7 years ago

added lua continuation in commit 67348adea, so closing this.

as an experiment, also added readline to matron input. works great when running matron directly from the shell, but as i had feared, it doesn't seem to work in a child process with input redirection.

@tehn: readline is the library that gnu programs use to provide the behavior i think you want (e.g. arrows for line history navigation, but that's just the tip of the iceberg - check out man readline.) it is really a complex piece of software in its own right. i'm considering using it in maiden, but need to confirm that it works properly with a remote shell (i kinda doubt it actually, but we'll see)