pdcurses/inchstr.c

branch
protocol5
changeset 106
7b156b764d11
parent 97
2d43f05b284c
equal deleted inserted replaced
104:a76af67a3a4b 106:7b156b764d11
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: inchstr
10
11 Synopsis:
12 int inchstr(chtype *ch);
13 int inchnstr(chtype *ch, int n);
14 int winchstr(WINDOW *win, chtype *ch);
15 int winchnstr(WINDOW *win, chtype *ch, int n);
16 int mvinchstr(int y, int x, chtype *ch);
17 int mvinchnstr(int y, int x, chtype *ch, int n);
18 int mvwinchstr(WINDOW *, int y, int x, chtype *ch);
19 int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);
20
21 int in_wchstr(cchar_t *wch);
22 int in_wchnstr(cchar_t *wch, int n);
23 int win_wchstr(WINDOW *win, cchar_t *wch);
24 int win_wchnstr(WINDOW *win, cchar_t *wch, int n);
25 int mvin_wchstr(int y, int x, cchar_t *wch);
26 int mvin_wchnstr(int y, int x, cchar_t *wch, int n);
27 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);
28 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);
29
30 Description:
31 These routines read a chtype or cchar_t string from the window,
32 starting at the current or specified position, and ending at the
33 right margin, or after n elements, whichever is less.
34
35 Return Value:
36 All functions return the number of elements read, or ERR on
37 error.
38
39 Portability X/Open BSD SYS V
40 inchstr Y - 4.0
41 winchstr Y - 4.0
42 mvinchstr Y - 4.0
43 mvwinchstr Y - 4.0
44 inchnstr Y - 4.0
45 winchnstr Y - 4.0
46 mvinchnstr Y - 4.0
47 mvwinchnstr Y - 4.0
48 in_wchstr Y
49 win_wchstr Y
50 mvin_wchstr Y
51 mvwin_wchstr Y
52 in_wchnstr Y
53 win_wchnstr Y
54 mvin_wchnstr Y
55 mvwin_wchnstr Y
56
57 **man-end****************************************************************/
58
59 int winchnstr(WINDOW *win, chtype *ch, int n)
60 {
61 chtype *src;
62 int i;
63
64 PDC_LOG(("winchnstr() - called\n"));
65
66 if (!win || !ch || n < 0)
67 return ERR;
68
69 if ((win->_curx + n) > win->_maxx)
70 n = win->_maxx - win->_curx;
71
72 src = win->_y[win->_cury] + win->_curx;
73
74 for (i = 0; i < n; i++)
75 *ch++ = *src++;
76
77 *ch = (chtype)0;
78
79 return OK;
80 }
81
82 int inchstr(chtype *ch)
83 {
84 PDC_LOG(("inchstr() - called\n"));
85
86 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
87 }
88
89 int winchstr(WINDOW *win, chtype *ch)
90 {
91 PDC_LOG(("winchstr() - called\n"));
92
93 return winchnstr(win, ch, win->_maxx - win->_curx);
94 }
95
96 int mvinchstr(int y, int x, chtype *ch)
97 {
98 PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
99
100 if (move(y, x) == ERR)
101 return ERR;
102
103 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
104 }
105
106 int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
107 {
108 PDC_LOG(("mvwinchstr() - called:\n"));
109
110 if (wmove(win, y, x) == ERR)
111 return ERR;
112
113 return winchnstr(win, ch, win->_maxx - win->_curx);
114 }
115
116 int inchnstr(chtype *ch, int n)
117 {
118 PDC_LOG(("inchnstr() - called\n"));
119
120 return winchnstr(stdscr, ch, n);
121 }
122
123 int mvinchnstr(int y, int x, chtype *ch, int n)
124 {
125 PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
126
127 if (move(y, x) == ERR)
128 return ERR;
129
130 return winchnstr(stdscr, ch, n);
131 }
132
133 int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)
134 {
135 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
136
137 if (wmove(win, y, x) == ERR)
138 return ERR;
139
140 return winchnstr(win, ch, n);
141 }
142
143 #ifdef PDC_WIDE
144 int win_wchnstr(WINDOW *win, cchar_t *wch, int n)
145 {
146 PDC_LOG(("win_wchnstr() - called\n"));
147
148 return winchnstr(win, wch, n);
149 }
150
151 int in_wchstr(cchar_t *wch)
152 {
153 PDC_LOG(("in_wchstr() - called\n"));
154
155 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
156 }
157
158 int win_wchstr(WINDOW *win, cchar_t *wch)
159 {
160 PDC_LOG(("win_wchstr() - called\n"));
161
162 return win_wchnstr(win, wch, win->_maxx - win->_curx);
163 }
164
165 int mvin_wchstr(int y, int x, cchar_t *wch)
166 {
167 PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
168
169 if (move(y, x) == ERR)
170 return ERR;
171
172 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
173 }
174
175 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
176 {
177 PDC_LOG(("mvwin_wchstr() - called:\n"));
178
179 if (wmove(win, y, x) == ERR)
180 return ERR;
181
182 return win_wchnstr(win, wch, win->_maxx - win->_curx);
183 }
184
185 int in_wchnstr(cchar_t *wch, int n)
186 {
187 PDC_LOG(("in_wchnstr() - called\n"));
188
189 return win_wchnstr(stdscr, wch, n);
190 }
191
192 int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
193 {
194 PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
195
196 if (move(y, x) == ERR)
197 return ERR;
198
199 return win_wchnstr(stdscr, wch, n);
200 }
201
202 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)
203 {
204 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
205
206 if (wmove(win, y, x) == ERR)
207 return ERR;
208
209 return win_wchnstr(win, wch, n);
210 }
211 #endif

mercurial