1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

small "readline" routine?

Discussion in 'Embedded' started by Grant Edwards, Jan 7, 2004.

  1. 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
    visi.com DIMENSION...
    Grant Edwards, Jan 7, 2004
    #1
    1. Advertising

  2. Grant Edwards

    Jack Klein Guest

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

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


    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
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Jan 8, 2004
    #2
    1. Advertising

  3. "Grant Edwards" <> wrote in message
    news:3ffc8631$0$967$...
    > 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?


    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.
    Grzegorz Mazur, Jan 8, 2004
    #3
  4. Grant Edwards

    Scott Moore Guest

    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.

    "Grant Edwards" <> wrote in message news:3ffc8631$0$967$...
    > 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
    > visi.com DIMENSION...
    Scott Moore, Jan 8, 2004
    #4
  5. "Grzegorz Mazur" <> wrote in
    news:btj3ds$2mjq$:

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

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


    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 ->
    --
    Mark A. Odell, Jan 8, 2004
    #5
  6. On 2004-01-08, Jack Klein <> wrote:

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

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


    H8

    > language,


    C

    > compiler,


    GCC 3.3

    > communications interface?


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

    > How much RAM and code space are available?


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

    > Do you just want a line input/editor


    Yes.

    > or text parser as well?


    No.

    > What does your command line interface look like?


    Undefined.

    > What sort of editing features?


    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
    visi.com can't remember WHO he is...
    Grant Edwards, Jan 8, 2004
    #6
  7. On 2004-01-08, Mark A. Odell <> wrote:

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

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

    >
    > I'm thinking of the bash shell command line editing
    > capabilities


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

    > and wondering how that could possibly be about 20 lines of C.
    > I'd like to see this implementation of yours.


    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!!
    visi.com
    Grant Edwards, Jan 8, 2004
    #7
  8. On 2004-01-08, Scott Moore <> wrote:

    > I heard gdb has a general purpose routine like that.


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

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


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

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


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

    --
    Grant Edwards grante Yow! Go on, EMOTE! I
    at was RAISED on thought
    visi.com balloons!!
    Grant Edwards, Jan 8, 2004
    #8
  9. Grant Edwards <> wrote in
    news:3ffd6f17$0$959$:

    >> and wondering how that could possibly be about 20 lines of C.
    >> I'd like to see this implementation of yours.

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


    Me too!

    --
    - Mark ->
    --
    Mark A. Odell, Jan 8, 2004
    #9
  10. "Mark A. Odell" <> wrote in message
    news:Xns946A5F5981ED5CopyrightMarkOdell@130.133.1.4...
    > > 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.

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


    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..
    Grzegorz Mazur, Jan 10, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eugene
    Replies:
    3
    Views:
    421
    Mumbato
    Sep 12, 2004
  2. tdk

    Bios start up routine

    tdk, Aug 24, 2003, in forum: Motherboards
    Replies:
    1
    Views:
    440
    =?iso-8859-1?Q?Eep=B2?=
    Sep 4, 2003
  3. Roscoe Pendoscoe
    Replies:
    1
    Views:
    294
    Rob G
    Jul 9, 2004
  4. Bram van de Kerkhof

    I2c master routine

    Bram van de Kerkhof, Jan 28, 2004, in forum: Embedded
    Replies:
    6
    Views:
    396
    Meindert Sprang
    Jan 29, 2004
  5. Neil McNulty

    Lex and yacc vs GNU readline

    Neil McNulty, Aug 7, 2011, in forum: Embedded
    Replies:
    4
    Views:
    874
    Andrew Smallshaw
    Aug 8, 2011
Loading...

Share This Page