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]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/types.h>
36 #include "curses_inc.h"
40 /* This routine gets a string starting at (_cury, _curx) */
42 wgetwstr(WINDOW
*win
, wchar_t *str
)
44 return ((wgetnwstr(win
, str
, LENGTH
) == ERR
) ? ERR
: OK
);
48 wgetnwstr(WINDOW
*win
, wchar_t *str
, int n
)
55 char rownum
[LENGTH
], colnum
[LENGTH
], length
[LENGTH
];
56 int doecho
= SP
->fl_echoit
;
57 int savecb
= cur_term
->_fl_rawmode
;
58 bool savsync
, savimmed
, savleave
;
62 fprintf(outf
, "doecho %d, savecb %d\n", doecho
, savecb
);
65 myerase
= erasechar();
71 SP
->fl_echoit
= FALSE
;
73 savimmed
= win
->_immed
;
74 savleave
= win
->_leave
;
75 win
->_immed
= win
->_sync
= win
->_leave
= FALSE
;
84 rownum
[cpos
] = win
->_cury
;
85 colnum
[cpos
] = win
->_curx
;
89 if ((ch
== ERR
) || (ch
== '\n') || (ch
== '\r') ||
92 if ((ch
== myerase
) || (ch
== KEY_LEFT
) ||
93 (ch
== KEY_BACKSPACE
) || (ch
== mykill
)) {
103 total
-= (i
= length
[cpos
]);
106 (void) wmove(win
, rownum
[cpos
],
108 /* Add the correct amount of blanks. */
110 (void) waddch(win
, ' ');
111 /* Move back after the blanks */
113 (void) wmove(win
, rownum
[cpos
],
116 (void) wrefresh(win
);
122 if ((KEY_MIN
<= ch
) && (ch
<= KEY_MAX
))
127 /* Add the length of the */
128 /* character to total. */
129 if ((ch
& EUCMASK
) != P00
)
130 length
[cpos
] = wcscrw(ch
);
134 length
[cpos
] = TABSIZE
-
135 (colnum
[cpos
] % TABSIZE
);
138 total
+= length
[cpos
];
139 (void) wechowchar(win
, (chtype
) ch
);
150 * The following code is equivalent to waddch(win, '\n')
151 * except that it does not do a wclrtoeol.
154 SP
->fl_echoit
= TRUE
;
156 if (win
->_cury
+ 1 > win
->_bmarg
)
157 (void) wscrl(win
, 1);
161 win
->_sync
= savsync
;
162 win
->_immed
= savimmed
;
163 win
->_leave
= savleave
;
164 (void) wrefresh(win
);