p3r7 / repl

access norns' repl from a script
MIT License
2 stars 1 forks source link

Command history #2

Closed xmacex closed 11 months ago

xmacex commented 12 months ago

Hi, repl is such a fun contraption, esp. as a mod to livecode with. I made a little command history, maybe it is useful for merging? Resolves #1

Please let me know if it would be better if I implemented this in some other way.

There is still an Obi-Wan bug in get_next_input as the first time doesn't register somehow, it seems to be about the offset manipulation... I'll see if I can find it. That's why some of the tests fail too (the tests need prompts and input_history to be temporarily set to be to global, and it needs to be run from dust/code to get dependincies).

Another think I would not hesitate to call a UI bug is that if the user/artist has started writing a command, it will be lost if they browse the input history... sadface. This draft should be captured somewhere and returned to. Shouldn't be too hard for me to implement.

p3r7 commented 12 months ago

oh, wow, adding command history is no small feat. implem looks fine to me.

also tests!

There is still an Obi-Wan bug [...]

i'm not 100% sure it's the explanation, but doing counting elements of a dynamically populated list w/ # is considered "unsafe" in lua (length is not updated synchronously w/ additions / deletions).

that's why norns provide tab.count.

is this bug gets fixed i'd merge this PR right away.

if the user/artist has started writing a command, it will be lost if they browse the input history

this can be tricky & could be dealt with at a later time

one direct implem could be to just use an additional state var to store the last unsubmitted prompt.

but what if the user "forks" the past by editing a prompt from the history? does it become the new "unsubmitted prompt" or do we need to preserve both? we'd have to look at how bash does it & do something similar.

xmacex commented 12 months ago

Thank you for insight and feedback, I'll work on it and try tab.count.

xmacex commented 11 months ago

I moved from # to tab.count per your suggestion (getting such knowledge is not obvious, thank you for the gift), and I think it was simply my confusion/brainmelt with indexing rather than anything attributable to Lua internals, I think I got the bug now.

p3r7 commented 11 months ago

well done. didn't take the time to test but i'm confident enough you had this working.

xmacex commented 11 months ago

Stellar, thank you. If you or another REPL-afficionado finds issues, please don't hesitate to ping me here on GH, lines, discord or whatever works.

>> print("happy hacking")