1 /* Public Domain Curses */
5 RCSID("$Id: addchstr.c,v 1.43 2008/07/13 16:08:17 wmcbrine Exp $")
7 /*man-start**************************************************************
12 int addchstr(const chtype *ch);
13 int addchnstr(const chtype *ch, int n);
14 int waddchstr(WINDOW *win, const chtype *ch);
15 int waddchnstr(WINDOW *win, const chtype *ch, int n);
16 int mvaddchstr(int y, int x, const chtype *ch);
17 int mvaddchnstr(int y, int x, const chtype *ch, int n);
18 int mvwaddchstr(WINDOW *, int y, int x, const chtype *ch);
19 int mvwaddchnstr(WINDOW *, int y, int x, const chtype *ch, int n);
21 int add_wchstr(const cchar_t *wch);
22 int add_wchnstr(const cchar_t *wch, int n);
23 int wadd_wchstr(WINDOW *win, const cchar_t *wch);
24 int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n);
25 int mvadd_wchstr(int y, int x, const cchar_t *wch);
26 int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n);
27 int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch);
28 int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch,
32 These routines write a chtype or cchar_t string directly into
33 the window structure, starting at the current or specified
34 position. The four routines with n as the last argument copy at
35 most n elements, but no more than will fit on the line. If n =
36 -1 then the whole string is copied, up to the maximum number
37 that will fit on the line.
39 The cursor position is not advanced. These routines do not check
40 for newline or other special characters, nor does any line
44 All functions return OK or ERR.
46 Portability X/Open BSD SYS V
64 **man-end****************************************************************/
68 int waddchnstr(WINDOW
*win
, const chtype
*ch
, int n
)
73 PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win
, n
));
75 if (!win
|| !ch
|| !n
|| n
< -1)
80 ptr
= &(win
->_y
[y
][x
]);
82 if (n
== -1 || n
> win
->_maxx
- x
)
85 minx
= win
->_firstch
[y
];
86 maxx
= win
->_lastch
[y
];
88 for (; n
&& *ch
; n
--, x
++, ptr
++, ch
++)
92 if (x
< minx
|| minx
== _NO_CHANGE
)
98 PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch"
99 " %x firstch: %d lastch: %d\n",
100 y
, x
, minx
, maxx
, *ptr
, *ch
,
101 win
->_firstch
[y
], win
->_lastch
[y
]));
107 win
->_firstch
[y
] = minx
;
108 win
->_lastch
[y
] = maxx
;
113 int addchstr(const chtype
*ch
)
115 PDC_LOG(("addchstr() - called\n"));
117 return waddchnstr(stdscr
, ch
, -1);
120 int addchnstr(const chtype
*ch
, int n
)
122 PDC_LOG(("addchnstr() - called\n"));
124 return waddchnstr(stdscr
, ch
, n
);
127 int waddchstr(WINDOW
*win
, const chtype
*ch
)
129 PDC_LOG(("waddchstr() - called: win=%p\n", win
));
131 return waddchnstr(win
, ch
, -1);
134 int mvaddchstr(int y
, int x
, const chtype
*ch
)
136 PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y
, x
));
138 if (move(y
, x
) == ERR
)
141 return waddchnstr(stdscr
, ch
, -1);
144 int mvaddchnstr(int y
, int x
, const chtype
*ch
, int n
)
146 PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y
, x
, n
));
148 if (move(y
, x
) == ERR
)
151 return waddchnstr(stdscr
, ch
, n
);
154 int mvwaddchstr(WINDOW
*win
, int y
, int x
, const chtype
*ch
)
156 PDC_LOG(("mvwaddchstr() - called:\n"));
158 if (wmove(win
, y
, x
) == ERR
)
161 return waddchnstr(win
, ch
, -1);
164 int mvwaddchnstr(WINDOW
*win
, int y
, int x
, const chtype
*ch
, int n
)
166 PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y
, x
, n
));
168 if (wmove(win
, y
, x
) == ERR
)
171 return waddchnstr(win
, ch
, n
);
175 int wadd_wchnstr(WINDOW
*win
, const cchar_t
*wch
, int n
)
177 PDC_LOG(("wadd_wchnstr() - called: win=%p n=%d\n", win
, n
));
179 return waddchnstr(win
, wch
, n
);
182 int add_wchstr(const cchar_t
*wch
)
184 PDC_LOG(("add_wchstr() - called\n"));
186 return wadd_wchnstr(stdscr
, wch
, -1);
189 int add_wchnstr(const cchar_t
*wch
, int n
)
191 PDC_LOG(("add_wchnstr() - called\n"));
193 return wadd_wchnstr(stdscr
, wch
, n
);
196 int wadd_wchstr(WINDOW
*win
, const cchar_t
*wch
)
198 PDC_LOG(("wadd_wchstr() - called: win=%p\n", win
));
200 return wadd_wchnstr(win
, wch
, -1);
203 int mvadd_wchstr(int y
, int x
, const cchar_t
*wch
)
205 PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y
, x
));
207 if (move(y
, x
) == ERR
)
210 return wadd_wchnstr(stdscr
, wch
, -1);
213 int mvadd_wchnstr(int y
, int x
, const cchar_t
*wch
, int n
)
215 PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y
, x
, n
));
217 if (move(y
, x
) == ERR
)
220 return wadd_wchnstr(stdscr
, wch
, n
);
223 int mvwadd_wchstr(WINDOW
*win
, int y
, int x
, const cchar_t
*wch
)
225 PDC_LOG(("mvwadd_wchstr() - called:\n"));
227 if (wmove(win
, y
, x
) == ERR
)
230 return wadd_wchnstr(win
, wch
, -1);
233 int mvwadd_wchnstr(WINDOW
*win
, int y
, int x
, const cchar_t
*wch
, int n
)
235 PDC_LOG(("mvwadd_wchnstr() - called: y %d x %d n %d \n", y
, x
, n
));
237 if (wmove(win
, y
, x
) == ERR
)
240 return wadd_wchnstr(win
, wch
, n
);