/*
* 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, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* XCurses Library
*
* Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
*
*/
#ifdef M_RCSID
#ifndef lint
static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/wgetn_ws.c 1.3 1995/10/02 15:07:23 ant Exp $";
#endif
#endif
#include <private.h>
#include <limits.h>
#include <stdlib.h>
#include <m_wio.h>
STATIC int fld_insert(void);
typedef struct t_key_entry {
int type;
int (*func)(void);
} t_key_entry;
#define ERASE_KEY 0
{ ERR, 0, fld_insert }
};
/*f
* 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
WINDOW *w;
void *s;
int n, mb_flag;
{
int type;
t_key_entry *k;
#ifdef M_CURSES_TRACE
#endif
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. */
if (mb_flag) {
/* Create a wint_t buffer, which makes it easier to
* handle erasing characters from the line.
*/
);
if (fld_buffer == (wint_t *) 0)
} else {
fld_buffer = (wint_t *) s;
}
/* 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;
/* 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()
{
return 0;
}
STATIC int
{
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 = y;
fld_window->_curx = x;
return 1;
}
STATIC int
fld_kill()
{
int y, x;
getyx(fld_window, y, x);
fld_buffer[0] = '\0';
return 1;
}
STATIC int
{
if (fld_maxlength < fld_index)
/* 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
wgetnstr(w, s, n)
WINDOW *w;
char *s;
int n;
{
int code;
#ifdef M_CURSES_TRACE
__m_trace("wgetnstr(%p, %p, %d)", w, s, n);
#endif
}
int
wgetn_wstr(w, s, n)
WINDOW *w;
wint_t *s;
int n;
{
int code;
#ifdef M_CURSES_TRACE
__m_trace("wgetn_wstr(%p, %p, %d)", w, s, n);
#endif
code = __m_wgetn_wstr(w, (void *) s, n, 0);
}