|
|
1.1 ! root 1: /* D.L.Buck and Associates, Inc. - May, 1984 ! 2: * ! 3: * COPYRIGHT NOTICE: ! 4: * Copyright c 1984 - An unpublished work by ! 5: * D.L.Buck and Associates, Inc. ! 6: * ! 7: * PROPRIETARY RIGHTS NOTICE: ! 8: * All rights reserved. This document and program contains ! 9: * proprietary information of D.L.Buck and Associates,Inc. ! 10: * of San Jose, California, U.S.A., embodying confidential ! 11: * information, ideas, and expressions, no part of which ! 12: * may be reproduced, or transmitted in any form or by any ! 13: * means, electronic, mechanical, or otherwise, without ! 14: * the written permission of D.L.Buck and Associates, Inc. ! 15: * ! 16: * NAME ! 17: * emputchar ! 18: * SYNOPSIS ! 19: * emputchar(cc) ! 20: * DESCRIPTION ! 21: * Places the character represented by "cc" at the position ! 22: * in the screen indicated by cursaddr, unless this isn't ! 23: * allowed. If INSERT_MODE is set in "status", the field is ! 24: * shifted. cursaddr and status may be affected. ! 25: */ ! 26: static char s_emputc[] = "@(#)emputchar.c 1.10 REL"; ! 27: ! 28: #include <em.h> ! 29: #include <ctype.h> ! 30: ! 31: emputchar(cc) ! 32: register int cc; ! 33: { ! 34: register char chr; /* used to check what char is at cursaddr */ ! 35: register int i; /* convenient index */ ! 36: int size; /* used to check size of field before insert */ ! 37: int ocursaddr; ! 38: int row; ! 39: int col; ! 40: ! 41: if (cc!=FM && cc!=DUP && (!isascii(cc) || !(isprint(cc) || cc==' '))) ! 42: return(NON_DISP); /* 'cc' is not displayable */ ! 43: ! 44: if (scrn_image[cursaddr] == (char)ATTRCODE) ! 45: return(ATTR_CHAR); /* location at cursaddr contains an ! 46: attribute character */ ! 47: ! 48: if (prot_attr(fldattr[curfield])) ! 49: return(PROTECTED); /* field is protected */ ! 50: ! 51: if (num_attr(fldattr[curfield]) && (!isdigit(cc) && cc != '.' && ! 52: cc != '-' && cc != DUP)) ! 53: return(NUMERIC); /* field is numeric */ ! 54: ! 55: if (do_screen) ! 56: if (hl_attr(fldattr[curfield])) /* turn on highlight */ ! 57: wstandout(vterm_scr); ! 58: else ! 59: wstandend(vterm_scr); ! 60: ! 61: if ((status & INSERT_MODE)) { ! 62: i = 0; /* count # nulls */ ! 63: size = cursaddr - fldstart[curfield]; ! 64: if (size < 0) size += MAXSCREENSIZE; ! 65: size = fldmax[curfield] - size; ! 66: if (totfields == 0) ! 67: size = fldmax[0]; ! 68: for (ocursaddr = cursaddr; ! 69: size; --size) { ! 70: if (scrn_image[ocursaddr] == '\0') ! 71: ++i; ! 72: if (++ocursaddr >= MAXSCREENSIZE) ! 73: ocursaddr = 0; ! 74: } ! 75: if (i == 0) /* no nulls were found */ ! 76: return(FLD_FULL); ! 77: ! 78: /* insert a character : ! 79: if character at cursaddr isn't null or blank, look for null or blank after ! 80: cursaddr and shift field to accomodate new character. */ ! 81: ! 82: ocursaddr = cursaddr; /* save present position */ ! 83: while((chr = scrn_image[cursaddr]) != '\0') { ! 84: if (++cursaddr >= MAXSCREENSIZE) ! 85: cursaddr = 0; ! 86: } ! 87: /* shift field */ ! 88: if (cursaddr < ocursaddr) cursaddr += MAXSCREENSIZE; ! 89: for (; cursaddr >= ocursaddr; --cursaddr) { ! 90: if (cursaddr < 0) ! 91: cursaddr = MAXSCREENSIZE - 1; ! 92: i=cursaddr>=MAXSCREENSIZE?cursaddr-MAXSCREENSIZE:cursaddr; ! 93: chr = scrn_image[i?i-1:MAXSCREENSIZE-1]; ! 94: scrn_image[i] = chr; ! 95: if (scrn_image[i] == '\0') chr = ' '; ! 96: if (do_screen && i != MAXSCREENSIZE - 1) { ! 97: row = i / SCREENWIDTH; ! 98: col = i % SCREENWIDTH; ! 99: if (invis_attr(fldattr[curfield])) ! 100: mvwaddch(vterm_scr,row,col,' '); ! 101: else if (chr == 0x1c) ! 102: mvwaddch(vterm_scr,row,col,'*'); /*DUP*/ ! 103: else if (chr == 0x1e) ! 104: mvwaddch(vterm_scr,row,col,';'); /*FM*/ ! 105: else ! 106: mvwaddch(vterm_scr,row,col,chr); ! 107: } ! 108: } ! 109: cursaddr = ocursaddr; ! 110: } ! 111: if (cc == DUP) ! 112: scrn_image[cursaddr] = 0x1c; ! 113: else if (cc == FM) ! 114: scrn_image[cursaddr] = 0x1e; ! 115: else ! 116: scrn_image[cursaddr] = cc; ! 117: ! 118: if (do_screen) { ! 119: if (LINES > 24 || cursaddr != MAXSCREENSIZE - 1) { ! 120: if (invis_attr(fldattr[curfield])) ! 121: mvwaddch(vterm_scr,ROW,COL,' '); ! 122: else { ! 123: if (cc == DUP) cc = '*'; ! 124: if (cc == FM) cc = ';'; ! 125: mvwaddch(vterm_scr,ROW,COL,cc); ! 126: } ! 127: } ! 128: if (hl_attr(fldattr[curfield])) /* turn off highlight */ ! 129: wstandend(vterm_scr); ! 130: wrefresh(vterm_scr); ! 131: } ! 132: ! 133: /* set MDT bit */ ! 134: fldattr[curfield] = fldattr[curfield] | ATTRMDT; ! 135: return(NORMAL); ! 136: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.