Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9214 | turbocat | 1 | /* PDCurses */ |
2 | |||
3 | #include |
||
4 | |||
5 | /*man-start************************************************************** |
||
6 | |||
7 | addchstr |
||
8 | -------- |
||
9 | |||
10 | ### Synopsis |
||
11 | |||
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); |
||
20 | |||
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); |
||
30 | |||
31 | ### Description |
||
32 | |||
33 | These routines write a chtype or cchar_t string directly into the |
||
34 | window structure, starting at the current or specified position. The |
||
35 | four routines with n as the last argument copy at most n elements, |
||
36 | but no more than will fit on the line. If n == -1 then the whole |
||
37 | string is copied, up to the maximum number that will fit on the line. |
||
38 | |||
39 | The cursor position is not advanced. These routines do not check for |
||
40 | newline or other special characters, nor does any line wrapping |
||
41 | occur. |
||
42 | |||
43 | ### Return Value |
||
44 | |||
45 | All functions return OK or ERR. |
||
46 | |||
47 | ### Portability |
||
48 | X/Open ncurses NetBSD |
||
49 | addchstr Y Y Y |
||
50 | waddchstr Y Y Y |
||
51 | mvaddchstr Y Y Y |
||
52 | mvwaddchstr Y Y Y |
||
53 | addchnstr Y Y Y |
||
54 | waddchnstr Y Y Y |
||
55 | mvaddchnstr Y Y Y |
||
56 | mvwaddchnstr Y Y Y |
||
57 | add_wchstr Y Y Y |
||
58 | wadd_wchstr Y Y Y |
||
59 | mvadd_wchstr Y Y Y |
||
60 | mvwadd_wchstr Y Y Y |
||
61 | add_wchnstr Y Y Y |
||
62 | wadd_wchnstr Y Y Y |
||
63 | mvadd_wchnstr Y Y Y |
||
64 | mvwadd_wchnstr Y Y Y |
||
65 | |||
66 | **man-end****************************************************************/ |
||
67 | |||
68 | #include |
||
69 | |||
70 | int waddchnstr(WINDOW *win, const chtype *ch, int n) |
||
71 | { |
||
72 | int y, x, maxx, minx; |
||
73 | chtype *ptr; |
||
74 | |||
75 | PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n)); |
||
76 | |||
77 | if (!win || !ch || !n || n < -1) |
||
78 | return ERR; |
||
79 | |||
80 | x = win->_curx; |
||
81 | y = win->_cury; |
||
82 | ptr = &(win->_y[y][x]); |
||
83 | |||
84 | if (n == -1 || n > win->_maxx - x) |
||
85 | n = win->_maxx - x; |
||
86 | |||
87 | minx = win->_firstch[y]; |
||
88 | maxx = win->_lastch[y]; |
||
89 | |||
90 | for (; n && *ch; n--, x++, ptr++, ch++) |
||
91 | { |
||
92 | if (*ptr != *ch) |
||
93 | { |
||
94 | if (x < minx || minx == _NO_CHANGE) |
||
95 | minx = x; |
||
96 | |||
97 | if (x > maxx) |
||
98 | maxx = x; |
||
99 | |||
100 | PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch" |
||
101 | " %x firstch: %d lastch: %d\n", |
||
102 | y, x, minx, maxx, *ptr, *ch, |
||
103 | win->_firstch[y], win->_lastch[y])); |
||
104 | |||
105 | *ptr = *ch; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | win->_firstch[y] = minx; |
||
110 | win->_lastch[y] = maxx; |
||
111 | |||
112 | return OK; |
||
113 | } |
||
114 | |||
115 | int addchstr(const chtype *ch) |
||
116 | { |
||
117 | PDC_LOG(("addchstr() - called\n")); |
||
118 | |||
119 | return waddchnstr(stdscr, ch, -1); |
||
120 | } |
||
121 | |||
122 | int addchnstr(const chtype *ch, int n) |
||
123 | { |
||
124 | PDC_LOG(("addchnstr() - called\n")); |
||
125 | |||
126 | return waddchnstr(stdscr, ch, n); |
||
127 | } |
||
128 | |||
129 | int waddchstr(WINDOW *win, const chtype *ch) |
||
130 | { |
||
131 | PDC_LOG(("waddchstr() - called: win=%p\n", win)); |
||
132 | |||
133 | return waddchnstr(win, ch, -1); |
||
134 | } |
||
135 | |||
136 | int mvaddchstr(int y, int x, const chtype *ch) |
||
137 | { |
||
138 | PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x)); |
||
139 | |||
140 | if (move(y, x) == ERR) |
||
141 | return ERR; |
||
142 | |||
143 | return waddchnstr(stdscr, ch, -1); |
||
144 | } |
||
145 | |||
146 | int mvaddchnstr(int y, int x, const chtype *ch, int n) |
||
147 | { |
||
148 | PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n)); |
||
149 | |||
150 | if (move(y, x) == ERR) |
||
151 | return ERR; |
||
152 | |||
153 | return waddchnstr(stdscr, ch, n); |
||
154 | } |
||
155 | |||
156 | int mvwaddchstr(WINDOW *win, int y, int x, const chtype *ch) |
||
157 | { |
||
158 | PDC_LOG(("mvwaddchstr() - called:\n")); |
||
159 | |||
160 | if (wmove(win, y, x) == ERR) |
||
161 | return ERR; |
||
162 | |||
163 | return waddchnstr(win, ch, -1); |
||
164 | } |
||
165 | |||
166 | int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *ch, int n) |
||
167 | { |
||
168 | PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y, x, n)); |
||
169 | |||
170 | if (wmove(win, y, x) == ERR) |
||
171 | return ERR; |
||
172 | |||
173 | return waddchnstr(win, ch, n); |
||
174 | } |
||
175 | |||
176 | #ifdef PDC_WIDE |
||
177 | int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n) |
||
178 | { |
||
179 | PDC_LOG(("wadd_wchnstr() - called: win=%p n=%d\n", win, n)); |
||
180 | |||
181 | return waddchnstr(win, wch, n); |
||
182 | } |
||
183 | |||
184 | int add_wchstr(const cchar_t *wch) |
||
185 | { |
||
186 | PDC_LOG(("add_wchstr() - called\n")); |
||
187 | |||
188 | return wadd_wchnstr(stdscr, wch, -1); |
||
189 | } |
||
190 | |||
191 | int add_wchnstr(const cchar_t *wch, int n) |
||
192 | { |
||
193 | PDC_LOG(("add_wchnstr() - called\n")); |
||
194 | |||
195 | return wadd_wchnstr(stdscr, wch, n); |
||
196 | } |
||
197 | |||
198 | int wadd_wchstr(WINDOW *win, const cchar_t *wch) |
||
199 | { |
||
200 | PDC_LOG(("wadd_wchstr() - called: win=%p\n", win)); |
||
201 | |||
202 | return wadd_wchnstr(win, wch, -1); |
||
203 | } |
||
204 | |||
205 | int mvadd_wchstr(int y, int x, const cchar_t *wch) |
||
206 | { |
||
207 | PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y, x)); |
||
208 | |||
209 | if (move(y, x) == ERR) |
||
210 | return ERR; |
||
211 | |||
212 | return wadd_wchnstr(stdscr, wch, -1); |
||
213 | } |
||
214 | |||
215 | int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n) |
||
216 | { |
||
217 | PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y, x, n)); |
||
218 | |||
219 | if (move(y, x) == ERR) |
||
220 | return ERR; |
||
221 | |||
222 | return wadd_wchnstr(stdscr, wch, n); |
||
223 | } |
||
224 | |||
225 | int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch) |
||
226 | { |
||
227 | PDC_LOG(("mvwadd_wchstr() - called:\n")); |
||
228 | |||
229 | if (wmove(win, y, x) == ERR) |
||
230 | return ERR; |
||
231 | |||
232 | return wadd_wchnstr(win, wch, -1); |
||
233 | } |
||
234 | |||
235 | int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch, int n) |
||
236 | { |
||
237 | PDC_LOG(("mvwadd_wchnstr() - called: y %d x %d n %d \n", y, x, n)); |
||
238 | |||
239 | if (wmove(win, y, x) == ERR) |
||
240 | return ERR; |
||
241 | |||
242 | return wadd_wchnstr(win, wch, n); |
||
243 | } |
||
244 | #endif>> |