small "readline" routine?

I need to add a simple command-line interface to an embedded project. Has anybody run across a small, free, readline-like library that provides rudimentary command-line editing?

--
Grant Edwards                   grante             Yow!  BRILL CREAM is
                                  at               CREAM O' WHEAT in another
 Click to see the full signature
Reply to
Grant Edwards
Loading thread data ...

On 07 Jan 2004 22:20:34 GMT, Grant Edwards wrote in comp.arch.embedded:

I think your question is a little too vague, but if you provide more detail you can probably find something you can use.

What processor, language, compiler, communications interface? How much RAM and code space are available? Do you just want a line input/editor or text parser as well? What does your command line interface look like? What sort of editing features?

--
Jack Klein
Home: http://JK-Technology.Com
 Click to see the full signature
Reply to
Jack Klein

Actually I believe that writing such routine would take less time than searching for it and adopting it to your project. The whole stuff (with backspace and line length limit handling) takes less than 20 lines of C code and approx. 35 lines of 51 assembly.

Reply to
Grzegorz Mazur

I heard gdb has a general purpose routine like that. I usually write my own, it takes about

2 or 3 pages if you make it full featured (arrow editing, insert/overwrite mode, word forward, word back, history recall, etc).

I allways thought it was facinating that you can write such a routine with just backspace as the only control character used to manipulate the screen. Cursor forward is done by outputting the character at the position.

Reply to
Scott Moore

"Grzegorz Mazur" wrote in news:btj3ds$2mjq$ snipped-for-privacy@mamut.aster.pl:

I'm thinking of the bash shell command line editing capabilities and wondering how that could possibly be about 20 lines of C. I'd like to see this implementation of yours.

--
- Mark ->
--
Reply to
Mark A. Odell

H8

C

GCC 3.3

Assume raw putc()/getc() type routines are available and they're connected to an ANSI terminal.

A total of maybe 8-16K for this function.

Yes.

No.

Undefined.

Most important: * recall the last few lines * move forward/reverse a character at a time * delete and backspace * insert typed characters at cursor Nice to have: * move to beginning/end of line * move forward backward word at a time * delete to end of line * delete word * transpose two characters at cursor Hardwired (but configurable in source code) keybindings are fine (my fingers speak emacs).

--
Grant Edwards                   grante             Yow!  I just got my PRINCE
                                  at               bumper sticker... But now I
 Click to see the full signature
Reply to
Grant Edwards

Me too. Specifically, I was thinking of a subset of Gnu "readline" (I guess I should have been more specific).

I don't need full-up Gnu readline with vi and emacs modes, but I would like command history, move by character/word delete character word, start of line, end of line. Don't need kill/yank or multiple modes and keybindings.

--
Grant Edwards                   grante             Yow!  Someone is DROOLING
                                  at               on my collar!!
 Click to see the full signature
Reply to
Grant Edwards

I had assumed it used the Gnu readline library (which is a bit heavyweight for a small embedded system).

Yea, me too. I thought maybe I'd look for a pre-existing one this time.

At low baud rates that method can be interesting to watch...

--
Grant Edwards                   grante             Yow!  Go on, EMOTE! I
                                  at               was RAISED on thought
 Click to see the full signature
Reply to
Grant Edwards

Grant Edwards wrote in news:3ffd6f17$0$959$ snipped-for-privacy@newsreader.visi.com:

Me too!

--
- Mark ->
--
Reply to
Mark A. Odell

Oops, didn't notice the 'redline' keyword. Single-line editing was what I meant. Of course if you are looking for history buffer etc., it's probably better to start with some Linux/Unix shell source then to write it from scratch..

Reply to
Grzegorz Mazur

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.