mb/google/nissa/var/glassway: Modify touch screen ILIT2901 sequence
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / instr.c
blob733a348eb6a3cdd46771b82f01717d8b31be7805
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: instr.c,v 1.44 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: instr
11 Synopsis:
12 int instr(char *str);
13 int innstr(char *str, int n);
14 int winstr(WINDOW *win, char *str);
15 int winnstr(WINDOW *win, char *str, int n);
16 int mvinstr(int y, int x, char *str);
17 int mvinnstr(int y, int x, char *str, int n);
18 int mvwinstr(WINDOW *win, int y, int x, char *str);
19 int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
21 int inwstr(wchar_t *wstr);
22 int innwstr(wchar_t *wstr, int n);
23 int winwstr(WINDOW *win, wchar_t *wstr);
24 int winnwstr(WINDOW *win, wchar_t *wstr, int n);
25 int mvinwstr(int y, int x, wchar_t *wstr);
26 int mvinnwstr(int y, int x, wchar_t *wstr, int n);
27 int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr);
28 int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n);
30 Description:
31 These functions take characters (or wide characters) from the
32 current or specified position in the window, and return them as
33 a string in str (or wstr). Attributes are ignored. The functions
34 with n as the last argument return a string at most n characters
35 long.
37 Return Value:
38 Upon successful completion, innstr(), mvinnstr(), mvwinnstr()
39 and winnstr() return the number of characters actually read into
40 the string; instr(), mvinstr(), mvwinstr() and winstr() return
41 OK. Otherwise, all these functions return ERR.
43 Portability X/Open BSD SYS V
44 instr Y - 4.0
45 winstr Y - 4.0
46 mvinstr Y - 4.0
47 mvwinstr Y - 4.0
48 innstr Y - 4.0
49 winnstr Y - 4.0
50 mvinnstr Y - 4.0
51 mvwinnstr Y - 4.0
52 inwstr Y
53 winwstr Y
54 mvinwstr Y
55 mvwinwstr Y
56 innwstr Y
57 winnwstr Y
58 mvinnwstr Y
59 mvwinnwstr Y
61 **man-end****************************************************************/
63 int winnstr(WINDOW *win, char *str, int n)
65 #ifdef PDC_WIDE
66 wchar_t wstr[513];
68 if (n < 0 || n > 512)
69 n = 512;
71 if (winnwstr(win, wstr, n) == ERR)
72 return ERR;
74 return PDC_wcstombs(str, wstr, n);
75 #else
76 chtype *src;
77 int i;
79 PDC_LOG(("winnstr() - called: n %d \n", n));
81 if (!win || !str)
82 return ERR;
84 if (n < 0 || (win->_curx + n) > win->_maxx)
85 n = win->_maxx - win->_curx;
87 src = win->_y[win->_cury] + win->_curx;
89 for (i = 0; i < n; i++)
90 str[i] = src[i] & A_CHARTEXT;
92 str[i] = '\0';
94 return i;
95 #endif
98 int instr(char *str)
100 PDC_LOG(("instr() - called: string=\"%s\"\n", str));
102 return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
105 int winstr(WINDOW *win, char *str)
107 PDC_LOG(("winstr() - called: \n"));
109 return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
112 int mvinstr(int y, int x, char *str)
114 PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
116 if (move(y, x) == ERR)
117 return ERR;
119 return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
122 int mvwinstr(WINDOW *win, int y, int x, char *str)
124 PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));
126 if (wmove(win, y, x) == ERR)
127 return ERR;
129 return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
132 int innstr(char *str, int n)
134 PDC_LOG(("innstr() - called: n %d \n", n));
136 return winnstr(stdscr, str, n);
139 int mvinnstr(int y, int x, char *str, int n)
141 PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
143 if (move(y, x) == ERR)
144 return ERR;
146 return winnstr(stdscr, str, n);
149 int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
151 PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));
153 if (wmove(win, y, x) == ERR)
154 return ERR;
156 return winnstr(win, str, n);
159 #ifdef PDC_WIDE
160 int winnwstr(WINDOW *win, wchar_t *wstr, int n)
162 chtype *src;
163 int i;
165 PDC_LOG(("winnstr() - called: n %d \n", n));
167 if (!win || !wstr)
168 return ERR;
170 if (n < 0 || (win->_curx + n) > win->_maxx)
171 n = win->_maxx - win->_curx;
173 src = win->_y[win->_cury] + win->_curx;
175 for (i = 0; i < n; i++)
176 wstr[i] = src[i] & A_CHARTEXT;
178 wstr[i] = L'\0';
180 return i;
183 int inwstr(wchar_t *wstr)
185 PDC_LOG(("inwstr() - called\n"));
187 return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
190 int winwstr(WINDOW *win, wchar_t *wstr)
192 PDC_LOG(("winwstr() - called\n"));
194 return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
197 int mvinwstr(int y, int x, wchar_t *wstr)
199 PDC_LOG(("mvinwstr() - called\n"));
201 if (move(y, x) == ERR)
202 return ERR;
204 return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
207 int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
209 PDC_LOG(("mvwinstr() - called\n"));
211 if (wmove(win, y, x) == ERR)
212 return ERR;
214 return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
217 int innwstr(wchar_t *wstr, int n)
219 PDC_LOG(("innwstr() - called\n"));
221 return winnwstr(stdscr, wstr, n);
224 int mvinnwstr(int y, int x, wchar_t *wstr, int n)
226 PDC_LOG(("mvinnstr() - called\n"));
228 if (move(y, x) == ERR)
229 return ERR;
231 return winnwstr(stdscr, wstr, n);
234 int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n)
236 PDC_LOG(("mvwinnwstr() - called\n"));
238 if (wmove(win, y, x) == ERR)
239 return ERR;
241 return winnwstr(win, wstr, n);
243 #endif