small "readline" routine?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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
We've slightly trimmed the long signature. Click to see the full one.
Re: small "readline" routine?
comp.arch.embedded:

Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: small "readline" routine?

Quoted text here. Click to load it

H8


C


GCC 3.3

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: small "readline" routine?
Quoted text here. Click to load it

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.



Re: small "readline" routine?

Quoted text here. Click to load it

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 ->
--

Re: small "readline" routine?

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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!!
We've slightly trimmed the long signature. Click to see the full one.
Re: small "readline" routine?
 
Quoted text here. Click to load it

Me too!

--
- Mark ->
--

Re: small "readline" routine?

Quoted text here. Click to load it

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..



Re: small "readline" routine?
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.

Quoted text here. Click to load it



Re: small "readline" routine?

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

--
Grant Edwards                   grante             Yow!  Go on, EMOTE! I
                                  at               was RAISED on thought
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline