DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦51e522332⟧ TextFile

    Length: 2357 (0x935)
    Types: TextFile
    Notes: UNIX file
    Names: »ansi.c«, »ansi_h19.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦0a3c255ba⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »emacs_dos/ansi.c« 
        └─ ⟦this⟧ »emacs_dos/ansi_h19.c« 

TextFile

/*
 * The routines in this file
 * provide support for ANSI style terminals
 * over a serial line. The serial I/O services are
 * provided by routines in "termio.c". It compiles
 * into nothing if not an ANSI device.
 */

 /* Modified for Heathkit H-19 terminal.
  * by Frank Hughes     7 April 1987
  */

#include	<stdio.h>
#include	"ed.h"

#if	ANSI

#define	NROW	24			/* Screen size.			*/
#define	NCOL	80			/* Edit if you want to.		*/
#define	BEL	0x07			/* BEL character.		*/
#define	ESC	0x1B			/* ESC character.		*/

extern	int	ttopen();		/* Forward references.		*/
extern	int	ttgetc();
extern	int	ttputc();
extern	int	ttflush();
extern	int	ttclose();
extern	int	ansimove();
extern	int	ansieeol();
extern	int	ansieeop();
extern	int	ansibeep();
extern	int	ansiopen();
static	int	tty_type = 0;		/* Terminal type		*/
/*
 * Terminal type	Added 7 April 1987	FAH
 *
 * 0 - none.
 * 1 - VT-100
 * 2 - H-19
 */

/*
 * Standard terminal interface
 * dispatch table. Most of the fields
 * point into "termio" code.
 */
TERM	term	= {
	NROW-1,
	NCOL,
	&ansiopen,
	&ttclose,
	&ttgetc,
	&ttputc,
	&ttflush,
	&ansimove,
	&ansieeol,
	&ansieeop,
	&ansibeep
};

ansimove(row, col)
{
	switch(tty_type) {
	
	case 1:

/*                              vt100 entry	*/
		ttputc(ESC);
		ttputc('[');
		ansiparm(row+1);
		ttputc(';');
		ansiparm(col+1);
		ttputc('H');
		break;
	case 2:
		ttputc(ESC);            /*      h-19 entry      */
		ttputc('Y');
		ttputc(row + 32);
		ttputc(col + 32);
		break;
	}
}

ansieeol()
{

	switch(tty_type) {

	case 1:
		ttputc(ESC);
		ttputc('[');
		ttputc('K');
		break;

	case 2:

		ttputc(ESC);            /*      H-19 entry      */
		ttputc('K');
		break;
	}
}

ansieeop()
{

	switch(tty_type) {

	case 1:

		ttputc(ESC);
		ttputc('[');
		ttputc('J');
		break;

	case 2:
		ttputc(ESC);            /*      H-19 entry      */
		ttputc('J');
		break;
	}
}

ansibeep()
{
	ttputc(BEL);
	ttflush();
}

ansiparm(n)
register int	n;
{
	register int	q;

	q = n/10;
	if (q != 0)
		ansiparm(q);
	ttputc((n%10) + '0');
}

#endif

ansiopen()
{
#if	V7
	register char *cp;
	char *getenv();

	if ((cp = getenv("TERM")) == NULL) {
		puts("Shell variable TERM not defined!");
		exit(1);
	}
	if (strcmp(cp, "kb") == 0) 
		tty_type = 2;
	if (strcmp(cp, "d0") == 0 || strcmp(cp, "vt100") == 0) 
		tty_type = 1;

	if (tty_type == 0)
		exit(1);
#endif
	ttopen();
}