File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.bin / bsc / cmd / 3270 / emputchar.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:26:11 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*	D.L.Buck and Associates, Inc. - May, 1984
 *
 *	COPYRIGHT NOTICE:
 *		Copyright c 1984 - An unpublished work by 
 *		D.L.Buck and Associates, Inc.
 *
 *	PROPRIETARY RIGHTS NOTICE:
 *		All rights reserved. This document and program contains
 *		proprietary information of D.L.Buck and Associates,Inc.
 *		of San Jose, California, U.S.A., embodying confidential
 *		information,  ideas, and expressions,  no part of which
 *		may be reproduced, or transmitted in any form or by any
 *		means,  electronic,  mechanical,  or otherwise, without
 *		the written permission of D.L.Buck and Associates, Inc.
 *
 *	NAME
 *		emputchar
 *	SYNOPSIS
 *		emputchar(cc)
 *	DESCRIPTION
 *		Places the character represented by "cc" at the position
 *		in the screen indicated by cursaddr, unless this isn't
 *		allowed. If INSERT_MODE is set in "status", the field is
 *		shifted. cursaddr and status may be affected.
 */
static char s_emputc[] = "@(#)emputchar.c	1.10 REL";

#include <em.h>
#include <ctype.h>

emputchar(cc)
register int cc;
{
	register char chr;	/* used to check what char is at cursaddr */
	register int i;		/* convenient index */
	int size;		/* used to check size of field before insert */
	int ocursaddr;
	int row;
	int col;

	if (cc!=FM && cc!=DUP && (!isascii(cc) || !(isprint(cc) || cc==' ')))
		return(NON_DISP);	/* 'cc' is not displayable */

	if (scrn_image[cursaddr] == (char)ATTRCODE)
		return(ATTR_CHAR);   	/* location at cursaddr contains an 
				           attribute character */

	if (prot_attr(fldattr[curfield]))
		return(PROTECTED);	/* field is protected */

	if (num_attr(fldattr[curfield]) && (!isdigit(cc) && cc != '.' &&
	    cc != '-' && cc != DUP))
		return(NUMERIC);	/* field is numeric */

	if (do_screen)
		if (hl_attr(fldattr[curfield]))	  /* turn on highlight */
			wstandout(vterm_scr);
		else
			wstandend(vterm_scr);

	if ((status & INSERT_MODE))	{
		i = 0;		/* count # nulls */
		size = cursaddr - fldstart[curfield];
		if (size < 0) size += MAXSCREENSIZE;
		size = fldmax[curfield] - size;
		if (totfields == 0)
			size = fldmax[0];
		for (ocursaddr = cursaddr;
		     size; --size) {
			if (scrn_image[ocursaddr] == '\0')
				++i;
			if (++ocursaddr >= MAXSCREENSIZE)
				ocursaddr = 0;
		}
		if (i == 0)	/* no nulls were found */
			return(FLD_FULL);
	
/* insert a character : 
   if character at cursaddr isn't null or blank, look for null or blank after 
   cursaddr and shift field to accomodate new character. */

		ocursaddr = cursaddr;	/* save present position */
		while((chr = scrn_image[cursaddr]) != '\0') {
			if (++cursaddr >= MAXSCREENSIZE)
				cursaddr = 0;
		}
	/* shift field */
		if (cursaddr < ocursaddr) cursaddr += MAXSCREENSIZE;
		for (; cursaddr >= ocursaddr; --cursaddr) {
			if (cursaddr < 0)
				cursaddr = MAXSCREENSIZE - 1;
		      i=cursaddr>=MAXSCREENSIZE?cursaddr-MAXSCREENSIZE:cursaddr;
			chr = scrn_image[i?i-1:MAXSCREENSIZE-1];
			scrn_image[i] = chr;
			if (scrn_image[i] == '\0') chr = ' ';
			if (do_screen && i != MAXSCREENSIZE - 1)	{
				row = i / SCREENWIDTH;
				col = i % SCREENWIDTH;
				if (invis_attr(fldattr[curfield]))
					mvwaddch(vterm_scr,row,col,' ');
				else if (chr == 0x1c)
					mvwaddch(vterm_scr,row,col,'*'); /*DUP*/
				else if (chr == 0x1e)
					mvwaddch(vterm_scr,row,col,';'); /*FM*/
				else
					mvwaddch(vterm_scr,row,col,chr);
			}
		}
		cursaddr = ocursaddr;
	}
	if (cc == DUP) 
		scrn_image[cursaddr] = 0x1c;
	else if (cc == FM) 
		scrn_image[cursaddr] = 0x1e;
	else 
		scrn_image[cursaddr] = cc;

	if (do_screen)	{
		if (LINES > 24 || cursaddr != MAXSCREENSIZE - 1)	{
			if (invis_attr(fldattr[curfield]))
				mvwaddch(vterm_scr,ROW,COL,' ');
			else	{
				if (cc == DUP) cc = '*';
				if (cc == FM) cc = ';';
				mvwaddch(vterm_scr,ROW,COL,cc);
			}
		}
		if (hl_attr(fldattr[curfield]))	/* turn off highlight */
			wstandend(vterm_scr);
		wrefresh(vterm_scr);
	}

/* set MDT bit */
	fldattr[curfield] = fldattr[curfield] | ATTRMDT;
	return(NORMAL);	
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.