/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1995-1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
/*
*
* XCurses Library
*
* Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
*
*/
#ifdef M_RCSID
#ifndef lint
static char rcsID[] =
"$Header: /team/ps/sun_xcurses/archive/local_changes/xcurses/src/lib/"
"libxcurses/src/libc/xcurses/rcs/wgetn_ws.c 1.7 1998/06/04 19:56:00 "
"cbates Exp $";
#endif
#endif
#include <private.h>
#include <limits.h>
#include <stdlib.h>
#include <m_wio.h>
static int fld_done(void);
static int fld_erase(void);
static int fld_kill(void);
static int fld_insert(void);
typedef struct t_key_entry {
int type;
int (*func)(void);
} t_key_entry;
#define ERASE_KEY 0
#else
#endif
{ ERR, 0, fld_insert }
};
/*
* The effect of wgetnstr() is as though a series of calls to wgetch()
* were made, until a <newline> or <return> are received. The
* resulting value is placed in the area pointed to by the character
* pointer 's'. wgetnstr() reads at most n characters, thus
* preventing a possible overflow of the input buffer. The user's
* erase and kill characters are interpreted.
*
* If n < 0, wgetnstr() will read until a <newline> or <return> is
* entered. To accept functions keys, keypad() must be set for the
* window.
*/
int
{
int type;
t_key_entry *k;
if (n == 0) {
*(char *)s = '\0';
return (OK);
}
fld_window = w;
fld_index = 0;
fld_bytes = 0;
/* Read at most N bytes from the field. */
fld_maxlength = n < 0 ? LINE_MAX : n;
/* Make sure there is enough to hold the largest characater. */
return (ERR);
if (mb_flag) {
/*
* Create a wint_t buffer, which makes it easier to
* handle erasing characters from the line.
*/
sizeof (*fld_buffer));
if (fld_buffer == NULL)
return (ERR);
} else {
fld_buffer = (wint_t *) s;
}
#endif
/*
* We remember if the user specified echo on or off, then disable it
* so that wgetch() doesn't perform any echoing before we've had a
* chance to process the key. fld_insert() will handle the necessary
* echoing of characters.
*/
fld_echo = __m_set_echo(0);
(void) cbreak();
for (; ; ) {
break;
break;
}
}
/* If the edit function returned false then quit. */
break;
}
}
/* Restore the I/O settings. */
(void) __m_set_echo(fld_echo);
(void) __m_tty_set(&saved);
if (mb_flag) {
}
}
static int
{
int len;
return (0);
}
static int
fld_done(void)
{
if (fld_echo) {
}
return (0);
}
static int
fld_erase(void)
{
int x, y, width;
if (fld_index <= 0) {
return (1);
}
getyx(fld_window, y, x);
if (0 < x) {
/* Rubout previous character. */
x -= width;
} else if (0 < y) {
/* Reverse line wrap. */
--y;
/*
* Find end of previous character, skipping any background
* character that may have been written by auto-wrap.
*/
--x;
/* Find first column of character. */
x = __m_cc_first(fld_window, y, x);
}
(void) __m_cc_erase(fld_window, y, x, y, x);
fld_window->_cury = (short) y;
fld_window->_curx = (short) x;
return (1);
}
static int
fld_kill(void)
{
int y, x;
getyx(fld_window, y, x);
fld_buffer[0] = '\0';
return (1);
}
static int
fld_insert(void)
{
/* Completely full, terminate input. */
return (0);
/*
* Don't exceed the byte length for the field.
*
* m_wio_get() called by wget_wch(), records the
* number of bytes converted, when _next == _size.
*
* wget_wch() makes sure that _next == _size by
* pushing invalid multibyte characters on to an
* input stack.
*/
/* Is there still room for single-byte characters? */
if (fld_bytes < fld_maxlength) {
(void) beep();
return (1);
}
/* Completely full, terminate input. */
return (0);
}
if (0 <= fld_key) {
if (fld_echo) {
}
} else {
(void) beep();
}
return (1);
}
int
{
int code;
return (code);
}
int
{
int code;
code = __m_wgetn_wstr(w, (void *) s, n, 0);
return (code);
}