Thread: just one more thing..

  1. #1
    xlord
    Guest

    just one more thing..

    Well this code works almost perfect.. but there is just one thing... i check this out


    Code:
    you have typed the down key
    you have typed the down key
    you have typed the down key
    you have typed left arrow
    you have typed left arrow
    you have typed left arrow
    you have typed the down key
    you have typed the down key
    you have typed the down key
    you have typed the down keyyou have typed the down keyyou have typed the down
    well the prob here is that once it gets to the end
    it wont pring on a new line anymore.. as you can see... so how can i make it so it can print on a new line..

    heres the code...

    Code:
      start_color();
      keypad(stdscr,TRUE);
    
    box(stdscr,0,0);
    while(1)
    {
       ch = getch();
        switch(ch)
        {
           case  KEY_LEFT:
    
                   init_pair(2,COLOR_RED, COLOR_BLACK);
    	       attron(COLOR_PAIR(2));
                   printw("you have typed left arrow\n");
    	       attroff(COLOR_PAIR(2));
    	       break;
    
           case KEY_RIGHT:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  printw("you have typed right arrow\n");
    	      attroff(COLOR_PAIR(2));
    	      break;
    
           case KEY_UP:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  printw("you have typed up arrow\n");
    	      break;
    
           case KEY_DOWN:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  printw("you have typed the down key\n");
    	      break;
    
    	      }
    	   }
    	     refresh();
    	     endwin();
    	     return 0;
    }
    i added the top part as code cause i didt now what else to use.. to keep it neat =)

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm not too sure I see the exact problem. Shouldn't you have refresh() inside the main while loop?

  3. #3
    xlord
    Guest
    actualy no.. refresh() is kinda really used only when your like using printw... then it should be used at the end of it but not at the loop

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pause/idle thing
    By freedik in forum Windows Programming
    Replies: 13
    Last Post: 08-22-2003, 09:46 AM
  2. A very strange thing
    By gustavosserra in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2003, 12:43 PM
  3. most challenging thing to program
    By volk in forum A Brief History of Cprogramming.com
    Replies: 52
    Last Post: 03-28-2003, 03:56 PM
  4. newbie needs help comprehending simple thing
    By A helpless one in forum C++ Programming
    Replies: 6
    Last Post: 12-16-2002, 09:23 PM
  5. PingPong But how to make 2 thing at the same time..
    By Gugge in forum C Programming
    Replies: 5
    Last Post: 04-02-2002, 06:13 PM