/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1981 Regents of the University of California */
#include "ex.h"
#include "ex_tty.h"
/*
* Input routines for command mode.
* Since we translate the end of reads into the implied ^D's
*/
static bool junkbs;
void
ignchar(void)
{
(void)getchar();
}
int
getchar(void)
{
int c;
do
c = getcd();
return (c);
}
int
getcd(void)
{
int c;
extern short slevel;
c = getach();
if (c == EOF)
return (c);
setlastchar('\n');
else if (junk(c)) {
checkjunk(c);
goto again;
}
return (c);
}
int
peekchar(void)
{
if (peekc == 0)
return (peekc);
}
int
peekcd(void)
{
if (peekc == 0)
return (peekc);
}
int verbose;
int
getach(void)
{
int c, i, prev;
c = peekc;
if (c != 0) {
peekc = 0;
return (c);
}
if (globp) {
if (*globp)
return (*globp++);
globp = 0;
}
top:
if (input) {
if(c = *input++)
return (lastc = c);
input = 0;
}
flush();
if (intty) {
if (c < 0)
noteinp();
prev = 0;
/* remove nulls from input buffer */
for (i = 0; i < c; i++)
if(inputline[i] != 0)
goto top;
}
else {
if (verbose)
}
return (lastc);
}
/*
* Most work here is in handling autoindent.
*/
static short lastin;
int
gettty(void)
{
int c = 0;
unsigned char hadup = 0;
extern int (*Pline)();
int ch;
if (offset) {
holdcm = 1;
flush();
holdcm = 0;
}
holdcm = 1;
holdcm = 0;
return (EOF);
}
}
switch (c) {
case '^':
case '0':
if (c == '0')
lastin = 0;
if (!over_strike) {
}
hadup = 1;
c = getchar();
} else
break;
case '.':
if (peekchar() == '\n') {
ignchar();
noteinp();
holdcm = 0;
return (EOF);
}
break;
case '\n':
hadup = 1;
break;
}
}
flush();
holdcm = 0;
}
if (c == 0)
c = getchar();
while (c != EOF && c != '\n') {
*cp++ = c;
c = getchar();
}
if (c == EOF) {
if (inglobal)
return (EOF);
}
*cp = 0;
*cp++ = '\t';
for (; c > 0; c--)
*cp++ = ' ';
}
return (EOF);
return (0);
}
/*
* Crunch the indent.
* Hard thing here is that in command mode some of the indent
* is only implicit, so we must seed the column counter.
* This should really be done differently so as to use the whitecnt routine
* and also to hack indenting for LISP.
*/
int
{
unsigned char *cp;
for (;;)
switch (*cp++) {
case ' ':
col++;
continue;
case '\t':
continue;
default:
cp--;
return (col);
}
}
void
checkjunk(unsigned char c)
{
if (junkbs == 0 && c == '\b') {
junkbs = 1;
}
}
void
{
lastin = 0;
else
}