Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   key mapping for command-line tools (http://www.velocityreviews.com/forums/t442178-key-mapping-for-command-line-tools.html)

parcour@gmail.com 04-07-2006 06:56 PM

key mapping for command-line tools
 
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.


Vladimir S. Oka 04-07-2006 07:12 PM

Re: key mapping for command-line tools
 
parcour@gmail.com 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...

--
Only a fool fights in a burning house.
-- Kank the Klingon, "Day of the Dove", stardate unknown

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>


Flash Gordon 04-07-2006 08:00 PM

Re: key mapping for command-line tools
 
parcour@gmail.com wrote:
> 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.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc

Default User 04-07-2006 08:00 PM

Re: key mapping for command-line tools
 
parcour@gmail.com wrote:

> 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

parcour@gmail.com 04-07-2006 11:11 PM

Re: key mapping for command-line tools
 
Thanks... now I have a better idea where to look. But sorry for the
off-topic post.



All times are GMT. The time now is 03:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.