mb/google/nissa/var/glassway: Modify touch screen ILIT2901 sequence
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / addchstr.c
blob249ea8d457354932a6389a4b1f424616ed2efc7e
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: addchstr.c,v 1.43 2008/07/13 16:08:17 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: addchstr
11 Synopsis:
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,
29 int n);
31 Description:
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
41 wrapping occur.
43 Return Value:
44 All functions return OK or ERR.
46 Portability X/Open BSD SYS V
47 addchstr Y - 4.0
48 waddchstr Y - 4.0
49 mvaddchstr Y - 4.0
50 mvwaddchstr Y - 4.0
51 addchnstr Y - 4.0
52 waddchnstr Y - 4.0
53 mvaddchnstr Y - 4.0
54 mvwaddchnstr Y - 4.0
55 add_wchstr Y
56 wadd_wchstr Y
57 mvadd_wchstr Y
58 mvwadd_wchstr Y
59 add_wchnstr Y
60 wadd_wchnstr Y
61 mvadd_wchnstr Y
62 mvwadd_wchnstr Y
64 **man-end****************************************************************/
66 #include <string.h>
68 int waddchnstr(WINDOW *win, const chtype *ch, int n)
70 int y, x, maxx, minx;
71 chtype *ptr;
73 PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n));
75 if (!win || !ch || !n || n < -1)
76 return ERR;
78 x = win->_curx;
79 y = win->_cury;
80 ptr = &(win->_y[y][x]);
82 if (n == -1 || n > win->_maxx - x)
83 n = win->_maxx - x;
85 minx = win->_firstch[y];
86 maxx = win->_lastch[y];
88 for (; n && *ch; n--, x++, ptr++, ch++)
90 if (*ptr != *ch)
92 if (x < minx || minx == _NO_CHANGE)
93 minx = x;
95 if (x > maxx)
96 maxx = x;
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]));
103 *ptr = *ch;
107 win->_firstch[y] = minx;
108 win->_lastch[y] = maxx;
110 return OK;
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)
139 return 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)
149 return 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)
159 return 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)
169 return ERR;
171 return waddchnstr(win, ch, n);
174 #ifdef PDC_WIDE
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)
208 return 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)
218 return 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)
228 return 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)
238 return ERR;
240 return wadd_wchnstr(win, wch, n);
242 #endif