title: Move a cursor inside a window - ncurses
body: <p>I made a window using ncurse and I am trying to be able to move my cursor using arrow keys inside my window and only inside it. For what I understood I have to use <code>wmove()</code> but apparently I didn't get how to use it.</p>
  
  <p>Here's some code snippets to let you know what I did:
  </p>
  
  <pre><code>int main(int argc, char **argv)
  {
    WINDOW *my_win;
    int startx, starty, width, height;
    int ch;
    int x = 50;
    int y = 5;
  
    initscr();
    cbreak();
    keypad(stdscr, TRUE);
    noecho();
  
    height = 10;
    width = 100;
    starty = (LINES - height) / 2;
    startx = (COLS - width) / 2;
    printw("Press F1 to exit");
    refresh();
    my_win = create_newwin(25, 50, y, x);
    wmove(my_win, y, x);
  
    while((ch = getch()) != KEY_F(1))
      {
        if ((ch = getch()) == KEY_RIGHT)
          wmove(my_win, y++, x++);
        refresh();
    }
  
    endwin();
    return 0;
  }
  </code></pre>
  
  <pre class="lang-c prettyprint-override"><code>WINDOW *create_newwin(int height, int width, int starty, int startx)
  {
    WINDOW *local_win;
  
    local_win = newwin(height, width, starty, startx);
    box(local_win, 0, 0);
    wrefresh(local_win);
  
    return (local_win);
  }
  </code></pre>