| 1 |
|
| 2 |
|
| 3 |
#include <curspriv.h> |
| 4 |
|
| 5 |
RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $") |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
int winchnstr(WINDOW *win, chtype *ch, int n) |
| 60 |
{ |
| 61 |
chtype *src; |
| 62 |
int i; |
| 63 |
|
| 64 |
PDC_LOG(("winchnstr() - called\n")); |
| 65 |
|
| 66 |
if (!win || !ch || n < 0) |
| 67 |
return ERR; |
| 68 |
|
| 69 |
if ((win->_curx + n) > win->_maxx) |
| 70 |
n = win->_maxx - win->_curx; |
| 71 |
|
| 72 |
src = win->_y[win->_cury] + win->_curx; |
| 73 |
|
| 74 |
for (i = 0; i < n; i++) |
| 75 |
*ch++ = *src++; |
| 76 |
|
| 77 |
*ch = (chtype)0; |
| 78 |
|
| 79 |
return OK; |
| 80 |
} |
| 81 |
|
| 82 |
int inchstr(chtype *ch) |
| 83 |
{ |
| 84 |
PDC_LOG(("inchstr() - called\n")); |
| 85 |
|
| 86 |
return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx); |
| 87 |
} |
| 88 |
|
| 89 |
int winchstr(WINDOW *win, chtype *ch) |
| 90 |
{ |
| 91 |
PDC_LOG(("winchstr() - called\n")); |
| 92 |
|
| 93 |
return winchnstr(win, ch, win->_maxx - win->_curx); |
| 94 |
} |
| 95 |
|
| 96 |
int mvinchstr(int y, int x, chtype *ch) |
| 97 |
{ |
| 98 |
PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x)); |
| 99 |
|
| 100 |
if (move(y, x) == ERR) |
| 101 |
return ERR; |
| 102 |
|
| 103 |
return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx); |
| 104 |
} |
| 105 |
|
| 106 |
int mvwinchstr(WINDOW *win, int y, int x, chtype *ch) |
| 107 |
{ |
| 108 |
PDC_LOG(("mvwinchstr() - called:\n")); |
| 109 |
|
| 110 |
if (wmove(win, y, x) == ERR) |
| 111 |
return ERR; |
| 112 |
|
| 113 |
return winchnstr(win, ch, win->_maxx - win->_curx); |
| 114 |
} |
| 115 |
|
| 116 |
int inchnstr(chtype *ch, int n) |
| 117 |
{ |
| 118 |
PDC_LOG(("inchnstr() - called\n")); |
| 119 |
|
| 120 |
return winchnstr(stdscr, ch, n); |
| 121 |
} |
| 122 |
|
| 123 |
int mvinchnstr(int y, int x, chtype *ch, int n) |
| 124 |
{ |
| 125 |
PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n)); |
| 126 |
|
| 127 |
if (move(y, x) == ERR) |
| 128 |
return ERR; |
| 129 |
|
| 130 |
return winchnstr(stdscr, ch, n); |
| 131 |
} |
| 132 |
|
| 133 |
int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n) |
| 134 |
{ |
| 135 |
PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n)); |
| 136 |
|
| 137 |
if (wmove(win, y, x) == ERR) |
| 138 |
return ERR; |
| 139 |
|
| 140 |
return winchnstr(win, ch, n); |
| 141 |
} |
| 142 |
|
| 143 |
#ifdef PDC_WIDE |
| 144 |
int win_wchnstr(WINDOW *win, cchar_t *wch, int n) |
| 145 |
{ |
| 146 |
PDC_LOG(("win_wchnstr() - called\n")); |
| 147 |
|
| 148 |
return winchnstr(win, wch, n); |
| 149 |
} |
| 150 |
|
| 151 |
int in_wchstr(cchar_t *wch) |
| 152 |
{ |
| 153 |
PDC_LOG(("in_wchstr() - called\n")); |
| 154 |
|
| 155 |
return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx); |
| 156 |
} |
| 157 |
|
| 158 |
int win_wchstr(WINDOW *win, cchar_t *wch) |
| 159 |
{ |
| 160 |
PDC_LOG(("win_wchstr() - called\n")); |
| 161 |
|
| 162 |
return win_wchnstr(win, wch, win->_maxx - win->_curx); |
| 163 |
} |
| 164 |
|
| 165 |
int mvin_wchstr(int y, int x, cchar_t *wch) |
| 166 |
{ |
| 167 |
PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x)); |
| 168 |
|
| 169 |
if (move(y, x) == ERR) |
| 170 |
return ERR; |
| 171 |
|
| 172 |
return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx); |
| 173 |
} |
| 174 |
|
| 175 |
int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch) |
| 176 |
{ |
| 177 |
PDC_LOG(("mvwin_wchstr() - called:\n")); |
| 178 |
|
| 179 |
if (wmove(win, y, x) == ERR) |
| 180 |
return ERR; |
| 181 |
|
| 182 |
return win_wchnstr(win, wch, win->_maxx - win->_curx); |
| 183 |
} |
| 184 |
|
| 185 |
int in_wchnstr(cchar_t *wch, int n) |
| 186 |
{ |
| 187 |
PDC_LOG(("in_wchnstr() - called\n")); |
| 188 |
|
| 189 |
return win_wchnstr(stdscr, wch, n); |
| 190 |
} |
| 191 |
|
| 192 |
int mvin_wchnstr(int y, int x, cchar_t *wch, int n) |
| 193 |
{ |
| 194 |
PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n)); |
| 195 |
|
| 196 |
if (move(y, x) == ERR) |
| 197 |
return ERR; |
| 198 |
|
| 199 |
return win_wchnstr(stdscr, wch, n); |
| 200 |
} |
| 201 |
|
| 202 |
int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n) |
| 203 |
{ |
| 204 |
PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n)); |
| 205 |
|
| 206 |
if (wmove(win, y, x) == ERR) |
| 207 |
return ERR; |
| 208 |
|
| 209 |
return win_wchnstr(win, wch, n); |
| 210 |
} |
| 211 |
#endif |