move.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* PDCurses */
  2. #include <curspriv.h>
  3. /*man-start**************************************************************
  4. move
  5. ----
  6. ### Synopsis
  7. int move(int y, int x);
  8. int mvcur(int oldrow, int oldcol, int newrow, int newcol);
  9. int wmove(WINDOW *win, int y, int x);
  10. ### Description
  11. move() and wmove() move the cursor associated with the window to the
  12. given location. This does not move the physical cursor of the
  13. terminal until refresh() is called. The position specified is
  14. relative to the upper left corner of the window, which is (0,0).
  15. mvcur() moves the physical cursor without updating any window cursor
  16. positions.
  17. ### Return Value
  18. All functions return OK on success and ERR on error.
  19. ### Portability
  20. X/Open ncurses NetBSD
  21. move Y Y Y
  22. mvcur Y Y Y
  23. wmove Y Y Y
  24. **man-end****************************************************************/
  25. int move(int y, int x)
  26. {
  27. PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
  28. if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
  29. return ERR;
  30. stdscr->_curx = x;
  31. stdscr->_cury = y;
  32. return OK;
  33. }
  34. int mvcur(int oldrow, int oldcol, int newrow, int newcol)
  35. {
  36. PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
  37. oldrow, oldcol, newrow, newcol));
  38. if (!SP || newrow < 0 || newrow >= LINES || newcol < 0 || newcol >= COLS)
  39. return ERR;
  40. PDC_gotoyx(newrow, newcol);
  41. SP->cursrow = newrow;
  42. SP->curscol = newcol;
  43. return OK;
  44. }
  45. int wmove(WINDOW *win, int y, int x)
  46. {
  47. PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
  48. if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
  49. return ERR;
  50. win->_curx = x;
  51. win->_cury = y;
  52. return OK;
  53. }