ncurses and key commands

Discussion in 'C Programming' started by lnatz, Feb 8, 2007.

  1. lnatz

    lnatz Guest

    Hi,
    I am writing a shell and am using ncurses to recognize key commands
    like up_arrow(KEY_UP) and down_arrow(KEY_DOWN). In a unix/linux OS the
    up arrow would give you the last command you input. I am trying to do
    that, but I don't know how to explain it well but I am trying to get
    that browsing look. I can access the history and retrieve the last
    command but if i want to browse three or four further back I can't get
    it to act the same way as the OS does. What I mean is that in a unix
    shell, if you press the up arrow it would give you the last command
    you input and if you press the up arrow several more times, the input
    is simply replaced. I can't get it to replace the previous input.

    I am sorry for my poor explanation but if anyone understands what I
    mean, I would greatly appreciate your help.

    Thank you in advance,
    natalie
     
    lnatz, Feb 8, 2007
    #1
    1. Advertising

  2. In article <>,
    lnatz <> wrote:
    >I am writing a shell and am using ncurses to recognize key commands
    >like up_arrow(KEY_UP) and down_arrow(KEY_DOWN). In a unix/linux OS the


    Try comp.unix.programming . The C language itself barely recognizes
    the existance of keys (it likes -characters- though). ncurses requires
    OS-specific extensions to C.
    --
    All is vanity. -- Ecclesiastes
     
    Walter Roberson, Feb 8, 2007
    #2
    1. Advertising

  3. lnatz

    CBFalconer Guest

    Re: [OT] ncurses and key commands

    lnatz wrote:
    >
    > I am writing a shell and am using ncurses to recognize key commands
    > like up_arrow(KEY_UP) and down_arrow(KEY_DOWN). In a unix/linux OS
    > the up arrow would give you the last command you input. I am trying
    > to do that, but I don't know how to explain it well but I am trying
    > to get that browsing look. I can access the history and retrieve
    > the last command but if i want to browse three or four further back
    > I can't get it to act the same way as the OS does. What I mean is
    > that in a unix shell, if you press the up arrow it would give you
    > the last command you input and if you press the up arrow several
    > more times, the input is simply replaced. I can't get it to replace
    > the previous input.


    I suggest you look at the way 4dos works, under DOS or w9x. You
    might want to sniff around comp.os.msdos.4dos. Many have been
    trying to persuade Rex Conn to port it to Linux. However, he has
    released the source. There is some confusion as to the terms.

    Shells, ncurses, etc. are all off-topic here. c.l.c discusses the
    C language, as defined by the various standards. Cross posted and
    f'ups set.

    --
    <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
    <http://www.securityfocus.com/columnists/423>

    "A man who is right every time is not likely to do very much."
    -- Francis Crick, co-discover of DNA
    "There is nothing more amazing than stupidity in action."
    -- Thomas Matthews
     
    CBFalconer, Feb 8, 2007
    #3
  4. lnatz

    Guest

    On 8 Feb, 02:11, "lnatz" <> wrote:
    >... In a unix/linux OS the
    > up arrow would give you the last command you input.

    <Off-topic>
    Not on most of the unixes I've worked on, but I'm _very_ old. I worked
    for many years with the bourne shell, and no command history at all.

    These days I tend to use ksh with vi-style editing from choice, which
    still doesn't mean arrow keys work.

    Please don't confuse the behaviour of a shell with the behaviour of
    the OS...
    </Off-topic>
     
    , Feb 8, 2007
    #4
  5. lnatz

    Chris Dollin Guest

    lnatz wrote:

    > Hi,
    > I am writing a shell and am using ncurses to recognize key commands
    > like up_arrow(KEY_UP) and down_arrow(KEY_DOWN). In a unix/linux OS the
    > up arrow would give you the last command you input. I am trying to do
    > that, but I don't know how to explain it well but I am trying to get
    > that browsing look. I can access the history and retrieve the last
    > command but if i want to browse three or four further back I can't get
    > it to act the same way as the OS does. What I mean is that in a unix
    > shell, if you press the up arrow it would give you the last command
    > you input and if you press the up arrow several more times, the input
    > is simply replaced. I can't get it to replace the previous input.


    There's a GNU readline package that will do this for you. I have
    used it, wrapped up so that if it's not available it falls back
    to using fgets on stdin; the rest of the program doesn't know or
    care about the gnu magic.

    (GNU readline isn't topical, but the trick of wrapping it is!)

    --
    Chris "electric hedgehog" Dollin
    Nit-picking is best done among friends.
     
    Chris Dollin, Feb 8, 2007
    #5
    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. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    3,981
    Thomas Stegen
    Jun 28, 2003
  2. Chris Burkert
    Replies:
    1
    Views:
    436
    Jarek Zgoda
    Jan 18, 2004
  3. Tim Stanka
    Replies:
    1
    Views:
    812
    Jeff Epler
    Aug 2, 2004
  4. M P
    Replies:
    1
    Views:
    493
  5. Kenneth McDonald
    Replies:
    1
    Views:
    154
    Nit Khair
    Sep 27, 2008
Loading...

Share This Page