home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
199_01
/
ged11.c
< prev
next >
Wrap
Text File
|
1987-12-17
|
12KB
|
403 lines
/*
Header: CUG199;
Title: Terminal specific module for ged editor;
Last Updated: 12/01/87;
Description: "PURPOSE: terminal dependent screen control functions.
Uses DeSmet's PCIO.A screen code w/additions"
Keywords: e, editor, qed, ged, DeSmet, MSDOS;
Filename: ged11.c;
Warnings: "O file must be present during link for ged";
Authors: G. Nigel Gilbert, James W. Haefner, and Mel Tearle;
Compilers: DeSmet 3.0;
References:
Endref;
*/
/*
e/qed/ged screen editor
(C) G. Nigel Gilbert, MICROLOGY, 1981 - August-December 1981
Modified: Aug-Dec 1984: BDS-C 'e'(vers 4.6a) to 'qe' (J.W. Haefner)
March 1985: BDS-C 'qe' to DeSmet-C 'qed' (J.W. Haefner)
May 1986: qed converted to ged (Mel Tearle)
August 1987: ged converted to MSC 4.0 (Mel Tearle)
File: ged11.c
Functions: delpage,
norm, high, keytranslate, displayhelp
Note: This file is very specific to IBM-PC like hardware.
Mostly interrupt routines for time, pathnames, keyboard
definitions, and help screen.
*/
#ifndef TC
#include "ged.h"
#else
#include "ged.t"
#endif
/* control key codes, here for convenience in defining terminal sequences
*/
#define CTRLA 0x01 /* SOH */
#define CTRLB 0x02 /* STX */
#define CTRLC 0x03 /* ETX */
#define CTRLD 0x04 /* EOT */
#define CTRLE 0x05 /* ENQ */
#define CTRLF 0x06 /* ACK */
#define CTRLG 0x07 /* BEL */
#define CTRLH 0x08 /* BS */
#define CTRLI 0x09 /* HT */
#define CTRLJ 0x0a /* LF */
#define CTRLK 0x0b /* VT */
#define CTRLL 0x0c /* FF */
#define CTRLM 0x0d /* CR */
#define CTRLN 0x0e /* SO */
#define CTRLO 0x0f /* SI */
#define CTRLP 0x10 /* DLE */
#define CTRLQ 0x11 /* DC1 */
#define CTRLR 0x12 /* DC2 */
#define CTRLS 0x13 /* DC3 */
#define CTRLT 0x14 /* DC4 */
#define CTRLU 0x15 /* NAK */
#define CTRLV 0x16 /* SYN */
#define CTRLW 0x17 /* ETB */
#define CTRLX 0x18 /* CAN */
#define CTRLY 0x19 /* EM */
#define CTRLZ 0x1a /* SUB */
/* defines the terminal key codes
* which perform the editor commands
*/
void keytranslate()
{
/* each tran[xxxx]= should be set to the code emitted by the terminal
key which will perform the indicated action. The recommended (control)
key assignments are shown in round brackets.
Some terminals precede their codes by a lead-in character
(eg the Hazeltine uses the tilde). This char should be assigned to
tran[LEADIN]. If there is no lead-in character, set tran[LEADIN] to zero.
'e' will ignore the leadin character if tran[LEADIN] is non-zero,
but will set the parity bit on the next character. All other chars from the
keyboard will already have any parity bits removed as they are read in. Thus
codes with lead-ins should be entered in the table below as code+0x80, or
more clearly, as code+PARBIT.
For example, suppose that one is coding the Hazeltine 1420, which
generates a tilde,^L (0x0d) sequence when the cursor up key is pressd. To
recognise this sequence, set tran[LEADIN] to tilde (0x7e) and set
tran[UPKEY] to 0x0d+PARBIT.
*/
tran[LEADIN] = 0; /* 0 lead-in character, 0 if not used */
tran[DOWNKEY] = CTRLX; /* 1 cursor down */
tran[UPKEY] = CTRLE; /* 2 cursor up */
tran[LEFTKEY] = CTRLS; /* 3 cursor left */
tran[RIGHTKEY] = CTRLD; /* 4 cursor right */
tran[RIGHTWKEY] = CTRLF; /* 5 cursor right one word (F) */
tran[LEFTWKEY] = CTRLA; /* 6 cursor left one word (A) */
tran[EOLKEY] = CTRLP; /* 7 cursor to end of line (P) */
tran[BOLKEY] = CTRLO; /* 8 cursor to beginning of line (P) */
tran[UPPAGE] = CTRLR; /* 9 scroll up a page (R) */
tran[DOWNPAGE] = CTRLC; /* 10 scroll down a page (C) */
tran[BOFKEY] = CTRLU; /* 11 cursor to beginning of file (U) */
tran[HOMEKEY] = CTRLB; /* 12 cursor to end of file (B) */
tran[DELLEFT] = 0x7f; /* 13 delete char to left of cursor (DEL) */
tran[DELRIGHT] = CTRLG; /* 14 delete char under cursor (G) */
tran[DELLNKEY] = 0x1C; /* 15 delete cursor line (^\) */
tran[DELWDKEY] = CTRLT; /* 16 delete word to right of cursor (T) */
tran[JUMPKEY] = CTRLJ; /* 17 jump to (J) */
tran[CRSTILL] = CTRLN; /* 18 insert newline after cursor (N) */
tran[QWIKKEY] = CTRLQ; /* 19 quit (Q) */
tran[SCRLUPKEY] = CTRLW; /* 20 scroll up thru text (W) */
tran[TOPSCRKEY] = CTRLY; /* 21 top of screen (Y) */
tran[BOTSCRKEY] = CTRLV; /* 22 bottom of screen (V) */
tran[BLOCKKEY] = CTRLK; /* 23 block operations (K) */
tran[SCRLDNKEY] = CTRLZ; /* 24 scroll down thru text (Z) */
tran[REPKEY] = CTRLL; /* 25 repeat last find/alter (L) */
tran[HELPKEY] = 0x1e; /* 26 display help menu (^^) */
tran[OOPSKEY] = 0x1f; /* 27 restore unedited line (^_) */
tran[TAB] = CTRLI; /* 28 tab (I) */
tran[RETRIEVE] = CTRLL; /* 29 retrieve (L) */
tran[CR] = 0x0d; /* 30 return */
tran[ESCKEY] = 0x1b; /* 31 escape, the magic key (ESC) */
}
/* interrupt routines follow */
#ifndef DS
union REGS r;
struct SREGS seg;
/* get current cursor position
*/
int getcursor()
{
r.x.ax = 0x0300;
r.x.bx = 0 << 8;
int86( 0x10, &r, &r );
return ( r.h.dl );
}
void curdrv(drv)
char drv[];
{
r.x.ax = 0x1900; /* DOS interrupt 19 */
intdos( &r, &r ); /* gets current drive number */
drv[0] = ( char ) ( r.x.ax + 'a'); /* convert to symbolic drive name */
drv[1] = ':';
drv[2] = '\0';
}
/* getpath - get path to directory on default drive
*/
void getpath(path)
char path[];
{
strcat( path, "\\" );
r.x.ax = 0x4700; /* DOS interrupt 47 gets path string */
r.x.dx = path[0] - '`'; /* convert to index */
r.x.si = (unsigned)&path[3];
intdos( &r, &r );
}
/* this function originally used sprintf to format timestr, however
* that added 4K of overhead to ged and was only used by this routine
*/
void xgettime()
{
unsigned hour, min;
char str[4];
r.x.ax = 0x2C00;
intdos( &r, &r );
min = r.x.cx & 0x00ff;
hour = r.x.cx >> 8;
zf_time( hour, str ); strcpy( timestr, str ); strcat( timestr, ":" );
zf_time( min, str ); strcat( timestr, str );
}
/* get status of parallel printer port - is the printer turned on?
* report if error
*/
int prnstat()
{
r.x.ax = ( 0x02 << 8 );
r.x.dx = 0; /* 0 = prn */
intdos( &r, &r );
if ( ( ( r.x.ax >> 8 ) & 0x80 ) ||
( ( r.x.ax >> 8 ) & 0x40 ) ||
( ( r.x.ax >> 8 ) & 0x10 ) )
return( 1 );
else {
scr_co( '\07' );
error( "error on printer " );
return( 0 );
}
}
#else
/* DeSmet C variables for 8086 registers and flags
*/
unsigned _rax, _rbx, _rcx, _rdx, _rsi, _rdi, _res, _rds;
char _carryf, _zerof;
/* get current cursor position
*/
int getcursor()
{
_rax = 0x0300;
_rbx = 0 << 8;
_doint( 0x10 );
return ( _rdx & 0xff );
}
/* curdrv - get current default drive
* from ed nather's ls.c
*/
void curdrv(drv)
char *drv;
{
int i;
i = _os( 0x19, 0 ); /* gets current drive number */
*drv++ = i + 'a'; /* convert to symbolic drive name */
*drv++ = ':';
return;
}
/* get path to directory on indicated drive
* from ed nather's ls.c
*/
void getpath(path)
char *path;
{
extern int _showds();
strcat( path, "\\" ); /* append root file symbol to drive name */
_rax = 0x4700; /* DOS interrupt 47 gets path string */
_rdx = *path - '`'; /* convert drive name to index */
_rsi = path + 3; /* paste string after root symbol */
_rds = _showds();
_doint( DOSINT );
return;
}
/* this function originally used sprintf to format timestr, however
* that added 4K of overhead to ged and was on