mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-29 20:46:22 -05:00
Compare commits
3 Commits
1cdc889f6f
...
893e34b740
Author | SHA1 | Date | |
---|---|---|---|
893e34b740 | |||
5c65613f03 | |||
1fbb2fc565 |
241
fridge/ansi.c
241
fridge/ansi.c
@ -1,241 +0,0 @@
|
||||
/* ANSI.C
|
||||
*
|
||||
* 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 by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#define termdef 1 /* don't define "term" external */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "estruct.h"
|
||||
|
||||
|
||||
#if ANSI
|
||||
|
||||
#define NROW 25 /* Screen size. */
|
||||
#define NCOL 80 /* Edit if you want to. */
|
||||
|
||||
#if PKCODE
|
||||
#define MROW 64
|
||||
#endif
|
||||
#define NPAUSE 100 /* # times thru update to pause */
|
||||
#define MARGIN 8 /* size of minimim margin and */
|
||||
#define SCRSIZ 64 /* scroll size for extended lines */
|
||||
#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();
|
||||
extern int ansirev();
|
||||
extern int ansiclose();
|
||||
extern int ansikopen();
|
||||
extern int ansikclose();
|
||||
extern int ansicres();
|
||||
|
||||
#if COLOR
|
||||
extern int ansifcol();
|
||||
extern int ansibcol();
|
||||
|
||||
int cfcolor = -1; /* current forground color */
|
||||
int cbcolor = -1; /* current background color */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard terminal interface dispatch table. Most of the fields point into
|
||||
* "termio" code.
|
||||
*/
|
||||
struct terminal term = {
|
||||
#if PKCODE
|
||||
MROW - 1,
|
||||
#else
|
||||
NROW - 1,
|
||||
#endif
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
SCRSIZ,
|
||||
NPAUSE,
|
||||
ansiopen,
|
||||
ansiclose,
|
||||
ansikopen,
|
||||
ansikclose,
|
||||
ttgetc,
|
||||
ttputc,
|
||||
ttflush,
|
||||
ansimove,
|
||||
ansieeol,
|
||||
ansieeop,
|
||||
ansibeep,
|
||||
ansirev,
|
||||
ansicres
|
||||
#if COLOR
|
||||
, ansifcol,
|
||||
ansibcol
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
#if COLOR
|
||||
ansifcol(color)
|
||||
/* set the current output color */
|
||||
int color; /* color to set */
|
||||
|
||||
{
|
||||
if (color == cfcolor)
|
||||
return;
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(color + 30);
|
||||
ttputc('m');
|
||||
cfcolor = color;
|
||||
}
|
||||
|
||||
/* Set the current background color.
|
||||
* color: color to set.
|
||||
*/
|
||||
void ansibcol(int color)
|
||||
{
|
||||
if (color == cbcolor)
|
||||
return;
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(color + 40);
|
||||
ttputc('m');
|
||||
cbcolor = color;
|
||||
}
|
||||
#endif
|
||||
|
||||
ansimove(row, col)
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(row + 1);
|
||||
ttputc(';');
|
||||
ansiparm(col + 1);
|
||||
ttputc('H');
|
||||
}
|
||||
|
||||
void ansieeol(void)
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ttputc('K');
|
||||
}
|
||||
|
||||
void ansieeop(void)
|
||||
{
|
||||
#if COLOR
|
||||
ansifcol(gfcolor);
|
||||
ansibcol(gbcolor);
|
||||
#endif
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ttputc('J');
|
||||
}
|
||||
|
||||
/* Change reverse video state.
|
||||
* state: TRUE = reverse, FALSE = normal
|
||||
*/
|
||||
void ansirev(int state)
|
||||
{
|
||||
#if COLOR
|
||||
int ftmp, btmp; /* temporaries for colors */
|
||||
#endif
|
||||
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ttputc(state ? '7' : '0');
|
||||
ttputc('m');
|
||||
#if COLOR
|
||||
if (state == FALSE) {
|
||||
ftmp = cfcolor;
|
||||
btmp = cbcolor;
|
||||
cfcolor = -1;
|
||||
cbcolor = -1;
|
||||
ansifcol(ftmp);
|
||||
ansibcol(btmp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Change screen resolution. */
|
||||
int ansicres()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ansibeep(void)
|
||||
{
|
||||
ttputc(BEL);
|
||||
ttflush();
|
||||
}
|
||||
|
||||
void ansiparm(int n)
|
||||
{
|
||||
int q, r;
|
||||
|
||||
q = n / 10;
|
||||
if (q != 0) {
|
||||
r = q / 10;
|
||||
if (r != 0) {
|
||||
ttputc((r % 10) + '0');
|
||||
}
|
||||
ttputc((q % 10) + '0');
|
||||
}
|
||||
ttputc((n % 10) + '0');
|
||||
}
|
||||
|
||||
void ansiopen(void)
|
||||
{
|
||||
#if V7 | USG | BSD
|
||||
char *cp;
|
||||
|
||||
if ((cp = getenv("TERM")) == NULL) {
|
||||
puts("Shell variable TERM not defined!");
|
||||
exit(1);
|
||||
}
|
||||
if (strcmp(cp, "vt100") != 0) {
|
||||
puts("Terminal type not 'vt100'!");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
strcpy(sres, "NORMAL");
|
||||
revexist = TRUE;
|
||||
ttopen();
|
||||
}
|
||||
|
||||
void ansiclose(void)
|
||||
{
|
||||
#if COLOR
|
||||
ansifcol(7);
|
||||
ansibcol(0);
|
||||
#endif
|
||||
ttclose();
|
||||
}
|
||||
|
||||
/* Open the keyboard (a noop here). */
|
||||
void ansikopen(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Close the keyboard (a noop here). */
|
||||
void ansikclose(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
494
fridge/ibmpc.c
494
fridge/ibmpc.c
@ -1,494 +0,0 @@
|
||||
/* ibmpc.c
|
||||
*
|
||||
* The routines in this file provide support for the IBM-PC and other
|
||||
* compatible terminals. It goes directly to the graphics RAM to do
|
||||
* screen output. It compiles into nothing if not an IBM-PC driver
|
||||
* Supported monitor cards include CGA, MONO and EGA.
|
||||
*
|
||||
* modified by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#define termdef 1 /* don't define "term" external */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "estruct.h"
|
||||
|
||||
#if IBMPC
|
||||
#if PKCODE
|
||||
#define NROW 50
|
||||
#else
|
||||
#define NROW 43 /* Max Screen size. */
|
||||
#endif
|
||||
#define NCOL 80 /* Edit if you want to. */
|
||||
#define MARGIN 8 /* size of minimim margin and */
|
||||
#define SCRSIZ 64 /* scroll size for extended lines */
|
||||
#define NPAUSE 200 /* # times thru update to pause */
|
||||
#define BEL 0x07 /* BEL character. */
|
||||
#define ESC 0x1B /* ESC character. */
|
||||
#define SPACE 32 /* space character */
|
||||
|
||||
#define SCADC 0xb8000000L /* CGA address of screen RAM */
|
||||
#define SCADM 0xb0000000L /* MONO address of screen RAM */
|
||||
#define SCADE 0xb8000000L /* EGA address of screen RAM */
|
||||
|
||||
#define MONOCRSR 0x0B0D /* monochrome cursor */
|
||||
#define CGACRSR 0x0607 /* CGA cursor */
|
||||
#define EGACRSR 0x0709 /* EGA cursor */
|
||||
|
||||
#define CDCGA 0 /* color graphics card */
|
||||
#define CDMONO 1 /* monochrome text card */
|
||||
#define CDEGA 2 /* EGA color adapter */
|
||||
#if PKCODE
|
||||
#define CDVGA 3
|
||||
#endif
|
||||
#define CDSENSE 9 /* detect the card type */
|
||||
|
||||
#if PKCODE
|
||||
#define NDRIVE 4
|
||||
#else
|
||||
#define NDRIVE 3 /* number of screen drivers */
|
||||
#endif
|
||||
|
||||
int dtype = -1; /* current display type */
|
||||
char drvname[][8] = { /* screen resolution names */
|
||||
"CGA", "MONO", "EGA"
|
||||
#if PKCODE
|
||||
, "VGA"
|
||||
#endif
|
||||
};
|
||||
long scadd; /* address of screen ram */
|
||||
int *scptr[NROW]; /* pointer to screen lines */
|
||||
unsigned int sline[NCOL]; /* screen line image */
|
||||
int egaexist = FALSE; /* is an EGA card available? */
|
||||
extern union REGS rg; /* cpu register for use of DOS calls */
|
||||
|
||||
extern int ttopen(); /* Forward references. */
|
||||
extern int ttgetc();
|
||||
extern int ttputc();
|
||||
extern int ttflush();
|
||||
extern int ttclose();
|
||||
extern int ibmmove();
|
||||
extern int ibmeeol();
|
||||
extern int ibmeeop();
|
||||
extern int ibmbeep();
|
||||
extern int ibmopen();
|
||||
extern int ibmrev();
|
||||
extern int ibmcres();
|
||||
extern int ibmclose();
|
||||
extern int ibmputc();
|
||||
extern int ibmkopen();
|
||||
extern int ibmkclose();
|
||||
|
||||
#if COLOR
|
||||
extern int ibmfcol();
|
||||
extern int ibmbcol();
|
||||
extern int ibmscroll_reg();
|
||||
|
||||
int cfcolor = -1; /* current forground color */
|
||||
int cbcolor = -1; /* current background color */
|
||||
int ctrans[] = /* ansi to ibm color translation table */
|
||||
#if PKCODE
|
||||
{ 0, 4, 2, 6, 1, 5, 3, 7, 15 };
|
||||
#else
|
||||
{ 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard terminal interface dispatch table. Most of the fields point into
|
||||
* "termio" code.
|
||||
*/
|
||||
struct terminal term = {
|
||||
NROW - 1,
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
SCRSIZ,
|
||||
NPAUSE,
|
||||
ibmopen,
|
||||
ibmclose,
|
||||
ibmkopen,
|
||||
ibmkclose,
|
||||
ttgetc,
|
||||
ibmputc,
|
||||
ttflush,
|
||||
ibmmove,
|
||||
ibmeeol,
|
||||
ibmeeop,
|
||||
ibmbeep,
|
||||
ibmrev,
|
||||
ibmcres
|
||||
#if COLOR
|
||||
, ibmfcol,
|
||||
ibmbcol
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
, ibmscroll_reg
|
||||
#endif
|
||||
};
|
||||
|
||||
#if COLOR
|
||||
/* Set the current output color.
|
||||
*
|
||||
* @color: color to set.
|
||||
*/
|
||||
void ibmfcol(int color)
|
||||
{
|
||||
cfcolor = ctrans[color];
|
||||
}
|
||||
|
||||
/* Set the current background color.
|
||||
*
|
||||
* @color: color to set.
|
||||
*/
|
||||
void ibmbcol(int color)
|
||||
{
|
||||
cbcolor = ctrans[color];
|
||||
}
|
||||
#endif
|
||||
|
||||
void ibmmove(int row, int col)
|
||||
{
|
||||
rg.h.ah = 2; /* set cursor position function code */
|
||||
rg.h.dl = col;
|
||||
rg.h.dh = row;
|
||||
rg.h.bh = 0; /* set screen page number */
|
||||
int86(0x10, &rg, &rg);
|
||||
}
|
||||
|
||||
void ibmeeol(void)
|
||||
{ /* erase to the end of the line */
|
||||
unsigned int attr; /* attribute byte mask to place in RAM */
|
||||
unsigned int *lnptr; /* pointer to the destination line */
|
||||
int i;
|
||||
int ccol; /* current column cursor lives */
|
||||
int crow; /* row */
|
||||
|
||||
/* find the current cursor position */
|
||||
rg.h.ah = 3; /* read cursor position function code */
|
||||
rg.h.bh = 0; /* current video page */
|
||||
int86(0x10, &rg, &rg);
|
||||
ccol = rg.h.dl; /* record current column */
|
||||
crow = rg.h.dh; /* and row */
|
||||
|
||||
/* build the attribute byte and setup the screen pointer */
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8;
|
||||
else
|
||||
attr = 0x0700;
|
||||
#else
|
||||
attr = 0x0700;
|
||||
#endif
|
||||
lnptr = &sline[0];
|
||||
for (i = 0; i < term.t_ncol; i++)
|
||||
*lnptr++ = SPACE | attr;
|
||||
|
||||
if (flickcode && (dtype == CDCGA)) {
|
||||
/* wait for vertical retrace to be off */
|
||||
while ((inp(0x3da) & 8));
|
||||
|
||||
/* and to be back on */
|
||||
while ((inp(0x3da) & 8) == 0);
|
||||
}
|
||||
|
||||
/* and send the string out */
|
||||
movmem(&sline[0], scptr[crow] + ccol, (term.t_ncol - ccol) * 2);
|
||||
|
||||
}
|
||||
|
||||
/* Put a character at the current position in the current colors */
|
||||
void ibmputc(int ch)
|
||||
{
|
||||
rg.h.ah = 14; /* write char to screen with current attrs */
|
||||
rg.h.al = ch;
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
rg.h.bl = cfcolor;
|
||||
else
|
||||
rg.h.bl = 0x07;
|
||||
#else
|
||||
rg.h.bl = 0x07;
|
||||
#endif
|
||||
int86(0x10, &rg, &rg);
|
||||
}
|
||||
|
||||
void ibmeeop(void)
|
||||
{
|
||||
int attr; /* attribute to fill screen with */
|
||||
|
||||
rg.h.ah = 6; /* scroll page up function code */
|
||||
rg.h.al = 0; /* # lines to scroll (clear it) */
|
||||
rg.x.cx = 0; /* upper left corner of scroll */
|
||||
rg.x.dx = (term.t_nrow << 8) | (term.t_ncol - 1);
|
||||
/* lower right corner of scroll */
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
attr =
|
||||
((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
|
||||
else
|
||||
attr = 0;
|
||||
#else
|
||||
attr = 0;
|
||||
#endif
|
||||
rg.h.bh = attr;
|
||||
int86(0x10, &rg, &rg);
|
||||
}
|
||||
|
||||
/* Change reverse video state.
|
||||
*
|
||||
* @state: TRUE = reverse, FALSE = normal.
|
||||
*/
|
||||
void ibmrev(int state)
|
||||
{
|
||||
/* This never gets used under the IBM-PC driver */
|
||||
}
|
||||
|
||||
/* Change screen resolution.
|
||||
*
|
||||
* @res: resolution to change to.
|
||||
*/
|
||||
void ibmcres(char *res)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NDRIVE; i++) {
|
||||
if (strcmp(res, drvname[i]) == 0) {
|
||||
scinit(i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
/* Move howmany lines starting at from to to. */
|
||||
void ibmscroll_reg(from, to, howmany)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (to < from) {
|
||||
for (i = 0; i < howmany; i++) {
|
||||
movmem(scptr[from + i], scptr[to + i],
|
||||
term.t_ncol * 2);
|
||||
}
|
||||
}
|
||||
else if (to > from) {
|
||||
for (i = howmany - 1; i >= 0; i--) {
|
||||
movmem(scptr[from + i], scptr[to + i],
|
||||
term.t_ncol * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ibmbeep(void)
|
||||
{
|
||||
bdos(6, BEL, 0);
|
||||
}
|
||||
|
||||
void ibmopen(void)
|
||||
{
|
||||
scinit(CDSENSE);
|
||||
revexist = TRUE;
|
||||
ttopen();
|
||||
}
|
||||
|
||||
void ibmclose(void)
|
||||
{
|
||||
#if COLOR
|
||||
ibmfcol(7);
|
||||
ibmbcol(0);
|
||||
#endif
|
||||
/* if we had the EGA open... close it */
|
||||
if (dtype == CDEGA)
|
||||
egaclose();
|
||||
#if PKCODE
|
||||
if (dtype == CDVGA)
|
||||
egaclose();
|
||||
#endif
|
||||
|
||||
ttclose();
|
||||
}
|
||||
|
||||
/* Open the keyboard. */
|
||||
void ibmkopen(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Close the keyboard. */
|
||||
void ibmkclose(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Initialize the screen head pointers.
|
||||
*
|
||||
* @type: type of adapter to init for.
|
||||
*/
|
||||
static int scinit(int type)
|
||||
{
|
||||
union {
|
||||
long laddr; /* long form of address */
|
||||
int *paddr; /* pointer form of address */
|
||||
} addr;
|
||||
int i;
|
||||
|
||||
/* if asked...find out what display is connected */
|
||||
if (type == CDSENSE)
|
||||
type = getboard();
|
||||
|
||||
/* if we have nothing to do....don't do it */
|
||||
if (dtype == type)
|
||||
return TRUE;
|
||||
|
||||
/* if we try to switch to EGA and there is none, don't */
|
||||
if (type == CDEGA && egaexist != TRUE)
|
||||
return FALSE;
|
||||
|
||||
/* if we had the EGA open... close it */
|
||||
if (dtype == CDEGA)
|
||||
egaclose();
|
||||
#if PKCODE
|
||||
if (dtype == CDVGA)
|
||||
egaclose();
|
||||
#endif
|
||||
|
||||
/* and set up the various parameters as needed */
|
||||
switch (type) {
|
||||
case CDMONO: /* Monochrome adapter */
|
||||
scadd = SCADM;
|
||||
newsize(TRUE, 25);
|
||||
break;
|
||||
|
||||
case CDCGA: /* Color graphics adapter */
|
||||
scadd = SCADC;
|
||||
newsize(TRUE, 25);
|
||||
break;
|
||||
|
||||
case CDEGA: /* Enhanced graphics adapter */
|
||||
scadd = SCADE;
|
||||
egaopen();
|
||||
newsize(TRUE, 43);
|
||||
break;
|
||||
case CDVGA: /* Enhanced graphics adapter */
|
||||
scadd = SCADE;
|
||||
egaopen();
|
||||
newsize(TRUE, 50);
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the $sres environment variable */
|
||||
strcpy(sres, drvname[type]);
|
||||
dtype = type;
|
||||
|
||||
/* initialize the screen pointer array */
|
||||
for (i = 0; i < NROW; i++) {
|
||||
addr.laddr = scadd + (long) (NCOL * i * 2);
|
||||
scptr[i] = addr.paddr;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* getboard: Determine which type of display board is attached.
|
||||
Current known types include:
|
||||
|
||||
CDMONO Monochrome graphics adapter
|
||||
CDCGA Color Graphics Adapter
|
||||
CDEGA Extended graphics Adapter
|
||||
*/
|
||||
|
||||
/* getboard: Detect the current display adapter
|
||||
if MONO set to MONO
|
||||
CGA set to CGA EGAexist = FALSE
|
||||
EGA set to CGA EGAexist = TRUE
|
||||
*/
|
||||
int getboard(void)
|
||||
{
|
||||
int type; /* board type to return */
|
||||
|
||||
type = CDCGA;
|
||||
int86(0x11, &rg, &rg);
|
||||
if ((((rg.x.ax >> 4) & 3) == 3))
|
||||
type = CDMONO;
|
||||
|
||||
/* test if EGA present */
|
||||
rg.x.ax = 0x1200;
|
||||
rg.x.bx = 0xff10;
|
||||
int86(0x10, &rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */
|
||||
egaexist = !(rg.x.bx & 0xfefc); /* Yes, it's EGA */
|
||||
return type;
|
||||
}
|
||||
|
||||
/* init the computer to work with the EGA */
|
||||
void egaopen(void)
|
||||
{
|
||||
/* put the beast into EGA 43 row mode */
|
||||
rg.x.ax = 3;
|
||||
int86(16, &rg, &rg);
|
||||
|
||||
rg.h.ah = 17; /* set char. generator function code */
|
||||
rg.h.al = 18; /* to 8 by 8 double dot ROM */
|
||||
rg.h.bl = 0; /* block 0 */
|
||||
int86(16, &rg, &rg);
|
||||
|
||||
rg.h.ah = 18; /* alternate select function code */
|
||||
rg.h.al = 0; /* clear AL for no good reason */
|
||||
rg.h.bl = 32; /* alt. print screen routine */
|
||||
int86(16, &rg, &rg);
|
||||
|
||||
rg.h.ah = 1; /* set cursor size function code */
|
||||
rg.x.cx = 0x0607; /* turn cursor on code */
|
||||
int86(0x10, &rg, &rg);
|
||||
|
||||
outp(0x3d4, 10); /* video bios bug patch */
|
||||
outp(0x3d5, 6);
|
||||
}
|
||||
|
||||
void egaclose(void)
|
||||
{
|
||||
/* put the beast into 80 column mode */
|
||||
rg.x.ax = 3;
|
||||
int86(16, &rg, &rg);
|
||||
}
|
||||
|
||||
/* Write a line out.
|
||||
*
|
||||
* @row: row of screen to place outstr on.
|
||||
* @outstr: string to write out (must be term.t_ncol long).
|
||||
* @forg: forground color of string to write.
|
||||
* @bacg: background color.
|
||||
*/
|
||||
void scwrite(int row, char *outstr, int forg, int bacg)
|
||||
{
|
||||
unsigned int attr; /* attribute byte mask to place in RAM */
|
||||
unsigned int *lnptr; /* pointer to the destination line */
|
||||
int i;
|
||||
|
||||
/* build the attribute byte and setup the screen pointer */
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
|
||||
else
|
||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||
#else
|
||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||
#endif
|
||||
lnptr = &sline[0];
|
||||
for (i = 0; i < term.t_ncol; i++)
|
||||
*lnptr++ = (outstr[i] & 255) | attr;
|
||||
|
||||
if (flickcode && (dtype == CDCGA)) {
|
||||
/* wait for vertical retrace to be off */
|
||||
while ((inp(0x3da) & 8));
|
||||
|
||||
/* and to be back on */
|
||||
while ((inp(0x3da) & 8) == 0);
|
||||
}
|
||||
|
||||
/* and send the string out */
|
||||
movmem(&sline[0], scptr[row], term.t_ncol * 2);
|
||||
}
|
||||
|
||||
#endif
|
197
fridge/mingw32.c
197
fridge/mingw32.c
@ -1,197 +0,0 @@
|
||||
/* mingw32.c -- */
|
||||
|
||||
#ifdef MINGW32
|
||||
#include "termio.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "utf8.h"
|
||||
#include "wscreen.h"
|
||||
|
||||
static void vv( void) {}
|
||||
static void vi( int i) {}
|
||||
static int is( char *s) { return *s ; }
|
||||
|
||||
static void ttmove( int l, int c) ;
|
||||
|
||||
#define MARGIN 8
|
||||
#define SCRSIZ 64
|
||||
#define NPAUSE 10 /* # times thru update to pause. */
|
||||
|
||||
struct terminal term = {
|
||||
24, /* These four values are set dynamically at open time. */
|
||||
24,
|
||||
80,
|
||||
80,
|
||||
MARGIN,
|
||||
SCRSIZ,
|
||||
NPAUSE,
|
||||
ttopen,
|
||||
#if PKCODE
|
||||
ttclose,
|
||||
#else
|
||||
ttclose,
|
||||
#endif
|
||||
vv, /* ttkopen, */
|
||||
vv, /* ttkclose, */
|
||||
ttgetc,
|
||||
ttputc,
|
||||
ttflush,
|
||||
ttmove,
|
||||
vv, /* tteeol, */
|
||||
vv, /* tteeop, */
|
||||
vv, /* ttbeep, */
|
||||
vi, /* ttrev, */
|
||||
is /* ttcres */
|
||||
#if COLOR
|
||||
, iv, /* ttfcol, */
|
||||
iv /* ttbcol */
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
, NULL /* set dynamically at open time */
|
||||
#endif
|
||||
} ;
|
||||
|
||||
|
||||
int ttrow ; /* Row location of HW cursor */
|
||||
int ttcol ; /* Column location of HW cursor */
|
||||
|
||||
boolean eolexist = TRUE ; /* does clear to EOL exist? */
|
||||
boolean revexist = FALSE ; /* does reverse video exist? */
|
||||
boolean sgarbf = TRUE ; /* State of screen unknown */
|
||||
|
||||
char sres[ 16] ; /* Current screen resolution. */
|
||||
/* NORMAL, CGA, EGA, VGA */
|
||||
|
||||
void ttopen( void) {
|
||||
winit() ;
|
||||
wcls() ;
|
||||
term.t_mrow = term.t_nrow = wbottom() - wtop() ;
|
||||
term.t_mcol = term.t_ncol = wright() - wleft() + 1 ;
|
||||
wtitle( "uEMACS") ;
|
||||
}
|
||||
|
||||
void ttclose( void) {
|
||||
}
|
||||
|
||||
int ttputc( unicode_t c) {
|
||||
char utf8[ 6] ;
|
||||
int bytes ;
|
||||
|
||||
bytes = unicode_to_utf8( c, utf8) ;
|
||||
fwrite( utf8, 1, bytes, stdout);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void ttflush( void) {
|
||||
int status ;
|
||||
|
||||
status = fflush( stdout);
|
||||
while( status < 0 && errno == EAGAIN) {
|
||||
_sleep( 1) ;
|
||||
status = fflush( stdout) ;
|
||||
}
|
||||
|
||||
if( status < 0)
|
||||
exit( 15) ;
|
||||
}
|
||||
|
||||
int ttgetc( void) {
|
||||
static char buffer[ 32] ;
|
||||
static int pending ;
|
||||
unicode_t c ;
|
||||
int count, bytes = 1, expected ;
|
||||
|
||||
count = pending ;
|
||||
if( !count) {
|
||||
count = read( 0, buffer, sizeof( buffer)) ;
|
||||
if( count <= 0)
|
||||
return 0 ;
|
||||
|
||||
pending = count ;
|
||||
}
|
||||
|
||||
c = (unsigned char) buffer[ 0] ;
|
||||
if( c >= 32 && c < 128)
|
||||
goto done ;
|
||||
|
||||
/*
|
||||
* Lazy. We don't bother calculating the exact
|
||||
* expected length. We want at least two characters
|
||||
* for the special character case (ESC+[) and for
|
||||
* the normal short UTF8 sequence that starts with
|
||||
* the 110xxxxx pattern.
|
||||
*
|
||||
* But if we have any of the other patterns, just
|
||||
* try to get more characters. At worst, that will
|
||||
* just result in a barely perceptible 0.1 second
|
||||
* delay for some *very* unusual utf8 character
|
||||
* input.
|
||||
*/
|
||||
expected = 2 ;
|
||||
if( (c & 0xe0) == 0xe0)
|
||||
expected = 6 ;
|
||||
|
||||
/* Special character - try to fill buffer */
|
||||
if( count < expected) {
|
||||
int n;
|
||||
#if 0
|
||||
ntermios.c_cc[VMIN] = 0;
|
||||
ntermios.c_cc[VTIME] = 1; /* A .1 second lag */
|
||||
tcsetattr(0, TCSANOW, &ntermios);
|
||||
#endif
|
||||
n = read(0, buffer + count, sizeof(buffer) - count);
|
||||
|
||||
/* Undo timeout */
|
||||
#if 0
|
||||
ntermios.c_cc[VMIN] = 1;
|
||||
ntermios.c_cc[VTIME] = 0;
|
||||
tcsetattr(0, TCSANOW, &ntermios);
|
||||
#endif
|
||||
if (n > 0)
|
||||
pending += n;
|
||||
}
|
||||
|
||||
if( pending > 1) {
|
||||
unsigned char second = buffer[1];
|
||||
|
||||
/* Turn ESC+'[' into CSI */
|
||||
if (c == 27 && second == '[') {
|
||||
bytes = 2;
|
||||
c = 128+27;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
bytes = utf8_to_unicode( buffer, 0, pending, &c) ;
|
||||
|
||||
done:
|
||||
pending -= bytes ;
|
||||
memmove( buffer, buffer+bytes, pending) ;
|
||||
return c ;
|
||||
}
|
||||
|
||||
int typahead( void) {
|
||||
int x ; /* holds # of pending chars */
|
||||
|
||||
#ifdef FIONREAD
|
||||
if( ioctl( 0, FIONREAD, &x) < 0)
|
||||
#endif
|
||||
x = 0 ;
|
||||
return x ;
|
||||
}
|
||||
|
||||
static void ttmove( int l, int c) {
|
||||
wgoxy( c, l) ;
|
||||
}
|
||||
|
||||
#else
|
||||
typedef void _pedantic_empty_translation_unit ;
|
||||
#endif
|
||||
|
||||
/* end of mingw32.c */
|
488
fridge/vmsvt.c
488
fridge/vmsvt.c
@ -1,488 +0,0 @@
|
||||
/* VMSVT.C
|
||||
*
|
||||
* Advanced VMS terminal driver
|
||||
*
|
||||
* Knows about any terminal defined in SMGTERMS.TXT and TERMTABLE.TXT
|
||||
* located in SYS$SYSTEM.
|
||||
*
|
||||
* Author: Curtis Smith
|
||||
* modified by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* Standard I/O package */
|
||||
#include "estruct.h" /* Emacs' structures */
|
||||
|
||||
#if VMSVT
|
||||
|
||||
#include <descrip.h> /* Descriptor definitions */
|
||||
|
||||
/* These would normally come from iodef.h and ttdef.h */
|
||||
#define IO$_SENSEMODE 0x27 /* Sense mode of terminal */
|
||||
#define TT$_UNKNOWN 0x00 /* Unknown terminal */
|
||||
#define TT$_VT100 96
|
||||
|
||||
/** Forward references **/
|
||||
int vmsopen(), ttclose(), vmskopen(), vmskclose(), ttgetc(), ttputc();
|
||||
int ttflush(), vmsmove(), vmseeol(), vmseeop(), vmsbeep(), vmsrev();
|
||||
int vmscres();
|
||||
extern int eolexist, revexist;
|
||||
extern char sres[];
|
||||
|
||||
#if COLOR
|
||||
int vmsfcol(), vmsbcol();
|
||||
#endif
|
||||
|
||||
/** SMG stuff **/
|
||||
static char *begin_reverse, *end_reverse, *erase_to_end_line;
|
||||
static char *erase_whole_display;
|
||||
static int termtype;
|
||||
|
||||
#define SMG$K_BEGIN_REVERSE 0x1bf
|
||||
#define SMG$K_END_REVERSE 0x1d6
|
||||
#define SMG$K_SET_CURSOR_ABS 0x23a
|
||||
#define SMG$K_ERASE_WHOLE_DISPLAY 0x1da
|
||||
#define SMG$K_ERASE_TO_END_LINE 0x1d9
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
#define SMG$K_SCROLL_FORWARD 561 /* from sys$library:smgtrmptr.h */
|
||||
#define SMG$K_SCROLL_REVERSE 562
|
||||
#define SMG$K_SET_SCROLL_REGION 572
|
||||
|
||||
static char *scroll_forward, *scroll_reverse;
|
||||
|
||||
#endif
|
||||
|
||||
/* Dispatch table. All hard fields just point into the terminal I/O code. */
|
||||
struct terminal term = {
|
||||
#if PKCODE
|
||||
MAXROW,
|
||||
#else
|
||||
24 - 1, /* Max number of rows allowable */
|
||||
#endif
|
||||
/* Filled in */ -1,
|
||||
/* Current number of rows used */
|
||||
MAXCOL, /* Max number of columns */
|
||||
/* Filled in */ 0,
|
||||
/* Current number of columns */
|
||||
64, /* Min margin for extended lines */
|
||||
8, /* Size of scroll region */
|
||||
100, /* # times thru update to pause */
|
||||
vmsopen, /* Open terminal at the start */
|
||||
ttclose, /* Close terminal at end */
|
||||
vmskopen, /* Open keyboard */
|
||||
vmskclose, /* Close keyboard */
|
||||
ttgetc, /* Get character from keyboard */
|
||||
ttputc, /* Put character to display */
|
||||
ttflush, /* Flush output buffers */
|
||||
vmsmove, /* Move cursor, origin 0 */
|
||||
vmseeol, /* Erase to end of line */
|
||||
vmseeop, /* Erase to end of page */
|
||||
vmsbeep, /* Beep */
|
||||
vmsrev, /* Set reverse video state */
|
||||
vmscres /* Change screen resolution */
|
||||
#if COLOR
|
||||
, vmsfcol, /* Set forground color */
|
||||
vmsbcol /* Set background color */
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/***
|
||||
* ttputs - Send a string to ttputc
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
ttputs(string)
|
||||
char *string; /* String to write */
|
||||
{
|
||||
if (string)
|
||||
while (*string != '\0')
|
||||
ttputc(*string++);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmsmove - Move the cursor (0 origin)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsmove(row, col)
|
||||
int row; /* Row position */
|
||||
int col; /* Column position */
|
||||
{
|
||||
char buffer[32];
|
||||
int ret_length;
|
||||
static int request_code = SMG$K_SET_CURSOR_ABS;
|
||||
static int max_buffer_length = sizeof(buffer);
|
||||
static int arg_list[3] = { 2 };
|
||||
char *cp;
|
||||
|
||||
int i;
|
||||
|
||||
/* Set the arguments into the arg_list array
|
||||
* SMG assumes the row/column positions are 1 based (boo!)
|
||||
*/
|
||||
arg_list[1] = row + 1;
|
||||
arg_list[2] = col + 1;
|
||||
|
||||
if ((smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list)
|
||||
|
||||
/* Argument list array */
|
||||
/* We'll know soon enough if this doesn't work */
|
||||
&1) == 0) {
|
||||
ttputs("OOPS");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send out resulting sequence */
|
||||
i = ret_length;
|
||||
cp = buffer;
|
||||
while (i-- > 0)
|
||||
ttputc(*cp++);
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
vmsscroll_reg(from, to, howmany)
|
||||
{
|
||||
int i;
|
||||
if (to == from)
|
||||
return;
|
||||
if (to < from) {
|
||||
vmsscrollregion(to, from + howmany - 1);
|
||||
vmsmove(from + howmany - 1, 0);
|
||||
for (i = from - to; i > 0; i--)
|
||||
ttputs(scroll_forward);
|
||||
} else { /* from < to */
|
||||
vmsscrollregion(from, to + howmany - 1);
|
||||
vmsmove(from, 0);
|
||||
for (i = to - from; i > 0; i--)
|
||||
ttputs(scroll_reverse);
|
||||
}
|
||||
vmsscrollregion(-1, -1);
|
||||
}
|
||||
|
||||
vmsscrollregion(top, bot)
|
||||
int top; /* Top position */
|
||||
int bot; /* Bottom position */
|
||||
{
|
||||
char buffer[32];
|
||||
int ret_length;
|
||||
static int request_code = SMG$K_SET_SCROLL_REGION;
|
||||
static int max_buffer_length = sizeof(buffer);
|
||||
static int arg_list[3] = { 2 };
|
||||
char *cp;
|
||||
|
||||
int i;
|
||||
|
||||
/* Set the arguments into the arg_list array
|
||||
* SMG assumes the row/column positions are 1 based (boo!)
|
||||
*/
|
||||
arg_list[1] = top + 1;
|
||||
arg_list[2] = bot + 1;
|
||||
|
||||
if ((smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list)
|
||||
|
||||
/* Argument list array */
|
||||
/* We'll know soon enough if this doesn't work */
|
||||
&1) == 0) {
|
||||
ttputs("OOPS");
|
||||
return;
|
||||
}
|
||||
|
||||
ttputc(0);
|
||||
/* Send out resulting sequence */
|
||||
i = ret_length;
|
||||
cp = buffer;
|
||||
while (i-- > 0)
|
||||
ttputc(*cp++);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***
|
||||
* vmsrev - Set the reverse video status
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsrev(status)
|
||||
int status; /* TRUE if setting reverse */
|
||||
{
|
||||
if (status)
|
||||
ttputs(begin_reverse);
|
||||
else
|
||||
ttputs(end_reverse);
|
||||
}
|
||||
|
||||
/***
|
||||
* vmscres - Change screen resolution (which it doesn't)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmscres()
|
||||
{
|
||||
/* But it could. For vt100/vt200s, one could switch from
|
||||
80 and 132 columns modes */
|
||||
}
|
||||
|
||||
|
||||
#if COLOR
|
||||
/***
|
||||
* vmsfcol - Set the forground color (not implimented)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsfcol()
|
||||
{
|
||||
}
|
||||
|
||||
/***
|
||||
* vmsbcol - Set the background color (not implimented)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsbcol()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/***
|
||||
* vmseeol - Erase to end of line
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmseeol()
|
||||
{
|
||||
ttputs(erase_to_end_line);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmseeop - Erase to end of page (clear screen)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmseeop()
|
||||
{
|
||||
ttputs(erase_whole_display);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmsbeep - Ring the bell
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsbeep()
|
||||
{
|
||||
ttputc('\007');
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmsgetstr - Get an SMG string capability by name
|
||||
*
|
||||
* Returns: Escape sequence
|
||||
* NULL No escape sequence available
|
||||
***/
|
||||
char *vmsgetstr(request_code)
|
||||
int request_code; /* Request code */
|
||||
{
|
||||
char *result;
|
||||
static char seq_storage[1024];
|
||||
static char *buffer = seq_storage;
|
||||
static int arg_list[2] = { 1, 1 };
|
||||
int max_buffer_length, ret_length;
|
||||
|
||||
/* Precompute buffer length */
|
||||
|
||||
max_buffer_length = (seq_storage + sizeof(seq_storage)) - buffer;
|
||||
|
||||
/* Get terminal commands sequence from master table */
|
||||
|
||||
if ((smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list)
|
||||
|
||||
|
||||
/* Argument list array */
|
||||
/* If this doesn't work, try again with no arguments */
|
||||
&1) == 0 && (smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer)
|
||||
|
||||
|
||||
/* Capability data buffer */
|
||||
/* Return NULL pointer if capability is not available */
|
||||
&1) == 0)
|
||||
return NULL;
|
||||
|
||||
/* Check for empty result */
|
||||
if (ret_length == 0)
|
||||
return NULL;
|
||||
|
||||
/* Save current position so we can return it to caller */
|
||||
|
||||
result = buffer;
|
||||
|
||||
/* NIL terminate the sequence for return */
|
||||
|
||||
buffer[ret_length] = 0;
|
||||
|
||||
/* Advance buffer */
|
||||
|
||||
buffer += ret_length + 1;
|
||||
|
||||
/* Return capability to user */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** I/O information block definitions **/
|
||||
struct iosb { /* I/O status block */
|
||||
short i_cond; /* Condition value */
|
||||
short i_xfer; /* Transfer count */
|
||||
long i_info; /* Device information */
|
||||
};
|
||||
struct termchar { /* Terminal characteristics */
|
||||
char t_class; /* Terminal class */
|
||||
char t_type; /* Terminal type */
|
||||
short t_width; /* Terminal width in characters */
|
||||
long t_mandl; /* Terminal's mode and length */
|
||||
long t_extend; /* Extended terminal characteristics */
|
||||
};
|
||||
static struct termchar tc; /* Terminal characteristics */
|
||||
|
||||
/***
|
||||
* vmsgtty - Get terminal type from system control block
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsgtty()
|
||||
{
|
||||
short fd;
|
||||
int status;
|
||||
struct iosb iostatus;
|
||||
$DESCRIPTOR(devnam, "SYS$INPUT");
|
||||
|
||||
/* Assign input to a channel */
|
||||
status = sys$assign(&devnam, &fd, 0, 0);
|
||||
if ((status & 1) == 0)
|
||||
exit(status);
|
||||
|
||||
/* Get terminal characteristics */
|
||||
status = sys$qiow( /* Queue and wait */
|
||||
0, /* Wait on event flag zero */
|
||||
fd, /* Channel to input terminal */
|
||||
IO$_SENSEMODE, /* Get current characteristic */
|
||||
&iostatus, /* Status after operation */
|
||||
0, 0, /* No AST service */
|
||||
&tc, /* Terminal characteristics buf */
|
||||
sizeof(tc), /* Size of the buffer */
|
||||
0, 0, 0, 0); /* P3-P6 unused */
|
||||
|
||||
/* De-assign the input device */
|
||||
if ((sys$dassgn(fd) & 1) == 0)
|
||||
exit(status);
|
||||
|
||||
/* Jump out if bad status */
|
||||
if ((status & 1) == 0)
|
||||
exit(status);
|
||||
if ((iostatus.i_cond & 1) == 0)
|
||||
exit(iostatus.i_cond);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmsopen - Get terminal type and open terminal
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmsopen()
|
||||
{
|
||||
/* Get terminal type */
|
||||
vmsgtty();
|
||||
if (tc.t_type == TT$_UNKNOWN) {
|
||||
printf("Terminal type is unknown!\n");
|
||||
printf
|
||||
("Try set your terminal type with SET TERMINAL/INQUIRE\n");
|
||||
printf("Or get help on SET TERMINAL/DEVICE_TYPE\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
/* Access the system terminal definition table for the */
|
||||
/* information of the terminal type returned by IO$_SENSEMODE */
|
||||
if ((smg$init_term_table_by_type(&tc.t_type, &termtype) & 1) == 0)
|
||||
return -1;
|
||||
|
||||
/* Set sizes */
|
||||
term.t_nrow = ((unsigned int) tc.t_mandl >> 24) - 1;
|
||||
term.t_ncol = tc.t_width;
|
||||
|
||||
/* Get some capabilities */
|
||||
begin_reverse = vmsgetstr(SMG$K_BEGIN_REVERSE);
|
||||
end_reverse = vmsgetstr(SMG$K_END_REVERSE);
|
||||
revexist = begin_reverse != NULL && end_reverse != NULL;
|
||||
erase_to_end_line = vmsgetstr(SMG$K_ERASE_TO_END_LINE);
|
||||
eolexist = erase_to_end_line != NULL;
|
||||
erase_whole_display = vmsgetstr(SMG$K_ERASE_WHOLE_DISPLAY);
|
||||
|
||||
#if SCROLLCODE
|
||||
scroll_forward = vmsgetstr(SMG$K_SCROLL_FORWARD);
|
||||
scroll_reverse = vmsgetstr(SMG$K_SCROLL_REVERSE);
|
||||
if (tc.t_type < TT$_VT100 || scroll_reverse == NULL ||
|
||||
scroll_forward == NULL)
|
||||
term.t_scroll = NULL;
|
||||
else
|
||||
term.t_scroll = vmsscroll_reg;
|
||||
#endif
|
||||
|
||||
/* Set resolution */
|
||||
strcpy(sres, "NORMAL");
|
||||
|
||||
/* Open terminal I/O drivers */
|
||||
ttopen();
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmskopen - Open keyboard (not used)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmskopen()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* vmskclose - Close keyboard (not used)
|
||||
*
|
||||
* Nothing returned
|
||||
***/
|
||||
vmskclose()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
161
fridge/vt52.c
161
fridge/vt52.c
@ -1,161 +0,0 @@
|
||||
/* vt52.c
|
||||
*
|
||||
* The routines in this file
|
||||
* provide support for VT52 style terminals
|
||||
* over a serial line. The serial I/O services are
|
||||
* provided by routines in "termio.c". It compiles
|
||||
* into nothing if not a VT52 style device. The
|
||||
* bell on the VT52 is terrible, so the "beep"
|
||||
* routine is conditionalized on defining BEL.
|
||||
*
|
||||
* modified by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#define termdef 1 /* don't define "term" external */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "estruct.h"
|
||||
|
||||
#if VT52
|
||||
|
||||
#define NROW 24 /* Screen size. */
|
||||
#define NCOL 80 /* Edit if you want to. */
|
||||
#define MARGIN 8 /* size of minimim margin and */
|
||||
#define SCRSIZ 64 /* scroll size for extended lines */
|
||||
#define NPAUSE 100 /* # times thru update to pause */
|
||||
#define BIAS 0x20 /* Origin 0 coordinate bias. */
|
||||
#define ESC 0x1B /* ESC character. */
|
||||
#define BEL 0x07 /* ascii bell character */
|
||||
|
||||
extern int ttopen(); /* Forward references. */
|
||||
extern int ttgetc();
|
||||
extern int ttputc();
|
||||
extern int ttflush();
|
||||
extern int ttclose();
|
||||
extern int vt52move();
|
||||
extern int vt52eeol();
|
||||
extern int vt52eeop();
|
||||
extern int vt52beep();
|
||||
extern int vt52open();
|
||||
extern int vt52rev();
|
||||
extern int vt52cres();
|
||||
extern int vt52kopen();
|
||||
extern int vt52kclose();
|
||||
|
||||
#if COLOR
|
||||
extern int vt52fcol();
|
||||
extern int vt52bcol();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dispatch table.
|
||||
* All the hard fields just point into the terminal I/O code.
|
||||
*/
|
||||
struct terminal term = {
|
||||
NROW - 1,
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
SCRSIZ,
|
||||
NPAUSE,
|
||||
&vt52open,
|
||||
&ttclose,
|
||||
&vt52kopen,
|
||||
&vt52kclose,
|
||||
&ttgetc,
|
||||
&ttputc,
|
||||
&ttflush,
|
||||
&vt52move,
|
||||
&vt52eeol,
|
||||
&vt52eeop,
|
||||
&vt52beep,
|
||||
&vt52rev,
|
||||
&vt52cres
|
||||
#if COLOR
|
||||
, &vt52fcol,
|
||||
&vt52bcol
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
vt52move(row, col)
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('Y');
|
||||
ttputc(row + BIAS);
|
||||
ttputc(col + BIAS);
|
||||
}
|
||||
|
||||
vt52eeol()
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('K');
|
||||
}
|
||||
|
||||
vt52eeop()
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('J');
|
||||
}
|
||||
|
||||
vt52rev(status)
|
||||
/* set the reverse video state */
|
||||
int status; /* TRUE = reverse video, FALSE = normal video */
|
||||
|
||||
{
|
||||
/* can't do this here, so we won't */
|
||||
}
|
||||
|
||||
vt52cres()
|
||||
{ /* change screen resolution - (not here though) */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if COLOR
|
||||
vt52fcol()
|
||||
{ /* set the forground color [NOT IMPLIMENTED] */
|
||||
}
|
||||
|
||||
vt52bcol()
|
||||
{ /* set the background color [NOT IMPLIMENTED] */
|
||||
}
|
||||
#endif
|
||||
|
||||
vt52beep()
|
||||
{
|
||||
#ifdef BEL
|
||||
ttputc(BEL);
|
||||
ttflush();
|
||||
#endif
|
||||
}
|
||||
|
||||
vt52open()
|
||||
{
|
||||
#if V7 | BSD
|
||||
char *cp;
|
||||
char *getenv();
|
||||
|
||||
if ((cp = getenv("TERM")) == NULL) {
|
||||
puts("Shell variable TERM not defined!");
|
||||
exit(1);
|
||||
}
|
||||
if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
|
||||
puts("Terminal type not 'vt52'or 'z19' !");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
ttopen();
|
||||
}
|
||||
|
||||
vt52kopen()
|
||||
{
|
||||
}
|
||||
|
||||
vt52kclose()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
117
fridge/wscreen.c
117
fridge/wscreen.c
@ -1,117 +0,0 @@
|
||||
/* wscreen.c -- windows screen console for MINGW32 */
|
||||
#include "wscreen.h"
|
||||
|
||||
#ifdef MINGW32
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Standard error macro for reporting API errors */
|
||||
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %ld from %s \
|
||||
on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
|
||||
|
||||
static void cls( HANDLE hConsole )
|
||||
{
|
||||
COORD coordScreen = { 0, 0 }; /* here's where we'll home the
|
||||
cursor */
|
||||
BOOL bSuccess;
|
||||
DWORD cCharsWritten;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
|
||||
DWORD dwConSize; /* number of character cells in
|
||||
the current buffer */
|
||||
|
||||
/* get the number of character cells in the current buffer */
|
||||
|
||||
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
|
||||
PERR( bSuccess, "GetConsoleScreenBufferInfo" );
|
||||
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
|
||||
|
||||
/* fill the entire screen with blanks */
|
||||
|
||||
bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
|
||||
dwConSize, coordScreen, &cCharsWritten );
|
||||
PERR( bSuccess, "FillConsoleOutputCharacter" );
|
||||
|
||||
/* get the current text attribute */
|
||||
|
||||
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
|
||||
PERR( bSuccess, "ConsoleScreenBufferInfo" );
|
||||
|
||||
/* now set the buffer's attributes accordingly */
|
||||
|
||||
bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
|
||||
dwConSize, coordScreen, &cCharsWritten );
|
||||
PERR( bSuccess, "FillConsoleOutputAttribute" );
|
||||
|
||||
/* put the cursor at (0, 0) */
|
||||
|
||||
bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
|
||||
PERR( bSuccess, "SetConsoleCursorPosition" );
|
||||
return;
|
||||
}
|
||||
|
||||
void wcls( void) {
|
||||
cls( GetStdHandle( STD_OUTPUT_HANDLE)) ;
|
||||
}
|
||||
|
||||
static struct {
|
||||
int width ;
|
||||
int height ;
|
||||
int curTop, curBot, curRight, curLeft ;
|
||||
} Screen ;
|
||||
|
||||
void winit( void) {
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbInfo ;
|
||||
|
||||
wcls() ;
|
||||
if( GetConsoleScreenBufferInfo(
|
||||
GetStdHandle( STD_OUTPUT_HANDLE), &csbInfo)) {
|
||||
Screen.width = csbInfo.dwSize.X ;
|
||||
Screen.height = csbInfo.dwSize.Y ;
|
||||
Screen.curLeft = csbInfo.srWindow.Left ;
|
||||
Screen.curTop = csbInfo.srWindow.Top ;
|
||||
Screen.curRight = csbInfo.srWindow.Right ;
|
||||
Screen.curBot = csbInfo.srWindow.Bottom ;
|
||||
}
|
||||
}
|
||||
|
||||
int wwidth( void) {
|
||||
return Screen.width ;
|
||||
}
|
||||
|
||||
int wheight( void) {
|
||||
return Screen.height ;
|
||||
}
|
||||
|
||||
int wleft( void) {
|
||||
return Screen.curLeft ;
|
||||
}
|
||||
|
||||
int wtop( void) {
|
||||
return Screen.curTop ;
|
||||
}
|
||||
|
||||
int wright( void) {
|
||||
return Screen.curRight ;
|
||||
}
|
||||
|
||||
int wbottom( void) {
|
||||
return Screen.curBot ;
|
||||
}
|
||||
|
||||
void wgoxy( int x, int y) {
|
||||
COORD coord ;
|
||||
|
||||
coord.X = x ;
|
||||
coord.Y = y ;
|
||||
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE), coord );
|
||||
}
|
||||
|
||||
void wtitle( const char *title) {
|
||||
SetConsoleTitle( title) ;
|
||||
}
|
||||
|
||||
#endif /* MINGW32 */
|
||||
|
||||
/* end of wscreen.c */
|
@ -1,14 +0,0 @@
|
||||
/* wscreen.h -- character screen drawing */
|
||||
|
||||
void winit( void) ;
|
||||
void wcls( void) ;
|
||||
void wgoxy( int x, int y) ;
|
||||
void wtitle( const char *title) ;
|
||||
int wwidth( void) ;
|
||||
int wheight( void) ;
|
||||
int wleft( void) ;
|
||||
int wright( void) ;
|
||||
int wtop( void) ;
|
||||
int wbottom( void) ;
|
||||
|
||||
/* end of wscreen.h */
|
2
lock.c
2
lock.c
@ -1,6 +1,4 @@
|
||||
/* lock.c -- implements lock.h */
|
||||
|
||||
#include "estruct.h"
|
||||
#include "lock.h"
|
||||
|
||||
/* LOCK.C
|
||||
|
8
lock.h
8
lock.h
@ -1,9 +1,9 @@
|
||||
/* lock.h -- */
|
||||
|
||||
#ifndef _LOCK_H_
|
||||
#define _LOCK_H_
|
||||
|
||||
#ifndef _ESTRUCT_H_
|
||||
#error uEmacs compilation settings needs to be done!
|
||||
#endif
|
||||
#include "estruct.h"
|
||||
|
||||
#if BSD | SVR4
|
||||
|
||||
@ -14,3 +14,5 @@ int unlock( const char *fname) ;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* end of lock.h */
|
||||
|
1
pklock.c
1
pklock.c
@ -1,5 +1,4 @@
|
||||
/* pklock.c -- implements pklock.h */
|
||||
#include "estruct.h"
|
||||
#include "pklock.h"
|
||||
|
||||
/* PKLOCK.C
|
||||
|
8
pklock.h
8
pklock.h
@ -1,9 +1,9 @@
|
||||
/* pklock.h -- */
|
||||
|
||||
#ifndef _PKLOCK_H_
|
||||
#define _PKLOCK_H_
|
||||
|
||||
#ifndef _ESTRUCT_H_
|
||||
#error uEmacs compilation settings needs to be done!
|
||||
#endif
|
||||
#include "estruct.h"
|
||||
|
||||
#if (FILOCK && BSD) || SVR4
|
||||
|
||||
@ -13,3 +13,5 @@ char *undolock( const char *fname) ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* end of pklock.h */
|
||||
|
159
region.c
159
region.c
@ -1,13 +1,11 @@
|
||||
/* region.c -- implements region.h */
|
||||
#include "region.h"
|
||||
|
||||
/* region.c
|
||||
*
|
||||
* The routines in this file deal with the region, that magic space
|
||||
* between "." and mark. Some functions are commands. Some functions are
|
||||
* just for internal use.
|
||||
*
|
||||
* Modified by Petri Kutvonen
|
||||
/* The routines in this file deal with the region, that magic space between
|
||||
"." and mark. Some functions are commands. Some functions are just for
|
||||
internal use.
|
||||
|
||||
Modified by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@ -20,20 +18,22 @@
|
||||
#include "random.h"
|
||||
#include "window.h"
|
||||
|
||||
/* Kill the region. Ask "getregion" to figure out the bounds of the
|
||||
* region. Move "." to the start, and kill the characters. Bound to
|
||||
* "C-W".
|
||||
/* Kill the region. Ask getregion() to figure out the bounds of the
|
||||
region. Move "." to the start, and kill the characters. Bound to C-W
|
||||
kill-region.
|
||||
*/
|
||||
BINDABLE( killregion) {
|
||||
int s;
|
||||
region_t region ;
|
||||
|
||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return s;
|
||||
int ret = getregion( ®ion) ;
|
||||
if( ret != TRUE)
|
||||
return ret ;
|
||||
|
||||
if( (lastflag & CFKILL) == 0) /* This is a kill type */
|
||||
kdelete() ; /* command, so do magic */
|
||||
|
||||
thisflag |= CFKILL ; /* kill buffer stuff. */
|
||||
curwp->w_dotp = region.r_linep ;
|
||||
curwp->w_doto = region.r_offset ;
|
||||
@ -41,102 +41,91 @@ BINDABLE( killregion) {
|
||||
}
|
||||
|
||||
/* Copy all of the characters in the region to the kill buffer. Don't move
|
||||
* dot at all. This is a bit like a kill region followed by a yank. Bound
|
||||
* to "M-W".
|
||||
dot at all. This is a bit like a kill region followed by a yank. Bound
|
||||
to M-W copy-region.
|
||||
*/
|
||||
BINDABLE( copyregion) {
|
||||
line_p linep;
|
||||
int loffs;
|
||||
int s;
|
||||
region_t region ;
|
||||
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return s;
|
||||
int ret = getregion( ®ion) ;
|
||||
if( ret != TRUE)
|
||||
return ret ;
|
||||
|
||||
if( (lastflag & CFKILL) == 0) /* Kill type command. */
|
||||
kdelete() ;
|
||||
|
||||
thisflag |= CFKILL ;
|
||||
linep = region.r_linep; /* Current line. */
|
||||
loffs = region.r_offset; /* Current offset. */
|
||||
line_p linep = region.r_linep ; /* Current line. */
|
||||
int loffs = region.r_offset ; /* Current offset. */
|
||||
while( region.r_size--) {
|
||||
if( loffs == llength( linep)) { /* End of line. */
|
||||
if ((s = kinsert('\n')) != TRUE)
|
||||
return s;
|
||||
ret = kinsert( '\n') ;
|
||||
if( ret != TRUE)
|
||||
return ret ;
|
||||
|
||||
linep = lforw( linep) ;
|
||||
loffs = 0 ;
|
||||
} else { /* Middle of line. */
|
||||
if ((s = kinsert(lgetc(linep, loffs))) != TRUE)
|
||||
return s;
|
||||
ret = kinsert( lgetc( linep, loffs)) ;
|
||||
if( ret != TRUE)
|
||||
return ret ;
|
||||
|
||||
++loffs ;
|
||||
}
|
||||
}
|
||||
|
||||
mloutstr( "(region copied)") ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/* Lower case region. Zap all of the upper case characters in the region
|
||||
* to lower case. Use the region code to set the limits. Scan the buffer,
|
||||
* doing the changes. Call "lchange" to ensure that redisplay is done in
|
||||
* all buffers. Bound to "C-X C-L".
|
||||
/* Lower case region & Upper case region. Zap all of the upper/lower case
|
||||
characters in the region to lower/upper case. Use the region code to
|
||||
set the limits. Scan the buffer, doing the changes. Call "lchange" to
|
||||
ensure that redisplay is done in all buffers. Bound to C-X C-L
|
||||
case-region-lower and C-X C-U case-region-upper.
|
||||
*/
|
||||
static int utol( int c) {
|
||||
return (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : -1 ;
|
||||
}
|
||||
|
||||
static int ltou( int c) {
|
||||
return (c >= 'a' && c <= 'z') ? c + 'A' - 'a' : -1 ;
|
||||
}
|
||||
|
||||
static int caseregion( int (* cconv)( int)) {
|
||||
region_t region ;
|
||||
|
||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||
|
||||
int ret = getregion( ®ion) ;
|
||||
if( ret != TRUE)
|
||||
return ret ;
|
||||
|
||||
lchange( WFHARD) ;
|
||||
line_p linep = region.r_linep ;
|
||||
int loffs = region.r_offset ;
|
||||
while( region.r_size--) {
|
||||
if( loffs == llength( linep)) {
|
||||
linep = lforw( linep) ;
|
||||
loffs = 0 ;
|
||||
} else {
|
||||
int c = cconv( lgetc( linep, loffs)) ;
|
||||
if( c != -1)
|
||||
lputc( linep, loffs, c) ;
|
||||
|
||||
++loffs ;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
BINDABLE( lowerregion) {
|
||||
line_p linep;
|
||||
int loffs;
|
||||
int c;
|
||||
int s;
|
||||
region_t region;
|
||||
|
||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return s;
|
||||
lchange(WFHARD);
|
||||
linep = region.r_linep;
|
||||
loffs = region.r_offset;
|
||||
while (region.r_size--) {
|
||||
if (loffs == llength(linep)) {
|
||||
linep = lforw(linep);
|
||||
loffs = 0;
|
||||
} else {
|
||||
c = lgetc(linep, loffs);
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
lputc(linep, loffs, c + 'a' - 'A');
|
||||
++loffs;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return caseregion( utol) ;
|
||||
}
|
||||
|
||||
/* Upper case region. Zap all of the lower case characters in the region
|
||||
* to upper case. Use the region code to set the limits. Scan the buffer,
|
||||
* doing the changes. Call "lchange" to ensure that redisplay is done in
|
||||
* all buffers. Bound to "C-X C-L".
|
||||
*/
|
||||
BINDABLE( upperregion) {
|
||||
line_p linep;
|
||||
int loffs;
|
||||
int c;
|
||||
int s;
|
||||
region_t region;
|
||||
|
||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return s;
|
||||
lchange(WFHARD);
|
||||
linep = region.r_linep;
|
||||
loffs = region.r_offset;
|
||||
while (region.r_size--) {
|
||||
if (loffs == llength(linep)) {
|
||||
linep = lforw(linep);
|
||||
loffs = 0;
|
||||
} else {
|
||||
c = lgetc(linep, loffs);
|
||||
if (c >= 'a' && c <= 'z')
|
||||
lputc(linep, loffs, c - 'a' + 'A');
|
||||
++loffs;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return caseregion( ltou) ;
|
||||
}
|
||||
|
||||
/* This routine figures out the bounds of the region in the current window,
|
||||
|
Loading…
Reference in New Issue
Block a user