Thread: make a cursor move using the arrow keys with ncurses?

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    make a cursor move using the arrow keys with ncurses?

    anyone know how to make a cursor move using the arrow keys with ncurses?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I'd start by reading
    NCURSES Programming HOWTO
    Writing Programs with NCURSES

    Just doing a search for "cursor" through both documents should help you home in on your answer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    11
    anyone know why this code gives me this error

    Code:
                // cursor goes up
                case 'KEY_UP': 
                    g.y++;
                    g.x++;
                    move(g.x,g.y);
                    break;
    sudoku.c: In function 'main':
    sudoku.c:165:18: error: character constant too long for its type [-Werror]
    cc1: all warnings being treated as errors

    make: *** [sudoku] Error 1

    line 165 is case 'KEY_UP':

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    KEY_UP is presumably an integer constant defined somewhere earlier in your code, but when you use the single quotes around it you are not referring to the constant KEY_UP, but are testing for a case where the switched value is 'KEY_UP'.

    Using for example case 'a': would be ok since it's only 1 char. So, just remove the single quotes.



    Edit: Actually KEY_UP is defined in curses.h, but the point remains.
    Last edited by Subsonics; 09-12-2012 at 07:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ncurses: Unable to move windows with mvwin !
    By Ravi Raj in forum C Programming
    Replies: 5
    Last Post: 05-21-2012, 06:35 PM
  2. ncurses Strange Keys
    By MTK in forum C Programming
    Replies: 3
    Last Post: 09-16-2009, 09:34 AM
  3. Arrow Keys
    By DeepFyre in forum C++ Programming
    Replies: 1
    Last Post: 10-12-2004, 04:16 PM
  4. Using the arrow keys
    By Punkture in forum C Programming
    Replies: 8
    Last Post: 05-31-2003, 04:25 PM
  5. arrow keys, ctrl and alt keys
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-25-2002, 03:53 PM