1 2 3 4 5 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
/* PDCurses */
#include <curspriv.h>
/*man-start**************************************************************
instr
-----
### Synopsis
int instr(char *str);
int innstr(char *str, int n);
int winstr(WINDOW *win, char *str);
int winnstr(WINDOW *win, char *str, int n);
int mvinstr(int y, int x, char *str);
int mvinnstr(int y, int x, char *str, int n);
int mvwinstr(WINDOW *win, int y, int x, char *str);
int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
int inwstr(wchar_t *wstr);
int innwstr(wchar_t *wstr, int n);
int winwstr(WINDOW *win, wchar_t *wstr);
int winnwstr(WINDOW *win, wchar_t *wstr, int n);
int mvinwstr(int y, int x, wchar_t *wstr);
int mvinnwstr(int y, int x, wchar_t *wstr, int n);
int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr);
int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n);
### Description
These functions take characters (or wide characters) from the current
or specified position in the window, and return them as a string in
str (or wstr). Attributes are ignored. The functions with n as the
last argument return a string at most n characters long.
### Return Value
Upon successful completion, innstr(), mvinnstr(), mvwinnstr() and
winnstr() return the number of characters actually read into the
string; instr(), mvinstr(), mvwinstr() and winstr() return OK.
Otherwise, all these functions return ERR.
### Portability
X/Open ncurses NetBSD
instr Y Y Y
winstr Y Y Y
mvinstr Y Y Y
mvwinstr Y Y Y
innstr Y Y Y
winnstr Y Y Y
mvinnstr Y Y Y
mvwinnstr Y Y Y
inwstr Y Y Y
winwstr Y Y Y
mvinwstr Y Y Y
mvwinwstr Y Y Y
innwstr Y Y Y
winnwstr Y Y Y
mvinnwstr Y Y Y
mvwinnwstr Y Y Y
**man-end****************************************************************/
int winnstr(WINDOW *win, char *str, int n)
{
#ifdef PDC_WIDE
wchar_t wstr[513];
if (n < 0 || n > 512)
n = 512;
if (winnwstr(win, wstr, n) == ERR)
return ERR;
return PDC_wcstombs(str, wstr, n);
#else
chtype *src;
int i;
PDC_LOG(("winnstr() - called: n %d \n", n));
if (!win || !str)
return ERR;
if (n < 0 || (win->_curx + n) > win->_maxx)
n = win->_maxx - win->_curx;
src = win->_y[win->_cury] + win->_curx;
for (i = 0; i < n; i++)
str[i] = src[i] & A_CHARTEXT;
str[i] = '\0';
return i;
#endif
}
int instr(char *str)
{
PDC_LOG(("instr() - called: string=\"%s\"\n", str));
return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
int winstr(WINDOW *win, char *str)
{
PDC_LOG(("winstr() - called: \n"));
return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
int mvinstr(int y, int x, char *str)
{
PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
if (move(y, x) == ERR)
return ERR;
return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
int mvwinstr(WINDOW *win, int y, int x, char *str)
{
PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));
if (wmove(win, y, x) == ERR)
return ERR;
return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
int innstr(char *str, int n)
{
PDC_LOG(("innstr() - called: n %d \n", n));
return winnstr(stdscr, str, n);
}
int mvinnstr(int y, int x, char *str, int n)
{
PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
if (move(y, x) == ERR)
return ERR;
return winnstr(stdscr, str, n);
}
int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
{
PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));
if (wmove(win, y, x) == ERR)
return ERR;
return winnstr(win, str, n);
}
#ifdef PDC_WIDE
int winnwstr(WINDOW *win, wchar_t *wstr, int n)
{
chtype *src;
int i;
PDC_LOG(("winnstr() - called: n %d \n", n));
if (!win || !wstr)
return ERR;
if (n < 0 || (win->_curx + n) > win->_maxx)
n = win->_maxx - win->_curx;
src = win->_y[win->_cury] + win->_curx;
for (i = 0; i < n; i++)
wstr[i] = src[i] & A_CHARTEXT;
wstr[i] = L'\0';
return i;
}
int inwstr(wchar_t *wstr)
{
PDC_LOG(("inwstr() - called\n"));
return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
}
int winwstr(WINDOW *win, wchar_t *wstr)
{
PDC_LOG(("winwstr() - called\n"));
return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
}
int mvinwstr(int y, int x, wchar_t *wstr)
{
PDC_LOG(("mvinwstr() - called\n"));
if (move(y, x) == ERR)
return ERR;
return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
}
int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
{
PDC_LOG(("mvwinstr() - called\n"));
if (wmove(win, y, x) == ERR)
return ERR;
return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
}
int innwstr(wchar_t *wstr, int n)
{
PDC_LOG(("innwstr() - called\n"));
return winnwstr(stdscr, wstr, n);
}
int mvinnwstr(int y, int x, wchar_t *wstr, int n)
{
PDC_LOG(("mvinnstr() - called\n"));
if (move(y, x) == ERR)
return ERR;
return winnwstr(stdscr, wstr, n);
}
int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n)
{
PDC_LOG(("mvwinnwstr() - called\n"));
if (wmove(win, y, x) == ERR)
return ERR;
return winnwstr(win, wstr, n);
}
#endif
|