key mapping for command-line tools

Discussion in 'C Programming' started by parcour@gmail.com, Apr 7, 2006.

  1. Guest

    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.
     
    , Apr 7, 2006
    #1
    1. Advertising

  2. 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>
     
    Vladimir S. Oka, Apr 7, 2006
    #2
    1. Advertising

  3. Flash Gordon Guest

    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
     
    Flash Gordon, Apr 7, 2006
    #3
  4. Default User Guest

    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
     
    Default User, Apr 7, 2006
    #4
  5. Guest

    Thanks... now I have a better idea where to look. But sorry for the
    off-topic post.
     
    , Apr 8, 2006
    #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. Errol Smith
    Replies:
    12
    Views:
    1,383
    Errol Smith
    Sep 24, 2004
  2. Adrian Casey
    Replies:
    5
    Views:
    832
    Adrian Casey
    Jan 12, 2005
  3. Replies:
    0
    Views:
    400
  4. ShortCircuit

    Command Line Tools

    ShortCircuit, Apr 21, 2010, in forum: VHDL
    Replies:
    0
    Views:
    445
    ShortCircuit
    Apr 21, 2010
  5. M P
    Replies:
    1
    Views:
    521
Loading...

Share This Page