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
|
/* PDCurses */
#include <curspriv.h>
/*man-start**************************************************************
addchstr
--------
### Synopsis
int addchstr(const chtype *ch);
int addchnstr(const chtype *ch, int n);
int waddchstr(WINDOW *win, const chtype *ch);
int waddchnstr(WINDOW *win, const chtype *ch, int n);
int mvaddchstr(int y, int x, const chtype *ch);
int mvaddchnstr(int y, int x, const chtype *ch, int n);
int mvwaddchstr(WINDOW *, int y, int x, const chtype *ch);
int mvwaddchnstr(WINDOW *, int y, int x, const chtype *ch, int n);
int add_wchstr(const cchar_t *wch);
int add_wchnstr(const cchar_t *wch, int n);
int wadd_wchstr(WINDOW *win, const cchar_t *wch);
int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n);
int mvadd_wchstr(int y, int x, const cchar_t *wch);
int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n);
int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch);
int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch,
int n);
### Description
These routines write a chtype or cchar_t string directly into the
window structure, starting at the current or specified position. The
four routines with n as the last argument copy at most n elements,
but no more than will fit on the line. If n == -1 then the whole
string is copied, up to the maximum number that will fit on the line.
The cursor position is not advanced. These routines do not check for
newline or other special characters, nor does any line wrapping
occur.
### Return Value
All functions return OK or ERR.
### Portability
X/Open ncurses NetBSD
addchstr Y Y Y
waddchstr Y Y Y
mvaddchstr Y Y Y
mvwaddchstr Y Y Y
addchnstr Y Y Y
waddchnstr Y Y Y
mvaddchnstr Y Y Y
mvwaddchnstr Y Y Y
add_wchstr Y Y Y
wadd_wchstr Y Y Y
mvadd_wchstr Y Y Y
mvwadd_wchstr Y Y Y
add_wchnstr Y Y Y
wadd_wchnstr Y Y Y
mvadd_wchnstr Y Y Y
mvwadd_wchnstr Y Y Y
**man-end****************************************************************/
#include <string.h>
int waddchnstr(WINDOW *win, const chtype *ch, int n)
{
int y, x, maxx, minx;
chtype *ptr;
PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n));
if (!win || !ch || !n || n < -1)
return ERR;
x = win->_curx;
y = win->_cury;
ptr = &(win->_y[y][x]);
if (n == -1 || n > win->_maxx - x)
n = win->_maxx - x;
minx = win->_firstch[y];
maxx = win->_lastch[y];
for (; n && *ch; n--, x++, ptr++, ch++)
{
if (*ptr != *ch)
{
if (x < minx || minx == _NO_CHANGE)
minx = x;
if (x > maxx)
maxx = x;
PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch"
" %x firstch: %d lastch: %d\n",
y, x, minx, maxx, *ptr, *ch,
win->_firstch[y], win->_lastch[y]));
*ptr = *ch;
}
}
win->_firstch[y] = minx;
win->_lastch[y] = maxx;
return OK;
}
int addchstr(const chtype *ch)
{
PDC_LOG(("addchstr() - called\n"));
return waddchnstr(stdscr, ch, -1);
}
int addchnstr(const chtype *ch, int n)
{
PDC_LOG(("addchnstr() - called\n"));
return waddchnstr(stdscr, ch, n);
}
int waddchstr(WINDOW *win, const chtype *ch)
{
PDC_LOG(("waddchstr() - called: win=%p\n", win));
return waddchnstr(win, ch, -1);
}
int mvaddchstr(int y, int x, const chtype *ch)
{
PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x));
if (move(y, x) == ERR)
return ERR;
return waddchnstr(stdscr, ch, -1);
}
int mvaddchnstr(int y, int x, const chtype *ch, int n)
{
PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n));
if (move(y, x) == ERR)
return ERR;
return waddchnstr(stdscr, ch, n);
}
int mvwaddchstr(WINDOW *win, int y, int x, const chtype *ch)
{
PDC_LOG(("mvwaddchstr() - called:\n"));
if (wmove(win, y, x) == ERR)
return ERR;
return waddchnstr(win, ch, -1);
}
int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *ch, int n)
{
PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y, x, n));
if (wmove(win, y, x) == ERR)
return ERR;
return waddchnstr(win, ch, n);
}
#ifdef PDC_WIDE
int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n)
{
PDC_LOG(("wadd_wchnstr() - called: win=%p n=%d\n", win, n));
return waddchnstr(win, wch, n);
}
int add_wchstr(const cchar_t *wch)
{
PDC_LOG(("add_wchstr() - called\n"));
return wadd_wchnstr(stdscr, wch, -1);
}
int add_wchnstr(const cchar_t *wch, int n)
{
PDC_LOG(("add_wchnstr() - called\n"));
return wadd_wchnstr(stdscr, wch, n);
}
int wadd_wchstr(WINDOW *win, const cchar_t *wch)
{
PDC_LOG(("wadd_wchstr() - called: win=%p\n", win));
return wadd_wchnstr(win, wch, -1);
}
int mvadd_wchstr(int y, int x, const cchar_t *wch)
{
PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y, x));
if (move(y, x) == ERR)
return ERR;
return wadd_wchnstr(stdscr, wch, -1);
}
int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n)
{
PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y, x, n));
if (move(y, x) == ERR)
return ERR;
return wadd_wchnstr(stdscr, wch, n);
}
int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch)
{
PDC_LOG(("mvwadd_wchstr() - called:\n"));
if (wmove(win, y, x) == ERR)
return ERR;
return wadd_wchnstr(win, wch, -1);
}
int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch, int n)
{
PDC_LOG(("mvwadd_wchnstr() - called: y %d x %d n %d \n", y, x, n));
if (wmove(win, y, x) == ERR)
return ERR;
return wadd_wchnstr(win, wch, n);
}
#endif
|