Example #1
0
static boolean print_eol(void)
{
	boolean status = FALSE;
	if ( ( status = prtchar( (char)13 )	) == FALSE )	/* CR */
		status = prtchar( (char)10 );					/* LF */
	return status;
}
Example #2
0
static boolean print_line 
( 
	char *dline 	/* 0-terminated line to print */
)
{
	char *p;					/* address of position in dline string */
	int i;						/* position in printer line */
	boolean status = FALSE;		/* prtchar print status */

	p = dline;
	i = 0;
	while ( !status && (*p != 0) )
	{
		status = prtchar(*p); 		/* beware: prtchar is false when OK ! */
		p++;
		i++;
		if ( !status && ((*p == 0) || (i >= plinelen)) ) /* end of line or line too long */
		{
			i = 0;					/* reset linelength counter */
			status = print_eol();	/* print cr lf */
		}	/* if...    */ 
	} 		/* while... */

	return status;					/* this one is FALSE if ok, too! */
}
Example #3
0
int
qnxinc(void)
{
    extern int pmask, cmask;
    extern int tt_utf8;
    int ch;

  loop:
    ch = ttinc(0);
    if ( ch < 0 )
        return ch;

    if ( seslog )
        logchar(ch);

    /* Handle the UTF8 conversion if we are in that mode */
    if ( tt_utf8 ) {
        USHORT * ucs2 = NULL;
        int rc = utf8_to_ucs2( (CHAR)(ch & 0xFF), &ucs2 );
        if ( rc > 0 )
            goto loop;
        else if ( rc < 0 )
            ch = 0xfffd;
        else
            ch = *ucs2;
    }

    if ( !xprint ) {
#ifndef NOXFER
        autodown(ch);
#endif /* NOXFER */
        autoexitchk(ch);
    }
    ch = ch & pmask & cmask;
    debugses(ch);
    if (printon && (is_xprint() || is_uprint()))
        prtchar(ch);
    return ch;
}
Example #4
0
void
qnxascii( int ch )
{
    int i,j,k,n,x,y,z;
    vtattrib attr={0,0,0,0,0,0,0,0,0,0,0} ;
    viocell blankvcell;

    if (printon && (is_xprint() || is_uprint()))
        prtchar(ch);

    if ( escstate == ES_GOTESC )/* Process character as part of an escstate sequence */
    {
        if ( ch <= SP ) {
            /* Print character as graphic */
            escstate = ES_NORMAL ;
            debug(F111,"QNX","Display character as graphic",ch);
            wrtch(ch);
        }
        else
        {
            escstate = ES_ESCSEQ ;
            switch ( ch ) {
            case '!': {
                /* Set the fill color used for blank lines when scrolling   */
                /* and for clearscreen when FF is received.                 */
                /* '0'=black, blue, green, cyan, red, magenta, brown, white */
                int fg = qnxinc();
                int bg = qnxinc();
                debug(F110,"QNX","Set the Fill Color",0);
                if ( debses )
                    break;
                if ( bg < '0' || bg >= '8' || fg < '0' || fg >= '8' )
                    break;
                defaultattribute = ((bg-'0')<<4) | (fg-'0');
                break;
            }
            case '"':
                break;
            case '#':
                break;
            case '$':
                break;
            case '%':
                break;
            case '&':
                break;
            case '\'':
                break;
            case '(':
                /* Turn on Reverse attribute */
                debug(F110,"QNX","Turn on Reverse attribute",0);
                if ( debses )
                    break;
                attrib.reversed = TRUE;
                break;
            case ')':
                /* Turn off Reverse Attribute */
                debug(F110,"QNX","Turn off Reverse attribute",0);
                if ( debses )
                    break;
                attrib.reversed = FALSE;
                break;
            case '*':
                break;
            case '+':
                break;
            case ',':
                break;
            case '-':
                break;
            case '.':
                break;
            case '/':
                break;
            case '0':
                break;
            case '1':
                break;
            case '2':
                break;
            case '3':
                break;
            case '4':
                break;
            case '5':
                break;
            case '6':
                break;
            case '7':
                break;
            case '8':
                break;
            case '9':
                break;
            case ':':
                break;
            case ';':
                break;
            case '<':
                /* Turn on Bold */
                debug(F110,"QNX","Turn on Bold",0);
                if ( debses )
                    break;
                attrib.bold = TRUE;
                break;
            case '=': {
                /* Position Cursor */
                int row = qnxinc() - 31;
                int col = qnxinc() - 31;
                debug(F110,"QNX","Address cursor to row col",0);
                if ( debses )
                    break;
                lgotoxy(VTERM,col,row);
                break;
            }
            case '>':
                /* Turn off Bold */
                debug(F110,"QNX","Turn off Bold",0);
                if ( debses )
                    break;
                attrib.bold = FALSE;
                break;
            case '?':
                break;
            case '@': {
                /* Define fg,bg colors of the display characters */
                int fg = qnxinc();
                int bg = qnxinc();
                debug(F110,"QNX","Set the Display Colors",0);
                if ( debses )
                    break;
                if ( fg < '0' || fg >= '8' || bg < '0' || bg >= '8' )
                    break;
                attribute = ((bg-'0')<<4) | (fg-'0');
                break;
            }
            case 'A':
                /* Cursor Up */
                debug(F110,"QNX","Cursor Up (no wrap)",0);
                if ( debses )
                    break;
                cursorup(0);
                break;
            case 'B':
                /* Cursor Down */
                debug(F110,"QNX","Cursor Down (no wrap)",0);
                if ( debses )
                    break;
                cursordown(0);
                break;
            case 'C':
                /* Cursor Right (no wrap)*/
                debug(F110,"QNX","Cursor Right (no wrap)",0);
                if ( debses )
                    break;
                cursorright(0);
                break;
            case 'D':
                /* Cursor Left (no wrap)*/
                debug(F110,"QNX","Cursor Left (no wrap)",0);
                if ( debses )
                    break;
                cursorleft(0);
                break;
            case 'E':
                /* Insert Line */
                debug(F110,"QNX","Insert Line",0);
                if ( debses )
                    break;
                VscrnScroll(VTERM,
                             DOWNWARD,
                             wherey[VTERM] - 1,
                             marginbot - 1,
                             1,
                             FALSE,
                             SP);
                break;
            case 'F':
                /* Delete Line */
                debug(F110,"QNX","Delete Line",0);
                if ( debses )
                    break;
                VscrnScroll(VTERM,
                             UPWARD,
                             wherey[VTERM] - 1,
                             marginbot - 1,
                                 1,
                                 FALSE,
                                 SP);
                break;
            case 'G':
                break;
            case 'H':
                /* Cursor Home */
                debug(F110,"QNX","Home Cursor",0);
                if ( debses )
                    break;
                lgotoxy(VTERM,1,1);
                break;
            case 'I':
                /* Reverse Line Feed */
                debug(F110,"QNX","Reverse Line Feed",0);
                if ( debses )
                    break;
                if (margintop == wherey[VTERM])
                    VscrnScroll(VTERM,
                                 DOWNWARD,
                                 margintop - 1,
                                 marginbot - 1,
                                 1,
                                  FALSE,
                                  SP
                                  );
                else
                    cursorup(0);
                break;
            case 'J':
                /* Clear Display with SP */
                /* use Fill Color */
                debug(F110,"QNX","Clear to EOS",0);
                clreoscr_escape(VTERM,SP);
                break;
            case 'K':
                /* Erase to End of Line with SP */
                /* use Fill Color */
                debug(F110,"QNX","Clear to EOL",0);
                if ( debses )
                    break;
                clrtoeoln(VTERM,SP);
                break;
            case 'L':
                break;
            case 'M':
                break;
            case 'N':
                break;
            case 'O':
                break;
            case 'P':
                break;
            case 'Q':
                break;
            case 'R':
                /* Restore Color and Attribute Information */
                debug(F110,"QNX","Restore Colors and Attributes",0);
                if ( debses )
                    break;
                attrib = savedattrib[VTERM];
                attribute = savedattribute[VTERM];
                defaultattribute = saveddefaultattribute[VTERM];
                break;
            case 'S':
                /* Save Color and Attribute Information   */
                /* save attribute, fill color, and attrib */
                debug(F110,"QNX","Save Colors and Attributes",0);
                if ( debses )
                    break;
                savedattrib[VTERM] = attrib;
                savedattribute[VTERM] = attribute;
                saveddefaultattribute[VTERM] = defaultattribute;
                break;
            case 'T':
                break;
            case 'U':
                break;
            case 'V':
                break;
            case 'W':
                /* From Relisys terminals */
                debug(F110,"QNX","Transparent Print On",0);
                if ( debses )
                    break;
                xprint = TRUE ;
                if ( !printon )
                    printeron() ;
                break;
            case 'X':
                /* From Relisys terminals */
                debug(F110,"QNX","Print Off",0);
                if ( debses )
                    break;
                xprint = cprint = FALSE ;
                setaprint(FALSE);
                if ( !uprint && !xprint && !cprint && !aprint && printon )
                    printeroff();
                break;
            case 'Y': {
                /* Position Cursor */
                int row = qnxinc() - 31;
                int col = qnxinc() - 31;
                debug(F110,"QNX","Address cursor to row col",0);
                if ( debses )
                    break;
                lgotoxy(VTERM,col,row);
                break;
            }
            case 'Z':
                break;
            case '[':
                /* Turn on underline */
                debug(F110,"QNX","Turn on Underline",0);
                if ( debses )
                    break;
                attrib.underlined = TRUE;
                break;
            case '\\':
                break;
            case ']':
                /* Turn off underline */
                debug(F110,"QNX","Turn off Underline",0);
                if ( debses )
                    break;
                attrib.underlined = FALSE;
                break;
            case '^':
                break;
            case '_':
                break;
            case '`':
                break;
            case 'a':
                /* Cursor Up with wrap */
                debug(F110,"QNX","Cursor Up (wrap)",0);
                if ( debses )
                    break;
                cursorup(1);
                break;
            case 'b':
                /* Cursor Down with wrap */
                debug(F110,"QNX","Cursor Down (wrap)",0);
                if ( debses )
                    break;
                cursordown(1);
                break;
            case 'c':
                /* Cursor Right with wrap */
                debug(F110,"QNX","Cursor Right (wrap)",0);
                if ( debses )
                    break;
                cursorright(1);
                break;
            case 'd':
                /* Cursor Left with wrap */
                debug(F110,"QNX","Cursor Left (wrap)",0);
                if ( debses )
                    break;
                cursorleft(1);
                break;
            case 'e':
                /* Inserts a space. */
                debug(F110,"QNX","Insert SP",0);
                if ( debses )
                    break;
                blankvcell.c = SP;
                blankvcell.a = attribute;
                VscrnScrollRt(VTERM, wherey[VTERM] - 1,
                               wherex[VTERM] - 1, wherey[VTERM] - 1,
                               VscrnGetWidth(VTERM) - 1, 1, blankvcell);
                break;
            case 'f':
                /* Deletes a character */
                debug(F110,"QNX","Delete a char",0);
                if ( debses )
                    break;
                blankvcell.c = SP;
                blankvcell.a = attribute;
                VscrnScrollLf(VTERM, wherey[VTERM] - 1,
                               wherex[VTERM] - 1,
                               wherey[VTERM] - 1,
                               VscrnGetWidth(VTERM) - 1,
                               1, blankvcell) ;
                break;
            case 'g': {
                /* Repeat character */
                int n = qnxinc() - SP;
                int c = rtolxlat(qnxinc());
                debug(F110,"QNX","Repeat character",0);
                if ( debses )
                    break;
                while ( n-- )
                    wrtch(c);
                break;
            }
            case 'h':
                /* Auto wrap on */
                debug(F110,"QNX","Auto wrap on",0);
                if ( debses )
                    break;
                tt_wrap = TRUE;
                break;
            case 'i':
                /* Auto wrap off */
                debug(F110,"QNX","Auto wrap off",0);
                if ( debses )
                    break;
                tt_wrap = FALSE;
                break;
            case 'j':
                break;
            case 'k':
                break;
            case 'l':
                break;
            case 'm':
                break;
            case 'n':
                break;
            case 'o':
                break;
            case 'p':
            case 'q':
            case 'r':
            case 's':
            case 't':
            case 'u':
            case 'v':
            case 'w':
            case 'x':
                break;
            case 'y': {
                /* set cursor type */
                int c = qnxinc();
                debug(F110,"QNX","Define cursor type",0);
                if ( debses )
                    break;
                switch ( c ) {
                case '0':
                    /* no cursor */
                    cursorena[VTERM] = FALSE ;
                    break;
                case '1':
                    /* line cursor */
                    tt_cursor = TTC_ULINE ;
                    setcursormode() ;
                    cursorena[VTERM] = TRUE ;
                    break;
                case '2':
                    /* block cursor */
                    tt_cursor = TTC_BLOCK ;
                    setcursormode() ;
                    cursorena[VTERM] = TRUE ;
                    break;
                }
                break;
            }
            case 'z':
                break;
            case '{':
                /* Turn blinking on */
                debug(F110,"QNX","Turn blinking on",0);
                if ( debses )
                    break;
                attrib.blinking = TRUE;
                break;
            case '|':
                break;
            case '}':
                /* Turn blinking off */
                debug(F110,"QNX","Turn blinking off",0);
                if ( debses )
                    break;
                attrib.blinking = FALSE;
                break;
            case '~':
                break;
            case DEL:
                break;
            }
            escstate = ES_NORMAL ;      /* Done parsing escstate sequence */
        }
    }
    else                /* Handle as a normal character */
    {
        if ( ch < SP || ch == DEL )
            qnxctrl(ch) ;
        else if ( !debses ) {
            /* Display the character */
            wrtch(ch);
        }
    }
    VscrnIsDirty(VTERM) ;
}
Example #5
0
static int print_file(WINDOW *w, int item)
{
	/* int handle, error = 0, i, key, result = 0, r; DjV 033 010203 */
	int handle, error = 0, i, result = 0; /* DjV 033 010203 */
	char *buffer;
	const char *name;
	long l;			/* index in buffer[] */
	int ll = 0;		/* DjV 031 150203 line length counter */
	boolean stop = FALSE;

	if ((name = itm_fullname(w, item)) == NULL)
		return XFATAL;

	buffer = x_alloc(PBUFSIZ);

	if (buffer != NULL)
	{
		graf_mouse(HOURGLASS, NULL);

		if ((handle = x_open(name, O_DENYW | O_RDONLY)) >= 0)
		{
			do
			{
				if ((l = x_read(handle, PBUFSIZ, buffer)) >= 0)
				{
					for (i = 0; i < (int) l; i++)
					{
						/* DjV 031 150203 ---vvv--- */
						/* 
						 * line wrap & new line handling;
						 */
						ll++;
						if ( (buffer[i] == (char)13) || (buffer[i] == (char)10) || (buffer[i] == (char)12) )
							ll = 0; /* reset linelength counter at CR, LF or FF */
						else if ( ll >= plinelen )
						{
							ll = 0;
							if (( stop = print_eol() ) == TRUE)
								break;
						}
						/* DjV 031 150203 ---^^^--- */

						if ((stop = prtchar(buffer[i])) == TRUE)
							break;
					}
					/* DjV 033 010203 ---vvv--- */
					/*
					if ((r = key_state(&key, TRUE)) > 0)
					{
						if (key == ESCAPE)
							stop = TRUE;
					}
					else if (r < 0)
						stop = TRUE;
					*/

					if ( escape_abort(TRUE) )
						stop = TRUE;

					/* DjV 033 010203 ---^^^--- */
				}
				else
					error = (int) l;
			}
			while ((l == PBUFSIZ) && (stop == FALSE));

			x_close(handle);
			print_eol(); /* DjV 031 150203 print cr lf at end of file */
		}
		else
			error = handle;

		if (stop == TRUE)
			result = XABORT;

		if (error != 0)
			result = xhndl_error(MEPRINT, error, itm_name(w, item));

		graf_mouse(ARROW, NULL);
		x_free(buffer);
	}
	else
	{
		xform_error(ENSMEM);
		result = XFATAL;
	}

	free(name);

	return result;
}