key mapping for command-line tools

P

parcour

Hi. I wonder if anyone could point me to a simple key mapping example
for a command-line application. I would like to map the up and down
arrow keys in my application to a couple of command history functions,
but I don't know how to interact with the terminal (any terminal) to do
this. If I use getc to trap an arrow key press I just get an ESC (27),
and of course I have to wait for a newline to do anything with it.
I've been looking over vim and mysql source for an answer, but it's a
lot of code to wade through. Thanks for any tips.
 
V

Vladimir S. Oka

(e-mail address removed) opined:
Hi. I wonder if anyone could point me to a simple key mapping
example
for a command-line application. I would like to map the up and down
arrow keys in my application to a couple of command history
functions, but I don't know how to interact with the terminal (any
terminal) to do
this. If I use getc to trap an arrow key press I just get an ESC
(27), and of course I have to wait for a newline to do anything with
it. I've been looking over vim and mysql source for an answer, but
it's a
lot of code to wade through. Thanks for any tips.

Ask in the group dealing with your particular environment. Stndard C
knows nothing about keys...
 
F

Flash Gordon

Hi. I wonder if anyone could point me to a simple key mapping example
for a command-line application. I would like to map the up and down
arrow keys in my application to a couple of command history functions,

<snip>

This isn't possible in standard C which is what we discus here, so you
will have to ask in a group dedicated to your implementation.
 
D

Default User

Hi. I wonder if anyone could point me to a simple key mapping example
for a command-line application. I would like to map the up and down
arrow keys in my application to a couple of command history functions,
but I don't know how to interact with the terminal (any terminal) to
do this.

Many implementations use a "scan code" system, multiple character
values translate into one key. Try searching for your platform name and
"scan codes". That's about the best we can do for you.




Brian
 
P

parcour

Thanks... now I have a better idea where to look. But sorry for the
off-topic post.
 

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
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top