📄 edterm.c
字号:
#endif
static union REGS rg;
static void pc_open()
{
scinit(CDSENSE);
ttopen();
}
static int scinit( /* initialize the screen head pointers */
int type) /* type of adapter to init for */
{
#if IBM_ICB
union {
int laddr; /* long form of address */
short *paddr; /* pointer form of address */
} addr;
#else
union {
long laddr; /* long form of address */
int *paddr; /* pointer form of address */
} addr;
#endif
int i;
#if IBM_ZTC
disp_open();
#endif
/* 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);
switch (type) {
case CDMONO: /* Monochrome adapter */
scadd = SCADM;
break;
case CDCGA: /* Color graphics adapter */
scadd = SCADC;
break;
}
dtype = type;
/* initialize the screen pointer array */
for (i = 0; i < NROW; i++) {
#if IBM_ICB
addr.laddr = scadd + (NCOL * i * 2);
#else
addr.laddr = scadd + (long)(NCOL * i * 2);
#endif
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
*/
/* getbaord: Detect the current display adapter
if MONO set to MONO
CGA set to CGA
*/
static int getboard()
{
int type; /* board type to return */
type = CDCGA;
int86(0x11, &rg, &rg);
if ((((rg.x.ax >> 4) & 3) == 3))
type = CDMONO;
return(type);
}
static int pc_getc()
{
int intrpt = 22; /* ROM-BIOS call for keyboard read */
rg.h.al = 0; /* Clear input registers */
rg.h.ah = 0; /* and set service to read */
int86(intrpt, &rg, &rg);
if(rg.h.al != 0) /* If low byte is not clear */
return(rg.h.al); /* then return value */
else { /* else, */
switch(rg.h.ah) { /* check hi byte for code */
case 3 :
return(COTL_AT_SIGN);
case 71 :
return(HOME_KEY);
case 72 :
return(UP_ARROW);
case 73 :
return(PGUP_KEY);
case 75 :
return(LEFT_ARROW);
case 77 :
return(RIGHT_ARROW);
case 79 :
return(END_KEY);
case 80 :
return(DOWN_ARROW);
case 81 :
return(PGDN_KEY);
case 115 :
return(COTL_LEFT_ARROW);
case 116 :
return(COTL_RIGHT_ARROW);
default :
return(BADKEY);
}
}
}
static void pc_putc(
int c)
{
rg.h.ah = 14; /* write char to screen with current attrs */
rg.h.al = (unsigned char) c;
rg.h.bh = 0;
rg.h.bl = 0x07;
int86(0x10, &rg, &rg);
}
static void pc_move(
int row,
int col)
{
rg.h.ah = 2; /* set cursor position function code */
rg.h.dl = (unsigned char) col;
rg.h.dh = (unsigned char) row;
rg.h.bh = 0; /* set screen page number */
int86(0x10, &rg, &rg);
}
static void pc_eeol()
{
unsigned int attr; /* attribute byte mask to place in RAM */
#if IBM_ICB
unsigned short *lnptr; /* pointer to the destination line */
#else
unsigned int *lnptr; /* pointer to the destination line */
#endif
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 */
attr = 0x0700;
lnptr = &sline[0];
for (i=0; i < term.t_ncol; i++)
*lnptr++ = SPACE | attr;
if (dtype == CDCGA) {
/* wait for vertical retrace to be off */
while ((inp(0x3da) & 8))
;
/* and to be back on */
while ((inp(0x3da) & 8) == 0)
;
}
#if IBM_ZTC
disp_move(crow,ccol);
disp_flush();
disp_eeol();
#endif
/* and send the string out */
#if (! IBM_ZTC)
memmove(scptr[crow]+ccol, &sline[0], (term.t_ncol-ccol)*2);
#endif
}
static void pc_eeop()
{
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 */
attr = 0x07;
rg.h.bh = (unsigned char) attr;
int86(0x10, &rg, &rg);
}
static void pc_beep()
{
pc_putc(BEL);
ttflush();
}
#endif
#endif
/* ==========================================================================
* Termcap Terminal
* ==========================================================================
*/
#if TERMCAP
/*
* The routines in this section provide support for terminals supported
* through the UNIX termcap capability.
*
* You need to include the termcap library at link time
* or else most of the calls to t____ functions don't work
*/
#define NROW 24
#define NCOL 80
#define BEL 0x07
#define ESC 0x1B
#define TCAPSLEN 315
static char tcapbuf[TCAPSLEN];
static char /*PC,*/
*CM,
*CE,
/* *UP, */
*CD;
globle TERM term = {
NROW-1,
NCOL,
tcapopen,
ttclose,
ttgetc,
ttputc,
ttflush,
tcapmove,
tcapeeol,
tcapeeop,
tcapbeep
};
static void tcapopen()
{
char *t, *p;
char tcbuf[1024];
char *tv_stype;
char err_str[72];
if ((tv_stype = getenv("TERM")) == NULL)
{
puts("Environment variable TERM not defined!");
exit(1);
}
if((tgetent(tcbuf, tv_stype)) != 1)
{
sprintf(err_str, "Unknown terminal type %s!", tv_stype);
puts(err_str);
exit(1);
}
p = tcapbuf;
t = tgetstr("pc", &p);
if(t)
PC = *t;
CD = tgetstr("cd", &p);
CM = tgetstr("cm", &p);
CE = tgetstr("ce", &p);
UP = tgetstr("up", &p);
if(CD == NULL || CM == NULL || CE == NULL || UP == NULL)
{
puts("Incomplete termcap entry\n");
exit(1);
}
if (p >= &tcapbuf[TCAPSLEN])
{
puts("Terminal description too big!\n");
exit(1);
}
ttopen();
}
static void tcapmove(
int row,
int col)
{
putpad(tgoto(CM, col, row));
}
static void tcapeeol()
{
putpad(CE);
}
static void tcapeeop()
{
putpad(CD);
}
static void tcapbeep()
{
ttputc(BEL);
}
static void putpad(
char *str)
{
tputs(str, 1, (int (*)(int)) ttputc);
}
#endif
#endif /* end original EMACS_EDITOR definition */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -