Minimal line editing for OSX, Linux, BSD

Carl Sassenrath, CTO
REBOL Technologies
23-Jun-2009 3:50 GMT

Article #0214
Main page || Index || Prior Article [0213] || Next Article [0215] || 4 Comments || Send feedback

It's about time we consider some kind of minimal "readline" interface for editing R3 input on the non-windows boxes.

The perfect solution would be a page or so of C code that handles the most common editing keys (arrow keys mainly), and would not require any other libs. Unlikely? It's difficult to say. Seems like most systems are pretty standard on the term types these days.

The reason we need to keep it pure and simple is because every OS has a slightly different lib for doing it. Dealing with those libs gets very time consuming.

So, nothing fancy.

Update - 25-June-2009:

I ended up writing a readline for R3, from scratch. Didn't want to, but we really needed something to make the console usable in Unix-land.

My goal was to write readline in two pages of C, but it's ended up at about five. (That's certainly better than the 400 KB BSDed readline version I was thinking about downloading.)

Of course, problem is, I don't have a lot of time for this feature. "It's not on my list." So, currently, I've had to punt, and make it ASCII. Yes, I know, we need UTF-8 editing too. I think it's possible to extend the code with a few lines here and there. We shouldn't need to decode the UTF-8, simply recognize the code length per char, so we can do the right thing on arrow moves and backspace, etc.


Updated 24-Jun-2024 - Edit - Copyright REBOL Technologies -