metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
128 stars 27 forks source link

Tab completion prints 'For example' #1067

Closed rhencke closed 4 years ago

rhencke commented 4 years ago

In the r3 console, pressing the 'tab' key causes the text "For example" to be placed in the buffer, with the text cursor aligned between the words 'For' and 'example'. (I'm not sure why it's this text, but it always seems to be 'For example')

hostilefork commented 4 years ago

Rebol2 and Red offer some command-line completion in their custom GUI terminals...because they cross-platformedly own the bitmap buffer of a box, and can draw in it. But when running in a traditional terminal window they don't...and lacking a GUI, there was never any completion in the open-sourced R3-Alpha.

Traditional terminals require platform-specific manual management of buffers through something like curses. R3-Alpha's was based on the monolithic ReadConsole function...where the granularity was insufficient to react to individual keypresses.

Ren-C has tried to push more and more code into usermode, for instance with the console itself:

https://github.com/metaeducation/ren-c/blob/master/extensions/console/ext-console-init.reb

The bad news about breaking apart the monolith is that then you become responsible for all of the key handling. That monolith had a first-cut at being broken apart, which is quite a lot of work:

https://github.com/metaeducation/ren-c/blob/master/extensions/stdio/readline-windows.c

Ultimately the desire is the console would present itself as a hookable "port" providing events at whatever granularity it could. But the single export of TAB to "do something" was given out as a proof of concept:

https://github.com/metaeducation/ren-c/issues/1022

That issue is open for anyone who wants to implement what the logic of tab completion is by writing the usermode routine. But I'm more interested in the principle of the thing and the mechanics (like what happens if your tab completion code has an error in it...)

I'll defer further discussion back over to that issue...

rebolek commented 4 years ago

Rebol2 doesn't offer tab-completion in console, but Red does.