ncurses and key commands

L

lnatz

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
 
W

Walter Roberson

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

CBFalconer

lnatz said:
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
 
M

mark_bluemel

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

Chris Dollin

lnatz said:
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!)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top