inch.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* PDCurses */
  2. #include <curspriv.h>
  3. /*man-start**************************************************************
  4. inch
  5. ----
  6. ### Synopsis
  7. chtype inch(void);
  8. chtype winch(WINDOW *win);
  9. chtype mvinch(int y, int x);
  10. chtype mvwinch(WINDOW *win, int y, int x);
  11. int in_wch(cchar_t *wcval);
  12. int win_wch(WINDOW *win, cchar_t *wcval);
  13. int mvin_wch(int y, int x, cchar_t *wcval);
  14. int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval);
  15. ### Description
  16. The inch() functions retrieve the character and attribute from the
  17. current or specified window position, in the form of a chtype. If a
  18. NULL window is specified, (chtype)ERR is returned.
  19. The in_wch() functions are the wide-character versions; instead of
  20. returning a chtype, they store a cchar_t at the address specified by
  21. wcval, and return OK or ERR. (No value is stored when ERR is
  22. returned.) Note that in PDCurses, chtype and cchar_t are the same.
  23. ### Portability
  24. X/Open ncurses NetBSD
  25. inch Y Y Y
  26. winch Y Y Y
  27. mvinch Y Y Y
  28. mvwinch Y Y Y
  29. in_wch Y Y Y
  30. win_wch Y Y Y
  31. mvin_wch Y Y Y
  32. mvwin_wch Y Y Y
  33. **man-end****************************************************************/
  34. chtype winch(WINDOW *win)
  35. {
  36. PDC_LOG(("winch() - called\n"));
  37. if (!win)
  38. return (chtype)ERR;
  39. return win->_y[win->_cury][win->_curx];
  40. }
  41. chtype inch(void)
  42. {
  43. PDC_LOG(("inch() - called\n"));
  44. return winch(stdscr);
  45. }
  46. chtype mvinch(int y, int x)
  47. {
  48. PDC_LOG(("mvinch() - called\n"));
  49. if (move(y, x) == ERR)
  50. return (chtype)ERR;
  51. return stdscr->_y[stdscr->_cury][stdscr->_curx];
  52. }
  53. chtype mvwinch(WINDOW *win, int y, int x)
  54. {
  55. PDC_LOG(("mvwinch() - called\n"));
  56. if (wmove(win, y, x) == ERR)
  57. return (chtype)ERR;
  58. return win->_y[win->_cury][win->_curx];
  59. }
  60. #ifdef PDC_WIDE
  61. int win_wch(WINDOW *win, cchar_t *wcval)
  62. {
  63. PDC_LOG(("win_wch() - called\n"));
  64. if (!win || !wcval)
  65. return ERR;
  66. *wcval = win->_y[win->_cury][win->_curx];
  67. return OK;
  68. }
  69. int in_wch(cchar_t *wcval)
  70. {
  71. PDC_LOG(("in_wch() - called\n"));
  72. return win_wch(stdscr, wcval);
  73. }
  74. int mvin_wch(int y, int x, cchar_t *wcval)
  75. {
  76. PDC_LOG(("mvin_wch() - called\n"));
  77. if (!wcval || (move(y, x) == ERR))
  78. return ERR;
  79. *wcval = stdscr->_y[stdscr->_cury][stdscr->_curx];
  80. return OK;
  81. }
  82. int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval)
  83. {
  84. PDC_LOG(("mvwin_wch() - called\n"));
  85. if (!wcval || (wmove(win, y, x) == ERR))
  86. return ERR;
  87. *wcval = win->_y[win->_cury][win->_curx];
  88. return OK;
  89. }
  90. #endif