wgetch.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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, 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
/*
* wgetch.c
*
* 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/"
"cbates Exp $";
#endif
#endif
#include <private.h>
#include <string.h>
#include <errno.h>
static struct termios read_termios;
int
iqContainsFullLine(void)
{
int i;
/*
* Non-canonical mode ...
* Don't care about full lines ... continue
*/
return (1);
}
/*
* Terminal subsystem worries about lines etc. ...
* continue ...
*/
return (1);
}
/* We turned off ICANON so we have to do it ourselves */
/* We set delay mode. Only error if noting in the read */
return (!iqIsEmpty());
}
return (1);
if ('\n' == ch)
return (1);
}
return (0);
}
void
{
return;
(int) ch;
}
void
{
int count;
if (count) {
}
}
int
iqIsEmpty(void)
{
}
void
iqReset(void)
{
}
/* Assumes count > 0 */
int
iqPull(void)
{
int ch;
return (ch);
}
/* Discard n characters from front of Q */
void
iqTrash(int n)
{
}
}
int
iqGetNth(int n)
{
int ch;
return (EOF);
}
return (ch);
}
struct termios
{
/* If halfdelay mode. Leave canonical mode intact */
return (rval);
/* If blocking mode. Leave canonical mode intact */
if (vmin == 1)
return (rval);
/* VMIN and VTIME trash VEOL and VEOF so canonical cannot work */
(void) __m_tty_set(&newstuff);
return (rval);
}
int
__m_read_input_char(int *pChar)
{
if (req_for_input != NULL) {
}
*pChar = 0;
/* save actual setting for later test */
errno = 0;
}
*pChar &= 0x7f;
return (OK);
}
int
{
unsigned char ch;
ssize_t r;
if (req_for_input != NULL) {
}
*pChar = 0;
/* save actual setting for later test */
errno = 0;
} else {
}
return (OK);
} else if (r == 0) {
return (OK);
} else {
return (ERR);
}
}
static int klugeTypeaheadInGetch = 0;
int
pollTypeahead(void)
{
int ch;
/* Typeahead disabled */
return (0);
}
save = __m_tty_override_mode(0, 0);
break;
}
(void) __m_tty_set(&save);
/* if in wgetch, always do refresh */
return ((klugeTypeaheadInGetch) ? 0 : !iqIsEmpty());
}
/*
* Push single-byte character back onto the input queue.
*
* MKS EXTENSION permits the return value of wgetch(), which
* can be a KEY_ value, to be pushed back.
*/
int
{
return (OK);
}
/*
* Return true if the SCREEN's stream has an I/O error.
* Ignore the window parameter.
*/
/* ARGSUSED */
int
__xc_ferror(void *w)
{
}
/* ARGSUSED */
int
__xc_ungetc(int ch, void *w)
{
return (1);
}
/*
* Return true if the SCREEN's stream has seen EOF.
* Ignore the window parameter.
*/
/* ARGSUSED */
int
__xc_feof(void *w)
{
}
/*
* Clear the error and eof flags of the SCREEN's stream.
* Ignore the window parameter.
*/
/* ARGSUSED */
void
__xc_clearerr(void *w)
{
}
int
{
return (ch);
(void) beep();
return (ERR);
}
if (ch == '\b') {
if (w->_curx <= 0) {
(void) beep();
return (ch);
}
w->_curx--;
(void) wdelch(w);
} else {
}
(void) wrefresh(w);
return (ch);
}
int
{
(void) wrefresh(w);
if (iqIsEmpty()) {
(void) __m_tty_set(&save);
return (ERR);
}
/* Put EOF on Q only in non-canonical mode */
}
(void) __m_tty_set(&save);
}
if (!iqContainsFullLine()) {
return (ERR);
}
/*
* Only check for function keys if keypad is true and we
* did not read a KEY_ value (which are < 0), nor EOF.
* It is conceivable that a KEY_ was pushed back with
* ungetch().
*/
/*
* Treat the termios ERASE key the same as key_backspace.
*
* We used to change the key_backspace entry to be a string
* containing the ERASE key in setupterm(), but this would
* then disable the real terminfo entry for the backspace key.
* of the backspace key in application keypad mode.
* See SR 6014.
*
* Refer to _shell instead of _prog, since _shell will
* correctly reflect the user's prefered settings, whereas
* _prog may not have been initialised if both input and
* output have been redirected.
*/
#ifdef _POSIX_VDISABLE
#endif
/* Discard ch from Q */
(void) iqPull();
return (KEY_BACKSPACE);
}
/* Begin check for function key. */
/* Use input stack as a queue. */
for (i = 1; ; i++) {
goto uncoded;
}
/* Found funuction key? */
/* Trash all input used to make the FKey */
iqTrash(i);
}
/*
* Get next candidate character -
* either from Q or input
*/
/*
* Setup interbyte timer (once only).
* fgetc() will return EOF if no input received,
* which may not be a true EOF.
*/
if (timeout) {
(void) __m_tty_override_mode(0,
}
timeout = 0;
return (ERR);
/* Timeout or real eof. */
break;
}
/* Incomplete sequence, continue. */
}
}
/* Return first byte received or EOF. */
}