4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
45 #include "curses_inc.h"
49 /* This routine gets a string starting at (_cury, _curx) */
52 wgetstr(WINDOW
*win
, char *str
)
54 return ((wgetnstr(win
, str
, LENGTH
) == ERR
) ? ERR
: OK
);
58 wgetnstr(WINDOW
*win
, char *str
, int n
)
70 char rownum
[LENGTH
], colnum
[LENGTH
], length
[LENGTH
];
71 int doecho
= SP
->fl_echoit
;
72 int savecb
= cur_term
->_fl_rawmode
;
73 bool savsync
, savimmed
, savleave
;
77 fprintf(outf
, "doecho %d, savecb %d\n", doecho
, savecb
);
80 myerase
= erasechar();
86 SP
->fl_echoit
= FALSE
;
88 savimmed
= win
->_immed
;
89 savleave
= win
->_leave
;
90 win
->_immed
= win
->_sync
= win
->_leave
= FALSE
;
98 if (doecho
&& !docont
) {
99 rownum
[cpos
] = win
->_cury
;
100 colnum
[cpos
] = win
->_curx
;
107 if ((ch
== ERR
) || (ch
== '\n') || (ch
== '\r') ||
110 if ((ch
== myerase
) || (ch
== KEY_LEFT
) ||
111 (ch
== KEY_BACKSPACE
) || (ch
== mykill
)) {
122 total
-= (i
= length
[cpos
]);
125 (void) wmove(win
, rownum
[cpos
],
127 /* Add the correct amount of blanks. */
129 (void) waddch(win
, ' ');
130 /* Move back after the blanks are */
132 (void) wmove(win
, rownum
[cpos
],
135 (void) wrefresh(win
);
140 } else if ((KEY_MIN
<= ch
) && (ch
<= KEY_MAX
))
148 } else if (ISMBIT(ch
)) {
155 if (docont
&& (tbyte
>= eucw
)) {
161 length
[cpos
] = (char)scrw
;
162 (void) wechochar(win
,
166 /* Add the length of the */
167 /* character to total. */
173 length
[cpos
] = TABSIZE
-
178 total
+= length
[cpos
];
179 (void) wechochar(win
, (chtype
) ch
);
192 * The following code is equivalent to waddch(win, '\n')
193 * except that it does not do a wclrtoeol.
196 SP
->fl_echoit
= TRUE
;
198 if (win
->_cury
+ 1 > win
->_bmarg
)
199 (void) wscrl(win
, 1);
203 win
->_sync
= savsync
;
204 win
->_immed
= savimmed
;
205 win
->_leave
= savleave
;
206 (void) wrefresh(win
);