home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume26
/
beav
/
part08
< prev
next >
Wrap
Text File
|
1991-11-21
|
55KB
|
2,265 lines
Newsgroups: comp.sources.misc
From: pvr@wang.com (Peter Reilley)
Subject: v26i044: beav - Binary file editor and viewer, v1.32, Part08/09
Message-ID: <1991Nov21.230409.1976@sparky.imd.sterling.com>
X-Md4-Signature: 4a80cf651476b320c1125fc0e57063c4
Date: Thu, 21 Nov 1991 23:04:09 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: pvr@wang.com (Peter Reilley)
Posting-number: Volume 26, Issue 44
Archive-name: beav/part08
Environment: UNIX, AIX, MS-DOS, AMIGA
Supersedes: beav: Volume 22, Issue 10-18
#! /bin/sh
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: ebcdic.c echo.c format.c kbd.c prototyp.h region.c tcap.c
# tty.c wangpc.c word.c
# Wrapped by kent@sparky on Thu Nov 21 16:47:02 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 8 (of 9)."'
if test -f 'ebcdic.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ebcdic.c'\"
else
echo shar: Extracting \"'ebcdic.c'\" \(2453 characters\)
sed "s/^X//" >'ebcdic.c' <<'END_OF_FILE'
X
X#include "def.h"
X
Xextern char ERR_ebcdic[];
X
X/* Function definitions */
X
X/* This table defines the translation from EBCDIC code to ASCII. */
X
Xchar ebcdic_table[] =
X{
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 00-07 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 08-0F */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 10-17 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 18-1F */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 20-27 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 28-2F */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 30-37 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 38-3F */
X 0x20, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 40-47 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x3C, 0x28, 0x2B, 0x2E,/* 48-4F */
X 0x26, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 50-57 */
X 0x2E, 0x2E, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E,/* 58-5F */
X 0x2D, 0x2F, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 60-67 */
X 0x2E, 0x2E, 0x7C, 0x2E, 0x25, 0x5F, 0x3E, 0x3F,/* 68-6F */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x27, 0x2E, 0x2E,/* 70-77 */
X 0x2E, 0x60, 0x3A, 0x23, 0x40, 0x2C, 0x3D, 0x22,/* 78-7F */
X 0x2E, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,/* 80-87 */
X 0x68, 0x69, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 88-8F */
X 0x2E, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,/* 90-97 */
X 0x71, 0x72, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 98-9F */
X 0x2E, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,/* A0-A7 */
X 0x79, 0x7A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* A8-AF */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* B0-B7 */
X 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* B8-BF */
X 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,/* C0-C7 */
X 0x48, 0x49, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* C8-CF */
X 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,/* D0-D7 */
X 0x51, 0x52, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* D8-DF */
X 0x5C, 0x2E, 0X53, 0x54, 0x55, 0x56, 0x57, 0x58,/* E0-E7 */
X 0x59, 0x5A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* E8-EF */
X 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,/* F0-F7 */
X 0x38, 0x39, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E/* F8-FF */
X};
X
X/* convert a ASCII character to an EBCDIC character */
Xchar to_ebcdic (ch)
X
Xchar ch;
X{
X int cnt;
X char buf[NCOL], buf1[NCOL];
X
X for (cnt = 0; cnt < sizeof (ebcdic_table); cnt++)
X {
X if (ch == ebcdic_table[cnt])
X return (cnt);
X }
X sprintf (buf1, ERR_ebcdic, R_BYTE_FMT(curwp));
X sprintf (buf, buf1, ch);
X writ_echo(buf);
X return (0);
X}
END_OF_FILE
if test 2453 -ne `wc -c <'ebcdic.c'`; then
echo shar: \"'ebcdic.c'\" unpacked with wrong size!
fi
# end of 'ebcdic.c'
fi
if test -f 'echo.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'echo.c'\"
else
echo shar: Extracting \"'echo.c'\" \(7152 characters\)
sed "s/^X//" >'echo.c' <<'END_OF_FILE'
X/*
X* Echo line reading and writing.
X* Common routines for reading
X* and writing characters in the echo line area
X* of the display screen. Used by the entire
X* known universe.
X*/
X#include "def.h"
X
Xvoid eerase ();
Xchar ereply ();
Xchar eread ();
Xvoid eformat ();
Xvoid eputi ();
Xvoid eputs ();
Xvoid eputc ();
X
X
Xextern char MSG_null[];
Xextern char MSG_y_n[];
Xextern char MSG_hex_dig[];
Xextern char MSG_hit_key[];
X
Xint epresf = FALSE; /* Stuff in echo line flag. */
X
X/*
X* Erase the echo line.
X*/
Xvoid eerase ()
X{
X writ_echo (MSG_null); /* clear the echo line */
X epresf = FALSE;
X}
X
X
X/*
X* Ask "yes" or "no" question.
X* Return ABORT if the user answers the question
X* with the abort ("^G") character. Return FALSE
X* for "no" and TRUE for "yes". No formatting
X* services are available.
X*/
Xchar eyesno (sp)
Xchar *sp;
X{
X
X register char s;
X char buf[NCOL];
X
X for (;;)
X {
X
X s = ereply (MSG_y_n, buf, sizeof (buf), sp);
X if (s == ABORT)
X return (ABORT);
X if (s != FALSE)
X {
X
X if (buf[0] == 'y' || buf[0] == 'Y')
X return (TRUE);
X if (buf[0] == 'n' || buf[0] == 'N')
X return (FALSE);
X }
X
X }
X
X}
X
X
X/*
X* Write out a prompt, and read back a
X* reply. The prompt is now written out with full "eprintf"
X* formatting, although the arguments are in a rather strange
X* place. This is always a new message, there is no auto
X* completion, and the return is echoed as such.
X*/
X/* VARARGS3 */
Xchar ereply (fp, buf, nbuf, arg)
Xchar *fp;
Xchar *buf;
Xint nbuf;
Xchar *arg;
X{
X return (eread (fp, buf, nbuf, EFNEW | EFCR, arg));
X}
X
X
X/*
X* This is the general "read input from the
X* echo line" routine. The basic idea is that the prompt
X* string "prompt" is written to the echo line, and a one
X* line reply is read back into the supplied "buf" (with
X* maximum length "len"). The "flag" contains EFNEW (a
X* new prompt), an EFAUTO (autocomplete), or EFCR (echo
X* the carriage return as CR).
X*/
Xchar eread (fp, buf, nbuf, flag, ap)
Xchar *fp;
Xchar *buf;
Xchar *ap;
X{
X
X register int cpos;
X register SYMBOL * sp1;
X register SYMBOL * sp2;
X register int i;
X register int c;
X register int h;
X register int nhits;
X register int nxtra;
X register int bxtra;
X
X int quote_flag;
X
X quote_flag = 0;
X cpos = 0;
X if (kbdmop != NULL)
X {
X /* In a macro. */
X while ((c = *kbdmop++) != '\0')
X buf[cpos++] = c;
X buf[cpos] = '\0';
X goto done;
X }
X
X if ((flag & EFNEW) != 0 || ttrow != nrow - 1)
X {
X
X ttcolor (CTEXT);
X ttmove (nrow - 1, 0);
X epresf = TRUE;
X }
X else
X eputc (' ');
X eformat (fp, ap);
X tteeol ();
X ttflush ();
X for (;;)
X {
X c = getkey ();
X if (c == ' ' && (flag & EFAUTO) != 0)
X {
X nhits = 0;
X nxtra = HUGE;
X for (h = 0; h < NSHASH; ++h)
X {
X sp1 = symbol[h];
X while (sp1 != NULL)
X {
X for (i = 0; i < cpos; ++i)
X {
X if (buf[i] != sp1 -> s_name[i])
X break;
X }
X
X if (i == cpos)
X {
X if (nhits == 0)
X sp2 = sp1;
X ++nhits;
X bxtra = getxtra (sp1, sp2, cpos);
X if (bxtra < nxtra)
X nxtra = bxtra;
X }
X
X sp1 = sp1 -> s_symp;
X }
X }
X
X if (nhits == 0) /* No completion. */
X continue;
X for (i = 0; i < nxtra && cpos < nbuf - 1; ++i)
X {
X c = sp2 -> s_name[cpos];
X buf[cpos++] = c;
X eputc (c);
X }
X
X ttflush ();
X if (nhits != 1) /* Fake a CR if there */
X continue; /* is 1 choice. */
X c = (KCTRL | 'M');
X }
X if (quote_flag)
X {
X c = c & 0x1f;
X quote_flag = 0;
X }
X
X
X switch (c)
X {
X case (KCTRL | 'Q'):
X quote_flag = 1;
X break;
X case (KCTRL | 'M'): /* Return, done. */
X buf[cpos] = '\0';
X if (kbdmip != NULL)
X {
X if (kbdmip + cpos + 1 > &kbdm[NKBDM - 3])
X {
X (void) ctrlg (FALSE, 0, KRANDOM);
X ttflush ();
X return (ABORT);
X }
X
X for (i = 0; i < cpos; ++i)
X *kbdmip++ = buf[i];
X *kbdmip++ = '\0';
X }
X
X if ((flag & EFCR) != 0)
X {
X ttputc (0x0D);
X ttflush ();
X }
X
X goto done;
X
X case (KCTRL | 'G'): /* Bell, abort. */
X eputc (0x07);
X (void) ctrlg (FALSE, 0, KRANDOM);
X ttflush ();
X return (ABORT);
X
X case 0x7F: /* Rubout, erase. */
X case (KCTRL | 'H'): /* Backspace, erase. */
X if (cpos != 0)
X {
X ttputc ('\b');
X ttputc (' ');
X ttputc ('\b');
X --ttcol;
X if (ISCTRL (buf[--cpos]) != FALSE)
X {
X ttputc ('\b');
X ttputc (' ');
X ttputc ('\b');
X --ttcol;
X }
X
X ttflush ();
X }
X break;
X
X case (KCTRL | 'U'): /* C-U, kill line. */
X while (cpos != 0)
X {
X ttputc ('\b');
X ttputc (' ');
X ttputc ('\b');
X --ttcol;
X if (ISCTRL (buf[--cpos]) != FALSE)
X {
X ttputc ('\b');
X ttputc (' ');
X ttputc ('\b');
X --ttcol;
X }
X
X }
X
X ttflush ();
X break;
X
X default: /* All the rest. */
X if ((cpos < nbuf - 1) && ((c & ~KCHAR) == 0))
X {
X buf[cpos++] = c;
X eputc (c);
X ttflush ();
X }
X } /* End switch */
X
X }
X
Xdone:
X if (buf[0] == '\0')
X return (FALSE);
X return (TRUE);
X}
X
X
X/*
X* The "sp1" and "sp2" point to extended command
X* symbol table entries. The "cpos" is a horizontal position
X* in the name. Return the longest block of characters that can
X* be autocompleted at this point. Sometimes the two symbols
X* are the same, but this is normal.
X*/
Xint getxtra (sp1, sp2, cpos)
XSYMBOL * sp1;
XSYMBOL * sp2;
X{
X
X register int i;
X
X i = cpos;
X for (;;)
X {
X
X if (sp1 -> s_name[i] != sp2 -> s_name[i])
X break;
X if (sp1 -> s_name[i] == '\0')
X break;
X ++i;
X }
X
X return (i - cpos);
X}
X
X/*
X* Printf style formatting. This is
X* called by both "eprintf" and "ereply", to provide
X* formatting services to their clients. The move to the
X* start of the echo line, and the erase to the end of
X* the echo line, is done by the caller.
X*/
Xvoid eformat (fp, ap)
Xchar *fp;
Xchar *ap;
X{
X
X register int c;
X
X while ((c = *fp++) != '\0')
X {
X
X if (c != '%')
X eputc (c);
X else
X {
X
X c = *fp++;
X switch (c)
X {
X
X case 'd':
X eputi (*(int *) ap, 10);
X ap += sizeof (int);
X break;
X
X case 'x': /* krw */
X eputi (*(int *) ap, 16);
X ap += sizeof (int);
X break;
X
X case 'o':
X eputi (*(int *) ap, 8);
X ap += sizeof (int);
X break;
X
X case 's':
X eputs (ap);
X ap += sizeof (char *);
X break;
X
X default:
X eputc (c);
X }
X
X }
X
X }
X
X}
X
X
X/*
X* Put integer, in radix "r".
X*/
Xvoid eputi (i, r)
Xint i;
Xint r;
X{
X static char *convert =
X {
X MSG_hex_dig
X };
X
X
X register int q;
X
X if ((q = i / r) != 0)
X eputi (q, r);
X eputc (convert[i % r]);
X
X}
X
X
X/*
X* Put string.
X*/
Xvoid eputs (s)
Xchar *s;
X{
X register int c;
X
X while ((c = *s++) != '\0')
X eputc (c);
X}
X
X
X/*
X* Put character. Watch for
X* control characters, and for the line
X* getting too long.
X*/
Xvoid eputc (c)
Xint c;
X{
X
X if (ttcol < ncol)
X {
X
X if (ISCTRL (c) != FALSE)
X {
X
X eputc ('^');
X c ^= 0x40;
X }
X
X ttputc (c);
X ++ttcol;
X }
X
X}
X/*
X * Print warning message and wait for the user to hit a key.
X */
Xvoid err_echo (buf)
Xchar *buf;
X{
X char ch[NCOL * 2];
X
X strcpy (ch, buf);
X strcat (ch, MSG_hit_key);
X writ_echo (ch);
X ttbeep ();
X while (ttgetc () != CTL_G);
X {
X ttbeep ();
X ttflush ();
X }
X}
END_OF_FILE
if test 7152 -ne `wc -c <'echo.c'`; then
echo shar: \"'echo.c'\" unpacked with wrong size!
fi
# end of 'echo.c'
fi
if test -f 'format.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'format.c'\"
else
echo shar: Extracting \"'format.c'\" \(8612 characters\)
sed "s/^X//" >'format.c' <<'END_OF_FILE'
X/*
X* The module devines the format of the screen display.
X*/
X
X#include "def.h"
X
X
Xextern char hex_str[];
Xextern char hex_l_str[];
Xextern char octal_str[];
Xextern char octal_l_str[];
Xextern char decimal_str[];
Xextern char decimal_l_str[];
Xextern char char_str[];
X
X
X/* These structures contain the format for the displayed line */
X
X
X#define FC 13
X#define FS 0
X
Xuchar ascii_s_posn[] =
X{
X FS+0, FS+1, FS+2, FS+3, FS+4, FS+5, FS+6, FS+7, FS+8, FS+9,
X FS+10, FS+11, FS+12, FS+13, FS+14, FS+15, FS+16, FS+17, FS+18, FS+19,
X FS+20, FS+21, FS+22, FS+23, FS+24, FS+25, FS+26, FS+27, FS+28, FS+29,
X FS+30, FS+31, FS+32, FS+33, FS+34, FS+35, FS+36, FS+37, FS+38, FS+39,
X FS+40, FS+41, FS+42, FS+43, FS+44, FS+45, FS+46, FS+47, FS+48, FS+49,
X FS+50, FS+51, FS+52, FS+53, FS+54, FS+55, FS+56, FS+57, FS+58, FS+59,
X FS+60, FS+61, FS+62, FS+63, FS+64, FS+65, FS+66, FS+67, FS+68, FS+69,
X FS+70, FS+71, FS+72, FS+73, FS+74, FS+75, FS+76, FS+77, FS+78, FS+79,
X};
X
XROW_FMT text_fmt =
X{
X TEXT, BYTES, 128, 128, 128, 1, 1, FALSE, char_str, hex_l_str, hex_str,
X ascii_s_posn, 0};
X
XROW_FMT ascii_fmt =
X{
X ASCII, BYTES, 64, 64, 64, 1, 1, FALSE, char_str, hex_l_str, hex_str,
X &ascii_s_posn[FC], 0};
X
XROW_FMT ascii_s_fmt =
X{
X ASCII, BYTES, 32, 32, 1, 1, 1, FALSE, char_str, hex_l_str, hex_str,
X ascii_s_posn, 0};
X
XROW_FMT ebcdic_fmt =
X{
X EBCDIC, BYTES, 64, 64, 64, 1, 1, FALSE, char_str, hex_l_str, hex_str,
X &ascii_s_posn[FC], 0};
X
XROW_FMT ebcdic_s_fmt =
X{
X EBCDIC, BYTES, 32, 32, 1, 1, 1, FALSE, char_str, hex_l_str, hex_str,
X ascii_s_posn, 0};
X
Xuchar octal_8_posn[] =
X{
X FC, FC + 4, FC + 8, FC + 12, FC + 16, FC + 20,
X FC + 24, FC + 28, FC + 33, FC + 37, FC + 41,
X FC + 45, FC + 49, FC + 53, FC + 57, FC + 61
X};
X
XROW_FMT octal_8_fmt =
X{
X OCTAL, BYTES, 16, 16, 16, 1, 3, TRUE, octal_str, octal_l_str, octal_str,
X octal_8_posn, 0};
X
Xuchar octal_s_8_posn[] =
X{
X FS, FS + 4, FS + 8, FS + 12, FS + 16, FS + 20,
X FS + 24, FS + 28, FS + 32, FS + 36, FS + 40,
X FS + 44, FS + 48, FS + 52, FS + 56, FS + 60,
X FS + 64, FS + 68, FS + 72, FS + 76, FS + 80
X};
XROW_FMT octal_s_8_fmt =
X{
X OCTAL, BYTES, 8, 8, 1, 1, 3, TRUE, octal_str, octal_l_str, octal_str,
X octal_s_8_posn, 0};
X
Xuchar octal_16_posn[] =
X{
X FC, FC + 7, FC + 14, FC + 21, FC + 29, FC + 36, FC + 43, FC + 50
X};
X
XROW_FMT octal_16_fmt =
X{
X OCTAL, WORDS, 8, 16, 16, 2, 6, TRUE, octal_str, octal_l_str, octal_str,
X octal_16_posn, 0};
X
Xuchar octal_s_16_posn[] =
X{
X FS, FS + 7, FS + 14, FS + 21, FS + 28, FS + 35,
X FS + 42, FS + 49, FS + 56, FS + 63, FS + 70, FS + 77
X};
XROW_FMT octal_s_16_fmt =
X{
X OCTAL, WORDS, 4, 8, 2, 2, 6, TRUE, octal_str, octal_l_str, octal_str,
X octal_s_16_posn, 0};
X
Xuchar octal_32_posn[] =
X{
X FC, FC + 12, FC + 25, FC + 37
X};
X
XROW_FMT octal_32_fmt =
X{
X OCTAL, DWORDS, 4, 16, 16, 4, 11, TRUE, octal_l_str, octal_l_str, octal_str,
X octal_32_posn, 0};
X
Xuchar octal_s_32_posn[] =
X{
X FS, FS + 12, FS + 24, FS + 36, FS + 48, FS + 60, FS + 72
X};
XROW_FMT octal_s_32_fmt =
X{
X OCTAL, DWORDS, 2, 8, 4, 4, 11, TRUE, octal_l_str, octal_l_str, octal_str,
X octal_s_32_posn, };
X
XROW_FMT decimal_8_fmt =
X{
X DECIMAL, BYTES, 16, 16, 16, 1, 3, TRUE, decimal_str, decimal_l_str, decimal_str,
X octal_8_posn, 0};
X
XROW_FMT decimal_s_8_fmt =
X{
X DECIMAL, BYTES, 8, 8, 1, 1, 3, TRUE, decimal_str, decimal_l_str, decimal_str,
X octal_s_8_posn, 0};
X
Xuchar decimal_16_posn[] =
X{
X FC, FC + 6, FC + 12, FC + 18, FC + 25,
X FC + 31, FC + 37, FC + 43
X};
X
XROW_FMT decimal_16_fmt =
X{
X DECIMAL, WORDS, 8, 16, 16, 2, 5, TRUE, decimal_str, decimal_l_str, decimal_str,
X decimal_16_posn, 0};
X
Xuchar decimal_s_16_posn[] =
X{
X FS, FS + 6, FS + 12, FS + 18, FS + 24,
X FS + 30, FS + 36, FS + 42, FS + 48,
X FS + 54, FS + 60, FS + 66, FS + 72, FS + 78
X};
XROW_FMT decimal_s_16_fmt =
X{
X DECIMAL, WORDS, 4, 8, 2, 2, 5, TRUE, decimal_str, decimal_l_str, decimal_str,
X decimal_s_16_posn, 0};
X
Xuchar decimal_32_posn[] =
X{
X FC, FC + 11, FC + 23, FC + 34
X};
X
XROW_FMT decimal_32_fmt =
X{
X DECIMAL, DWORDS, 4, 16, 16, 4, 10, TRUE, decimal_l_str, decimal_l_str, decimal_str,
X decimal_32_posn, 0};
X
Xuchar decimal_s_32_posn[] =
X{
X FS, FS + 11, FS + 22, FS + 33, FS + 44, FS + 55, FS + 66, FS + 77
X};
XROW_FMT decimal_s_32_fmt =
X{
X DECIMAL, DWORDS, 4, 16, 4, 4, 10, TRUE, decimal_l_str, decimal_l_str, decimal_str,
X decimal_s_32_posn, 0};
X
Xuchar hex_8_posn[] =
X{
X FC, FC + 3, FC + 6, FC + 9, FC + 12, FC + 15,
X FC + 18, FC + 21, FC + 25, FC + 28, FC + 31,
X FC + 34, FC + 37, FC + 40, FC + 43, FC + 46,
X FC + 50, FC + 51, FC + 52, FC + 53, FC + 54,
X FC + 55, FC + 56, FC + 57, FC + 58, FC + 59,
X FC + 60, FC + 61, FC + 62, FC + 63, FC + 64,
X FC + 65
X};
X
XROW_FMT hex_8_fmt =
X{
X HEX, BYTES, 16, 16, 16, 1, 2, TRUE, hex_str, hex_l_str, hex_str,
X hex_8_posn, 0};
X
X
Xuchar hex_s_8_posn[] =
X{
X FS, FS + 3, FS + 6, FS + 9, FS + 12, FS + 15,
X FS + 18, FS + 21, FS + 24, FS + 27, FS + 30,
X FS + 33, FS + 36, FS + 39, FS + 42, FS + 45,
X FS + 48, FS + 51, FS + 54, FS + 57, FS + 60,
X FS + 63, FS + 66, FS + 69, FS + 72, FS + 75,
X FS + 78, FS + 80, FS + 80, FS + 80, FS + 80,
X FS + 80
X};
XROW_FMT hex_s_8_fmt =
X{
X HEX, BYTES, 8, 8, 1, 1, 2, TRUE, hex_str, hex_l_str, hex_str,
X hex_s_8_posn, 0};
X
Xuchar hex_16_posn[] =
X{
X FC, FC + 5, FC + 10, FC + 15, FC + 21, FC + 26, FC + 31, FC + 36
X};
X
XROW_FMT hex_16_fmt =
X{
X HEX, WORDS, 8, 16, 16, 2, 4, TRUE, hex_str, hex_l_str, hex_str,
X hex_16_posn, 0};
X
Xuchar hex_s_16_posn[] =
X{
X FS, FS + 5, FS + 10, FS + 15, FS + 20, FS + 25,
X FS + 30, FS + 35, FS + 40, FS + 45, FS + 50,
X FS + 55, FS + 60, FS + 65, FS + 70, FS + 75
X};
XROW_FMT hex_s_16_fmt =
X{
X HEX, WORDS, 8, 16, 2, 2, 4, TRUE, hex_str, hex_l_str, hex_str,
X hex_s_16_posn, 0};
X
Xuchar hex_32_posn[] =
X{
X FC, FC + 9, FC + 19, FC + 28
X};
X
XROW_FMT hex_32_fmt =
X{
X HEX, DWORDS, 4, 16, 16, 4, 8, TRUE, hex_l_str, hex_l_str, hex_str,
X hex_32_posn, 0};
X
Xuchar hex_s_32_posn[] =
X{
X FS, FS + 9, FS + 18, FS + 27, FS + 36, FS + 45, FS + 54, FS + 63, FS + 72
X};
XROW_FMT hex_s_32_fmt =
X{
X HEX, DWORDS, 4, 16, 4, 4, 8, TRUE, hex_l_str, hex_l_str, hex_str,
X hex_s_32_posn, 0};
X
XROW_FMT binary_8_fmt =
X{
X BINARY, BYTES, 4, 4, 4, 1, 8, FALSE, hex_str, hex_l_str, hex_str,
X hex_32_posn, 0}; /* use the hex position array */
X
XROW_FMT binary_s_8_fmt =
X{
X BINARY, BYTES, 4, 4, 1, 1, 8, FALSE, hex_str, hex_l_str, hex_str,
X hex_s_32_posn, 0}; /* use the hex position array */
X
Xuchar binary_16_posn[] =
X{
X FC, FC + 17, FC + 34, FC + 51
X};
X
XROW_FMT binary_16_fmt =
X{
X BINARY, WORDS, 4, 8, 8, 2, 16, FALSE, hex_str, hex_l_str, hex_str,
X binary_16_posn, 0};
X
Xuchar binary_s_16_posn[] =
X{
X FS, FS + 17, FS + 34, FS + 51, FS + 68
X};
XROW_FMT binary_s_16_fmt =
X{
X BINARY, WORDS, 2, 4, 2, 2, 16, FALSE, hex_str, hex_l_str, hex_str,
X binary_s_16_posn, 0};
X
Xuchar binary_32_posn[] =
X{
X FC, FC + 33
X};
X
XROW_FMT binary_32_fmt =
X{
X BINARY, DWORDS, 2, 8, 8, 4, 32, FALSE, hex_l_str, hex_l_str, hex_str,
X binary_32_posn, 0};
X
Xuchar binary_s_32_posn[] =
X{
X FS, FS + 33
X};
XROW_FMT binary_s_32_fmt =
X{
X BINARY, DWORDS, 1, 4, 4, 4, 32, FALSE, hex_l_str, hex_l_str, hex_str,
X binary_s_32_posn, 0};
X
X/* I must do this because C does not allow forward initialization of
X structures */
Xvoid init_fmt()
X{
X text_fmt.r_srch_fmt = &text_fmt;
X ascii_fmt.r_srch_fmt = &ascii_s_fmt;
X ascii_s_fmt.r_srch_fmt = &ascii_fmt;
X ebcdic_fmt.r_srch_fmt = &ebcdic_s_fmt;
X ebcdic_s_fmt.r_srch_fmt = &ebcdic_fmt;
X octal_8_fmt.r_srch_fmt = &octal_s_8_fmt;
X octal_s_8_fmt.r_srch_fmt = &octal_8_fmt;
X octal_16_fmt.r_srch_fmt = &octal_s_16_fmt;
X octal_s_16_fmt.r_srch_fmt = &octal_16_fmt;
X octal_32_fmt.r_srch_fmt = &octal_s_32_fmt;
X octal_s_32_fmt.r_srch_fmt = &octal_32_fmt;
X decimal_8_fmt.r_srch_fmt = &decimal_s_8_fmt;
X decimal_s_8_fmt.r_srch_fmt = &decimal_8_fmt;
X decimal_16_fmt.r_srch_fmt = &decimal_s_16_fmt;
X decimal_s_16_fmt.r_srch_fmt = &decimal_16_fmt;
X decimal_32_fmt.r_srch_fmt = &decimal_s_32_fmt;
X decimal_s_32_fmt.r_srch_fmt = &decimal_32_fmt;
X hex_8_fmt.r_srch_fmt = &hex_s_8_fmt;
X hex_s_8_fmt.r_srch_fmt = &hex_8_fmt;
X hex_16_fmt.r_srch_fmt = &hex_s_16_fmt;
X hex_s_16_fmt.r_srch_fmt = &hex_16_fmt;
X hex_32_fmt.r_srch_fmt = &hex_s_32_fmt;
X hex_s_32_fmt.r_srch_fmt = &hex_32_fmt;
X binary_8_fmt.r_srch_fmt = &binary_s_8_fmt;
X binary_s_8_fmt.r_srch_fmt = &binary_8_fmt;
X binary_16_fmt.r_srch_fmt = &binary_s_16_fmt;
X binary_s_16_fmt.r_srch_fmt = &binary_16_fmt;
X binary_32_fmt.r_srch_fmt = &binary_s_32_fmt;
X binary_s_32_fmt.r_srch_fmt = &binary_32_fmt;
X}
END_OF_FILE
if test 8612 -ne `wc -c <'format.c'`; then
echo shar: \"'format.c'\" unpacked with wrong size!
fi
# end of 'format.c'
fi
if test -f 'kbd.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'kbd.c'\"
else
echo shar: Extracting \"'kbd.c'\" \(3870 characters\)
sed "s/^X//" >'kbd.c' <<'END_OF_FILE'
X/* KBD.C
X* Terminal independent keyboard handling.
X*/
X#include "def.h"
X
Xchar *keystrings ();
X
Xextern char MSG_tab[];
Xextern char MSG_esc[];
Xextern char MSG_ctl_x[];
Xextern char MSG_ctl[];
Xextern char MSG_fn[];
Xextern char MSG_ret[];
Xextern char MSG_bksp[];
Xextern char MSG_space[];
Xextern char MSG_rubout[];
X
X
X/*
X* Read in a key, doing the terminal
X* independent prefix handling. The terminal specific
X* "getkbd" routine gets the first swing, and may return
X* one of the special codes used by the special keys
X* on the keyboard. The "getkbd" routine returns the
X* C0 controls as received; this routine moves them to
X* the right spot in 11 bit code.
X*/
Xint getkey ()
X{
X
X register int c;
X c = getkbd ();
X if (c == METACH) /* M- */
X {
X c = KMETA | getctl ();
X#ifdef VT100KEY
X if ((c & KCHAR) == '[')
X c = KMETA | KCTRL | KCTLX | getctl (); /* flag VT100 sequence */
X#endif
X }
X else if (c == CTRLCH) /* C- */
X c = KCTRL | getctl ();
X else if (c == CTMECH) /* C-M- */
X c = KCTRL | KMETA | getctl ();
X else if (c >= 0x00 && c <= 0x1F)/* Relocate control. */
X c = KCTRL | (c + '@');
X
X if (c == (KCTRL | 'X')) /* C-X */
X c = KCTLX | getctl ();
X return (c);
X}
X
X
X/*
X* Used above.
X*/
Xint getctl ()
X{
X
X register int c;
X
X#if 1
X c = getkbd ();
X if (c == METACH) /* M- */
X c = KMETA | getctl ();
X else
X if (c == CTRLCH) /* C- */
X c = KCTRL | getctl ();
X else
X if (c == CTMECH) /* C-M- */
X c = KCTRL | KMETA | getctl ();
X else
X if (c >= 0x00 && c <= 0x1F)/* Relocate control. */
X c = KCTRL | (c + '@');
X#else
X c = getkey (); /* Note recursion */
X if (ISLOWER (c & 0xFF))
X c = (c & ~0xFF) | TOUPPER (c & 0xFF);
X if (c >= 0x00 && c <= 0x1F) /* Relocate control. */
X c = KCTRL | (c + '@');
X#endif
X if (ISLOWER (c & 0xFF))
X c = (c & ~0xFF) | TOUPPER (c & 0xFF);
X return (c);
X}
X
X
X/*
X* Transform a key code into a name,
X* using a table for the special keys and combination
X* of some hard code and some general processing for
X* the rest. None of this code is terminal specific any
X* more. This makes adding keys easier.
X*/
Xvoid keyname (cp, k)
Xregister char *cp;
Xregister int k;
X{
X register char *np;
X char nbuf[3];
X
X static char hex[] =
X {
X '0', '1', '2', '3',
X '4', '5', '6', '7',
X '8', '9', 'A', 'B',
X 'C', 'D', 'E', 'F'
X };
X *cp = 0; /* terminate previous string */
X#ifdef VT100KEY
X if ((k & (KMETA | KCTRL | KCTLX)) == (int)(KMETA | KCTRL | KCTLX))
X {
X sprintf (&cp[strlen (cp)], MSG_fn);
X sprintf (&cp[strlen (cp)], "%c", k & KCHAR);
X return;
X }
X#endif
X if (k & 0x80)
X {
X if ((np = keystrings (k)) != NULL)
X {
X if ((k & KMETA) != 0)
X sprintf (&cp[strlen (cp)], MSG_esc);
X
X strcat (cp, np);
X }
X else
X cp[strlen (cp)] = 0; /* null string */
X return;
X }
X
X if ((k & KCTLX) != 0)
X {
X /* Ctl-X prefix. */
X sprintf (&cp[strlen (cp)], MSG_ctl_x);
X k &= ~KCTLX;
X }
X
X if ((k & KMETA) != 0)
X {
X /* Add Esc- mark. */
X sprintf (&cp[strlen (cp)], MSG_esc);
X k &= ~KMETA;
X }
X
X if (k == (KCTRL | 'I'))/* Some specials. */
X np = MSG_tab;
X else
X {
X if (k == (KCTRL | 'M'))
X np = MSG_ret;
X else if (k == (KCTRL | 'H'))
X np = MSG_bksp;
X else if (k == ' ')
X np = MSG_space;
X else if (k == 0x7F)
X np = MSG_rubout;
X else
X {
X if ((k & KCTRL) != 0)
X {
X /* Add Ctl- mark. */
X sprintf (&cp[strlen (cp)], MSG_ctl);
X }
X np = &nbuf[0];
X if (((k & KCHAR) >= 0x20 && (k & KCHAR) <= 0x7E)
X || ((k & KCHAR) >= 0xA0 && (k & KCHAR) <= 0xFE))
X {
X nbuf[0] = k & KCHAR;/* Graphic. */
X nbuf[1] = 0;
X }
X else
X {
X /* Non graphic. */
X nbuf[0] = hex[(k >> 4) & 0x0F];
X nbuf[1] = hex[k & 0x0F];
X nbuf[2] = 0;
X }
X }
X }
X strcat (cp, np);
X}
X
END_OF_FILE
if test 3870 -ne `wc -c <'kbd.c'`; then
echo shar: \"'kbd.c'\" unpacked with wrong size!
fi
# end of 'kbd.c'
fi
if test -f 'prototyp.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'prototyp.h'\"
else
echo shar: Extracting \"'prototyp.h'\" \(8685 characters\)
sed "s/^X//" >'prototyp.h' <<'END_OF_FILE'
Xextern char *flook(char *fname,int hflag);
Xextern char *keystrings(int key);
Xextern char addline(char *text);
Xextern char anycb(void );
Xextern char asciimode(void );
Xextern char autosave(void );
Xextern char backchar(int f,int n,int k);
Xextern char backdel(int f,int n,int k);
Xextern char backline(int f,int n,int k);
Xextern char backpage(int f,int n,int k);
Xextern char backsearch(void );
Xextern char backsrch(void );
Xextern char backunit(int f,int n,int k);
Xextern char bclear(struct BUFFER *bp);
Xextern char binarymode(void );
Xextern char bindtokey(void );
Xextern char buffername(void );
Xextern char bufsizlock(void );
Xextern char b_append_c(struct BUFFER *buf_p,unsigned char ch);
Xextern char compare(void );
Xextern char copyregion(int f,int n,int k);
Xextern char ctlxe(int f,int n,int k);
Xextern char ctlxlp(int f,int n,int k);
Xextern char ctlxrp(int f,int n,int k);
Xextern char ctrlg(int f,int n,int k);
Xextern char decimalmode(void );
Xextern char dec_chr_ok(char *char_buf,char *max_str,char chr,char pos);
Xextern char delbunit(int f,int n,int k);
Xextern char delfunit(int f,int n,int k);
Xextern char delwind(void );
Xextern char dispshift(int f,int n,int k);
Xextern char dispsize1(void );
Xextern char dispsize2(void );
Xextern char dispsize4(void );
Xextern char dispswapbyte(int f,int n,int k);
Xextern char ebcdicmode(void );
Xextern char enlargewind(int f,int n,int k);
Xextern char eread(char *fp,char *buf,int nbuf,int flag,char *ap);
Xextern char ereply(char *fp,char *buf,int nbuf,char *arg);
Xextern char execute(int c,int f,int n);
Xextern char extend(int f,int n,int k);
Xextern char eyesno(char *sp);
Xextern char fbackupfile(char *fname);
Xextern char ffclose(void );
Xextern char ffgetline(char *buf,unsigned int nbuf,unsigned int *rbuf);
Xextern char ffputline(char *buf,int nbuf);
Xextern char ffropen(char *fn);
Xextern char ffwopen(char *fn,unsigned short mode);
Xextern char fileinsert(void );
Xextern char filename(void );
Xextern char fileread(void );
Xextern char filesave(void );
Xextern char filevisit(void );
Xextern char filewrite(void );
Xextern char file_visit(int f,int n,int k);
Xextern char fill_out(void );
Xextern char flushnquit(int f,int n,int k);
Xextern char flush_all(void );
Xextern char forwchar(int f,int n,int k);
Xextern char forwdel(int f,int n,int k);
Xextern char forwline(int f,int n,int k);
Xextern char forwpage(int f,int n,int k);
Xextern char forwsearch(void );
Xextern char forwsrch(void );
Xextern char forwunit(int f,int n,int k);
Xextern char getregion(struct reg *rp);
Xextern char getscreenstate(void );
Xextern char gotobob(void );
Xextern char gotoeob(void );
Xextern char gotoline(int f,int n,int k);
Xextern char help(void );
Xextern char hexmode(void );
Xextern char insertunit(int f,int n,int k);
Xextern char insert_toggle(void );
Xextern char killablebufs(struct BUFFER *bp);
Xextern char killbuffer(void );
Xextern char killregion(int f,int n,int k);
Xextern char ldelete(unsigned long n_bytes,int kflag);
Xextern char linkwind(void );
Xextern char linsert(int n,unsigned char c);
Xextern char listbuffers(void );
Xextern char load_extend(void );
Xextern char load_file(char *fname,unsigned long start,unsigned long end);
Xextern char lrepl_str(int plen,struct LINE *rstr,struct LINE *mstr);
Xextern char makelist(void );
Xextern char move_ptr(struct WINDOW *wp,long len,char dot,char fix,char rel);
Xextern char mvdnwind(int f,int n,int k);
Xextern char mvupwind(int f,int n,int k);
Xextern char nextwind(void );
Xextern char next_buf(void );
Xextern char n_way_combine(int f,int n,int k);
Xextern char n_way_split(int f,int n,int k);
Xextern char octalmode(void );
Xextern char onebuf(struct BUFFER *bp);
Xextern char onlywind(void );
Xextern char parse_f_name(char *fn,unsigned long *start,unsigned long *end);
Xextern char pickone(void );
Xextern char popblist(void );
Xextern char prevwind(void );
Xextern char prev_buf(void );
Xextern char print(void );
Xextern char queryrepl(int f,int n,int k);
Xextern char quit(int f,int n,int k);
Xextern char quote(int f,int n,int k);
Xextern char readin(char *fname,unsigned long start,unsigned long end);
Xextern char readpattern(void );
Xextern char recall(void );
Xextern char refresh(void );
Xextern char replaceit(void );
Xextern char reposition(void );
Xextern char save_region(int f,int n,int k);
Xextern char searchagain(void );
Xextern char selfinsert(int f,int n,int k);
Xextern char setmark(void );
Xextern char showcpos(int f,int n,int k);
Xextern char showsavebuf(void );
Xextern char showversion(int f,int n,int k);
Xextern char shrinkwind(int f,int n,int k);
Xextern char spawncli(int f,int n,int k);
Xextern char splitwind(void );
Xextern char swapmark(void );
Xextern char to_ebcdic(char ch);
Xextern char twiddle(void );
Xextern char usebuffer(void );
Xextern char use_buffer(void );
Xextern char viewfile(void );
Xextern char vtputd(struct WINDOW *wp,int row);
Xextern char wallchart(int f,int n,int k);
Xextern char wind_on_dot(struct WINDOW *wp);
Xextern char writeout(char *fn,unsigned long start,unsigned long end,unsigned short mode);
Xextern char yank(int f,int n,int k);
Xextern char yank_buffer(void );
Xextern char _killbuffer(char *bufn);
Xextern char _usebuffer(char *bufn);
Xextern char _yankbuffer(char *bufn);
Xextern int find_keyval(char *name);
Xextern int getctl(void );
Xextern int getkbd(void );
Xextern int getkey(void );
Xextern int getsysconfig(union REGS *outregs,struct SREGS *segregs);
Xextern int getxtra(struct SYMBOL *sp1,struct SYMBOL *sp2,int cpos);
Xextern int symhash(char *cp);
Xextern int ttgetc(void );
Xextern int ttkeyready(void );
Xextern struct BUFFER *bcreate(char *bname);
Xextern struct BUFFER *bfind(char *bname,int cflag);
Xextern struct LINE *lalloc(int size);
Xextern struct LINE *l_break_in_two(struct LINE *lp,unsigned int lo,unsigned int extra);
Xextern struct SYMBOL *symlookup(char *cp);
Xextern struct WINDOW *wpopup(void );
Xextern unsigned int fill_buf(struct WINDOW *wp,struct LINE *lin,unsigned int lin_off,char *w_buff,unsigned int cnt);
Xextern unsigned int get_curcol(struct WINDOW *wp);
Xextern unsigned int get_currow(struct WINDOW *wp);
Xextern unsigned long ffseek(unsigned long posn);
Xextern unsigned long file_len(void );
Xextern unsigned long get_long(unsigned char *w_buf);
Xextern unsigned short get_int(unsigned char *w_buf);
Xextern unsigned short get_save_char(void );
Xextern void adjustcase(char *fn);
Xextern void asciiparm(int n);
Xextern void bad_key(int key);
Xextern void bin_to_text(char *bin_buf,char *txt_buf,unsigned int len,struct ROW_FMT *fmt_ptr);
Xextern void b_append_l(struct BUFFER *buf_p,struct LINE *lp);
Xextern void check_extend(char *sfname);
Xextern void edinit(char *bname);
Xextern void eerase(void );
Xextern void eformat(char *fp,char *ap);
Xextern void eputc(int c);
Xextern void eputi(int i,int r);
Xextern void eputs(char *s);
Xextern void err_echo(char *buf);
Xextern void funky_name(char *bname,int n);
Xextern void is_wang(void );
Xextern void keyadd(int new,char (*funcp)(),char *name,int modify);
Xextern void keydup(int new,char *name);
Xextern void keymapinit(void );
Xextern void keyname(char *cp,int k);
Xextern void lchange(int flag);
Xextern void lfree(struct LINE *lp);
Xextern void lreplace(int n,char c);
Xextern void l_fix_up(struct LINE *line);
Xextern void main(int argc,char * *argv);
Xextern void makename(char *bname,char *fname);
Xextern void mem_line(int row,struct vid *vvp);
Xextern void modeline(struct WINDOW *wp);
Xextern void next_pat(void );
Xextern void putline(int row,int startcol,int stringsize,char *string);
Xextern void save_buf_home(void );
Xextern void save_buf_init(void );
Xextern void set_crt_type(void );
Xextern void set_mode_vars(void );
Xextern void sort_buf(struct BUFFER *b_ptr,int cnt);
Xextern void ttbeep(void );
Xextern void ttclose(void );
Xextern void ttcolor(int color);
Xextern void ttcooked(void );
Xextern void tteeol(void );
Xextern void tteeop(void );
Xextern void ttflush(void );
Xextern void ttinit(void );
Xextern void ttmove(int row,int col);
Xextern void ttnowindow(void );
Xextern void ttopen(void );
Xextern void ttputc(int c);
Xextern void ttraw(void );
Xextern void tttidy(void );
Xextern void ttykeymapinit(void );
Xextern void ucopy(struct vid *vvp,struct vid *pvp);
Xextern void uline(int row,struct vid *vvp,struct vid *pvp);
Xextern void ungetkey(int k);
Xextern void update(void );
Xextern void vteeol(void );
Xextern void vtinit(void );
Xextern void vtmove(int row,int col);
Xextern void vtputc(char c);
Xextern void vttidy(void );
Xextern void wind_on_dot_all(void );
Xextern void writ_echo(char *buf);
Xextern void _lowercase(char *s);
END_OF_FILE
if test 8685 -ne `wc -c <'prototyp.h'`; then
echo shar: \"'prototyp.h'\" unpacked with wrong size!
fi
# end of 'prototyp.h'
fi
if test -f 'region.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'region.c'\"
else
echo shar: Extracting \"'region.c'\" \(4265 characters\)
sed "s/^X//" >'region.c' <<'END_OF_FILE'
X/*
X* Region based commands.
X* The routines in this file
X* deal with the region, that magic space
X* between "." and mark. Some functions are
X* commands. Some functions are just for
X* internal use.
X*/
X#include "def.h"
X
Xbool getregion ();
X
Xextern char MSG_sv_in_b[];
Xextern char MSG_sav_slf[];
Xextern char MSG_no_mark[];
Xextern char MSG_procing[];
X
Xextern BUFFER sav_buf;
X
X/*
X* Kill the region. Ask "getregion"
X* to figure out the bounds of the region.
X* Move "." to the start, and kill the characters.
X*/
Xchar killregion (f, n, k)
X{
X register char s;
X REGION region;
X int error;
X
X if ((s = getregion (®ion)) != TRUE)
X return (s);
X if ((lastflag & CFKILL) == 0)/* This is a kill type */
X bclear (&sav_buf);
X thisflag |= CFKILL; /* kill buffer stuff. */
X curwp -> w_dotp = region.r_linep;
X curwp -> w_doto = region.r_offset;
X error = ldelete (region.r_size, TRUE);
X lchange (WFHARD);
X /* cause the save buffer display to be updated if needed */
X if (sav_buf.b_nwnd != 0)
X showsavebuf ();
X writ_echo (okmsg);
X return (error);
X}
X
X
X/*
X* Copy all of the characters in the
X* region to the kill buffer. Don't move dot
X* at all. This is a bit like a kill region followed
X* by a yank.
X*/
Xchar copyregion (f, n, k)
X{
X register LINE * linep;
X register int loffs, j;
X register char s;
X REGION region;
X char buf[NCOL], buf1[NCOL];
X
X j = 0;
X if ((s = getregion (®ion)) != TRUE)
X return (s);
X if ((lastflag & CFKILL) == 0)/* Kill type command. */
X bclear (&sav_buf);
X thisflag |= CFKILL;
X linep = region.r_linep; /* Current line. */
X loffs = region.r_offset; /* Current offset. */
X while (region.r_size--)
X {
X if ((s = b_append_c (&sav_buf, lgetc (linep, loffs))) != TRUE)
X return (s);
X ++loffs;
X if ((j++ & 0x2ff) == 0)
X {
X sprintf (buf1, MSG_procing, R_POS_FMT(curwp));
X sprintf (buf, buf1, DOT_POS (curwp));
X writ_echo (buf);
X /* check if we should quit */
X if (ttkeyready ())
X {
X wind_on_dot_all();
X if (ttgetc () == '*')
X return (FALSE);
X }
X }
X }
X /* cause the save buffer display to be updated if needed */
X if (sav_buf.b_nwnd != 0)
X showsavebuf ();
X /* update buffer display */
X if ((blistp -> b_nwnd != 0) &&
X (blistp -> b_type == BTLIST))
X listbuffers ();
X writ_echo (okmsg);
X return (TRUE);
X}
X
X/*
X* This routine figures out the bound of the region
X* in the current window, and stores the results into the fields
X* of the REGION structure. Dot and mark are usually close together,
X* but I don't know the order. The size is kept in a long. At the
X* end, after the size is figured out, it is assigned to the size
X* field of the region structure. If this assignment loses any bits,
X* then we print an error. This is "type independent" overflow
X* checking. All of the callers of this routine should be ready to
X* get an ABORT status, because I might add a "if regions is big,
X* ask before clobberring" flag.
X*/
Xbool getregion (rp)
Xregister REGION * rp;
X{
X if (curwp -> w_markp == NULL)
X {
X writ_echo (MSG_no_mark);
X return (FALSE);
X }
X
X if (DOT_POS(curwp) < MARK_POS(curwp))
X {
X rp -> r_linep = curwp -> w_dotp;
X rp -> r_offset = curwp -> w_doto;
X rp -> r_size = MARK_POS(curwp) - DOT_POS(curwp);
X }
X else
X {
X rp -> r_linep = curwp -> w_markp;
X rp -> r_offset = curwp -> w_marko;
X rp -> r_size = DOT_POS(curwp) - MARK_POS(curwp);
X }
X return (TRUE);
X}
X
X/* save some region in a buffer
X* (use _usebuffer to handle non-existent buffers)
X*
X* hack as it uses kill buffer to transfer stuff (quick and dirty!)
X* and doesn't do clever things at all with dot in destination buffer!
X*/
Xchar save_region (f, n, k)
X{
X char bufn[NBUFN];
X char oldbufn[NBUFN];
X register char s;
X
X if ((s = ereply (MSG_sv_in_b, bufn, NBUFN, NULL)) != TRUE)
X return (s);
X
X if (strcmp (bufn, curbp -> b_bname) == 0)
X {
X writ_echo (MSG_sav_slf);
X return (FALSE);
X }
X
X /* save this name for ughly reversal */
X strcpy (oldbufn, curbp -> b_bname);
X
X /* copy stuff using killbuffer as work space - hack !! * than move it to
X named place using yank - Quick AND Dirty */
X copyregion (f, n, k);
X _usebuffer (bufn);
X curbp -> b_type = BTSAVE; /* mark as a saved buffer */
X
X yank (f, n, k);
X _usebuffer (oldbufn);
X writ_echo (okmsg);
X return (TRUE);
X}
X
X
END_OF_FILE
if test 4265 -ne `wc -c <'region.c'`; then
echo shar: \"'region.c'\" unpacked with wrong size!
fi
# end of 'region.c'
fi
if test -f 'tcap.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'tcap.c'\"
else
echo shar: Extracting \"'tcap.c'\" \(2839 characters\)
sed "s/^X//" >'tcap.c' <<'END_OF_FILE'
X/* tcap: Unix V5, V7 and BS4.2 Termcap video driver
X for beav
X*/
X
X#include "def.h"
X
X#ifdef UNIX
X
X#define MARGIN 8
X#define SCRSIZ 64
X#define NPAUSE 10 /* # times thru update to pause */
X#define BEL 0x07
X#define ESC 0x1B
X
Xextern char *tgoto();
X
X#ifdef NOPROTO
Xextern int ttputc();
Xvoid putpad();
X#endif
X
X#ifdef COLOR
Xextern int tcapfcol();
Xextern int tcapbcol();
X#endif
X
X#define TCAPSLEN 315
Xchar tcapbuf[TCAPSLEN];
Xchar *UP, PC, *CM, *CE, *CL, *SO, *SE;
X
X#ifdef BSD
X#include <sys/ioctl.h>
Xstruct ttysize ttysize;
X#endif /* BSD */
X#ifdef ULTRIX
Xstruct ttysize ttysize;
X#endif
X
Xvoid putpad(str)
Xchar *str;
X{
X tputs(str, 1, ttputc);
X}
X
Xvoid tcapopen()
X{
X char *getenv();
X char *t, *p, *tgetstr();
X char tcbuf[1024];
X char *tv_stype;
X char err_str[NCOL];
X#ifdef ULTRIX
X struct winsize ttysize;
X#endif
X
X if ((tv_stype = getenv("TERM")) == NULL)
X {
X puts("Environment variable TERM not defined!\r");
X ttclose();
X exit(1);
X }
X
X if ((tgetent(tcbuf, tv_stype)) != 1)
X {
X sprintf(err_str, "Unknown terminal type %s!\r", tv_stype);
X puts(err_str);
X ttclose(); /* fix in 1.13 */
X exit(1);
X }
X
X
X#ifdef BSD
X#ifdef ULTRIX
X if (ioctl(0, TIOCGWINSZ, &ttysize) == 0
X && ttysize.ws_row > 0) {
X nrow = ttysize.ws_row;
X } else
X#else
X if (ioctl(0, TIOCGSIZE, &ttysize) == 0
X && ttysize.ts_lines > 0) {
X nrow = ttysize.ts_lines;
X }
X else
X#endif /* ULTRIX */
X#endif /* BSD */
X if ((nrow=(short)tgetnum("li")-1) == -1){
X puts("termcap entry incomplete (lines)\r");
X ttclose(); /* fix in 1.13 */
X exit(1);
X }
X printf ("nrow %d, ncol %d\n", nrow, ncol);
X /* don't allow to specify a larger number of rows than we can handle 1.13 */
X if (nrow > NROW)
X nrow = NROW;
X
X if ((ncol=(short)tgetnum("co")) == -1){
X puts("Termcap entry incomplete (columns)\r");
X ttclose(); /* fix in 1.13 */
X exit(1);
X }
X /* don't allow to specify a larger number of cols than we can handle 1.13 */
X if (ncol > NCOL)
X ncol = NCOL;
X
X p = tcapbuf;
X t = tgetstr("pc", &p);
X if(t)
X PC = *t;
X
X CL = tgetstr("cl", &p);
X CM = tgetstr("cm", &p);
X CE = tgetstr("ce", &p);
X UP = tgetstr("up", &p);
X SE = tgetstr("se", &p);
X SO = tgetstr("so", &p);
X
X if(CL == NULL || CM == NULL || UP == NULL)
X {
X puts("Incomplete termcap entry\r");
X ttclose(); /* fix in 1.13 */
X exit(1);
X }
X
X if (p >= &tcapbuf[TCAPSLEN])
X {
X puts("Terminal description too big!\r");
X ttclose(); /* fix in 1.13 */
X exit(1);
X }
X}
X
Xvoid tcapmove(row, col)
Xregister int row, col;
X{
X putpad(tgoto(CM, col, row));
X}
X
Xvoid tcapeeol()
X{
X putpad(CE);
X}
X
Xvoid tcapeeop()
X{
X putpad(CL);
X}
X
Xvoid tcaprev(state) /* change reverse video status */
Xint state; /* FALSE = normal video, TRUE = reverse video */
X
X{
X if (state) {
X if (SO != NULL)
X putpad(SO);
X } else
X if (SE != NULL)
X putpad(SE);
X}
X
Xvoid putnpad(str, n)
Xchar *str;
X{
X tputs(str, n, ttputc);
X}
X
X#endif
END_OF_FILE
if test 2839 -ne `wc -c <'tcap.c'`; then
echo shar: \"'tcap.c'\" unpacked with wrong size!
fi
# end of 'tcap.c'
fi
if test -f 'tty.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'tty.c'\"
else
echo shar: Extracting \"'tty.c'\" \(4528 characters\)
sed "s/^X//" >'tty.c' <<'END_OF_FILE'
X/*
X* Wang PC terminal display TTY.C
X*
X*/
X#include "def.h"
X
Xvoid ttinit ();
Xvoid tttidy ();
Xvoid ttmove ();
Xvoid tteeol ();
Xvoid tteeop ();
Xvoid ttbeep ();
Xvoid asciiparm ();
Xvoid ttnowindow (); /* stub */
Xvoid ttcolor ();
Xextern void tcapopen ();
Xextern void tcapmove ();
X
X#ifdef MSDOS
X#include "dos.h"
Xextern bool ibm_pc, mem_map;
X#endif
X#define BEL 0x07 /* BEL character. */
X#define ESC 0x1B /* ESC character. */
X
Xextern int ttrow;
Xextern int ttcol;
Xextern int tttop;
Xextern int ttbot;
Xextern int tthue;
X
Xint tceeol = 3; /* Costs. */
Xint rowb = NROW;
X
X/*
X* Initialize the terminal when the editor
X* gets started up.
X*/
Xvoid ttinit ()
X{
X#ifdef MSDOS
X ttraw ();
X#endif
X#ifdef UNIX
X tcapopen();
X#endif
X}
X
X/*
X* Clean up the terminal, in anticipation of
X* a return to the command interpreter.
X*/
Xvoid tttidy ()
X{
X#ifdef MSDOS
X ttcooked ();
X#endif
X}
X
X/*
X* Move the cursor to the specified
X* origin 0 row and column position. Try to
X* optimize out extra moves; redisplay may
X* have left the cursor in the right
X* location last time!
X*/
Xvoid ttmove (row, col)
X{
X#ifdef MSDOS
X union REGS regs;
X
X /* Move in both axes */
X if (ibm_pc)
X {
X regs.h.ah = 2;
X regs.h.dh = (char)row;
X regs.h.dl = (char)col;
X regs.h.bh = 0;
X int86 (0x10, ®s, ®s); /* set cursor position */
X }
X else
X#endif
X#ifdef UNIX
X tcapmove(row, col);
X#endif
X#ifdef ANSI
X {
X ttputc (ESC);
X ttputc ('[');
X asciiparm (row + 1);
X ttputc (';');
X asciiparm (col + 1);
X ttputc ('H');
X }
X#endif
X ttrow = row;
X ttcol = col;
X}
X
X/*
X* Erase to end of line.
X*/
Xvoid tteeol ()
X{
X char col, row, i;
X#ifdef MSDOS
X union REGS regs;
X
X if (ibm_pc)
X {
X regs.h.ah = 3;
X regs.h.bh = 0;
X int86 (0x10, ®s, ®s); /* get cursor position */
X col = regs.h.dl;
X row = regs.h.dh;
X for (i = col ; i < (NCOL - 1); i++)
X {
X regs.h.ah = 0x0e;
X regs.h.bl = 0;
X regs.h.bh = 0;
X regs.h.al = ' ';
X int86 (0x10, ®s, ®s); /* set cursor position */
X }
X /* put cursor back to original position */
X regs.h.ah = 2;
X regs.h.bh = 0;
X regs.h.dl = col;
X regs.h.dh = row;
X int86 (0x10, ®s, ®s); /* get cursor position */
X }
X else
X#endif
X#ifdef ANSI
X {
X ttputc (ESC);
X ttputc ('[');
X#ifdef MSDOS
X if (ibm_pc)
X ttputc ('0'); /* this is necessary in IBM PC's */
X#endif
X ttputc ('K');
X }
X#endif
X#ifdef UNIX
X tcapeeol();
X#endif
X}
X
X/*
X* Erase to end of page.
X* only ever used when cursor is at 0,0, so IBM screen erase
X* is same as eop
X*/
Xvoid tteeop ()
X{
X#ifdef MSDOS
X union REGS regs;
X char i, j;
X
X if (ibm_pc)
X {
X for (j = 0 ; j < nrow; j++)
X {
X for (i = 0 ; i < NCOL; i++)
X {
X regs.h.ah = 0x0e;
X regs.h.bl = 0;
X regs.h.bh = 0;
X regs.h.al = ' ';
X int86 (0x10, ®s, ®s); /* set cursor position */
X }
X }
X }
X else
X#endif
X#ifdef ANSI
X {
X ttcolor (CTEXT);
X ttputc (ESC);
X ttputc ('[');
X#ifdef MSDOS
X if (ibm_pc)
X ttputc ('0');
X else
X#endif
X ttputc ('2');
X ttputc ('J');
X }
X#endif
X#ifdef UNIX
X tcapeeop();
X#endif
X}
X
X/*
X* Make a noise.
X*/
Xvoid ttbeep ()
X{
X ttputc (BEL);
X ttflush ();
X}
X
X/*
X* Convert a number to decimal
X* ascii, and write it out. Used to
X* deal with numeric arguments.
X*/
Xvoid asciiparm (n)
Xregister int n;
X{
X register int q;
X
X q = n / 10;
X if (q != 0)
X asciiparm (q);
X ttputc ((n % 10) + '0');
X}
X
X/*
X* Switch to full screen scroll. This is
X* used by "spawn.c" just before is suspends the
X* editor, and by "display.c" when it is getting ready
X* to exit. This is a no-op.
X*/
Xvoid ttnowindow (){
X}
X
X/*
X* Set the current writing color to the
X* specified color. Watch for color changes that are
X* not going to do anything (the color is already right)
X* and don't send anything to the display.
X*/
Xvoid ttcolor (color)
Xregister int color;
X{
X#ifdef MSDOS
X if (mem_map)
X {
X tthue = color; /* Save the color. */
X return;
X }
X#endif
X#ifdef UNIX
X if (color == CTEXT)
X tcaprev (FALSE);
X else
X tcaprev (TRUE);
X tthue = color; /* Save the color. */
X#endif
X#ifdef ANSI
X if (color != tthue)
X {
X if (color == CTEXT)
X { /* Normal video. */
X ttputc (ESC);
X ttputc ('[');
X ttputc ('0');
X ttputc ('m');
X }
X else
X if (color == CMODE)
X { /* Reverse video. */
X ttputc (ESC);
X ttputc ('[');
X ttputc ('7');
X ttputc ('m');
X }
X tthue = color; /* Save the color. */
X }
X#endif
X}
END_OF_FILE
if test 4528 -ne `wc -c <'tty.c'`; then
echo shar: \"'tty.c'\" unpacked with wrong size!
fi
# end of 'tty.c'
fi
if test -f 'wangpc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'wangpc.c'\"
else
echo shar: Extracting \"'wangpc.c'\" \(3001 characters\)
sed "s/^X//" >'wangpc.c' <<'END_OF_FILE'
X#include "def.h"
X#if MSDOS
X#include "dos.h"
X
Xtypedef struct SCREENINFO
X{
X unsigned char state;
X unsigned char scanoff;
X unsigned short bufseg;
X unsigned char colors;
X unsigned char row;
X unsigned char col;
X unsigned char attr;
X unsigned char auxmod;
X unsigned char auxmod2;
X} SCREENINFO;
X
Xtypedef struct SYSCONFIG
X{
X unsigned short version;
X unsigned short memsize;
X unsigned short reserved[2];
X unsigned short screen_count;
X unsigned short screens[4];
X} SYSCONFIG;
X
X#define SENDCHAR 6
X#define SENDLINE 0x0d
X#define BIOS 0x88
X#define GETSYSCON 1
X
Xbool wang_pc = FALSE;
Xbool ibm_pc = FALSE;
Xbool mem_map = FALSE;
X
Xvoid is_wang ()
X{
X union REGS inregs, outregs;
X struct SREGS segregs;
X unsigned char *memptr;
X unsigned char c;
X int i;
X static char wang_id[] = {
X "WANG" };
X static char ret_str[6];
X char *chr_ptr;
X
X chr_ptr = ret_str;
X /* test for Wang PC */
X memptr = (unsigned char *)0xFC003FC2L;
X wang_pc = TRUE;
X for (i=0;(i<4 && wang_pc);i++)
X {
X if(*memptr != wang_id[i])
X wang_pc = FALSE;
X memptr++;
X }
X
X if (wang_pc)
X {
X mem_map = TRUE;
X ret_str[0] = 0xFF; /* set to known value */
X mem_map = TRUE;
X inregs.h.al = 0x02;
X inregs.h.ah = 0x44;
X inregs.x.bx = 0;
X inregs.x.cx = 1;
X inregs.x.dx = FP_OFF (chr_ptr);
X segregs.ds = FP_SEG (chr_ptr);
X
X int86x (0x21, &inregs, &outregs, &segregs);
X if (ret_str[0] == 0x11)
X {
X ibm_pc = TRUE;
X return;
X }
X ibm_pc = FALSE;
X return;
X }
X
X /* Must be an IBM or clone */
X memptr = (unsigned char *)0xF000FFFEL;
X c = *memptr;
X switch(c)
X {
X case 0xFC: /* IBM AT or clone */
X case 0xFD: /* IBM PC Jr */
X case 0xFE: /* IBM XT or clone */
X case 0xFF: /* IBM PC or clone */
X mem_map = TRUE;
X ibm_pc = TRUE;
X return;
X }
X}
X
Xint getsysconfig (outregs, segregs)
Xunion REGS * outregs;
Xstruct SREGS *segregs;
X{
X union REGS inregs;
X
X inregs.h.al = GETSYSCON;
X
X int86x (BIOS, &inregs, outregs, segregs);
X}
X
Xchar getscreenstate ()
X{
X struct SREGS segregs;
X union REGS outregs;
X
X struct SYSCONFIG *config;
X struct SCREENINFO *screeninfo;
X unsigned short *shortptr;
X unsigned int screen_count;
X
X getsysconfig (&outregs, &segregs);
X
X /* set pointer to force register info into a long pointer. */
X shortptr = (unsigned short *) & config;
X
X /* Offset is first, it comes back in BX */
X *shortptr = (unsigned short) outregs.x.bx;
X shortptr++;
X
X /* segment is in ES */
X *shortptr = (unsigned short) segregs.es;
X
X /* Now, the config pointer should be set to the config table. */
X /* printf("Version = %04x \n",config->version);
X printf("Memsize = %04x \n",config->memsize);
X printf("Screens = %04x \n",config->screen_count);
X*/
X screen_count = config -> screen_count;
X while (screen_count)
X {
X shortptr = (unsigned short *) & screeninfo;
X *shortptr = (unsigned short) config -> screens[screen_count - 1];
X shortptr++;
X *shortptr = (unsigned short) segregs.es;
X if (screeninfo -> state & 0x80)
X break;
X screen_count--;
X }
X return (screeninfo -> state);
X}
X#endif
END_OF_FILE
if test 3001 -ne `wc -c <'wangpc.c'`; then
echo shar: \"'wangpc.c'\" unpacked with wrong size!
fi
# end of 'wangpc.c'
fi
if test -f 'word.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'word.c'\"
else
echo shar: Extracting \"'word.c'\" \(2711 characters\)
sed "s/^X//" >'word.c' <<'END_OF_FILE'
X/*
X* Word mode commands.
X* The routines in this file
X* implement commands that work unit at
X* a time. There are all sorts of unit mode
X* commands. If I do any sentence and/or paragraph
X* mode commands, they are likely to be put in
X* this file.
X*/
X#include "def.h"
X
Xextern BUFFER sav_buf;
Xchar forwunit ();
X
X/*
X* Move the cursor backward by
X* "n" units. All of the details of motion
X* are performed by the "backchar" and "forwchar"
X* routines. Error if you try to move beyond
X* the buffers.
X*/
Xchar backunit (f, n, k)
X{
X char ret;
X
X if (n < 0)
X return (forwunit (f, -n, KRANDOM));
X
X curwp -> w_unit_offset = 0;
X while (n--)
X {
X ret = move_ptr (curwp, -(long)R_B_PER_U(curwp), TRUE, TRUE, TRUE);
X }
X wind_on_dot (curwp);
X curwp -> w_flag |= WFMODE; /* update mode line */
X return (ret);
X}
X
X
X/*
X* Move the cursor forward by
X* the specified number of units. All of the
X* motion is done by "forwchar". Error if you
X* try and move beyond the buffer's end.
X*/
Xchar forwunit (f, n, k)
X{
X
X if (n < 0)
X return (backunit (f, -n, KRANDOM));
X
X curwp -> w_unit_offset = 0;
X while (n--)
X {
X move_ptr (curwp, (long)R_B_PER_U(curwp), TRUE, TRUE, TRUE);
X }
X wind_on_dot (curwp);
X curwp -> w_flag |= WFMODE; /* update mode line */
X return (TRUE);
X}
X
X
X/*
X* Kill forward by "n" units. The rules for final
X* status are now different. It is not considered an error
X* to delete fewer units than you asked. This lets you say
X* "kill lots of units" and have the command stop in a reasonable
X* way when it hits the end of the buffer.
X*/
Xbool delfunit (f, n, k)
X{
X if (n < 0)
X return (FALSE);
X if ((lastflag & CFKILL) == 0)/* Purge kill buffer. */
X bclear (&sav_buf);
X thisflag |= CFKILL;
X while (n--)
X {
X ldelete ((A32)(R_B_PER_U(curwp)), TRUE);
X }
X curwp -> w_flag |= WFHARD;
X curwp -> w_unit_offset = 0;
X return (TRUE);
X}
X
X
X/*
X* Kill backwards by "n" units. The rules
X* for success and failure are now different, to prevent
X* strange behavior at the start of the buffer. The command
X* only fails if something goes wrong with the actual delete
X* of the characters. It is successful even if no characters
X* are deleted, or if you say delete 5 units, and there are
X* only 4 units left. I considered making the first call
X* to "backchar" special, but decided that that would just
X* be wierd. Normally this is bound to "M-Rubout" and
X* to "M-Backspace".
X*/
Xbool delbunit (f, n, k)
X{
X int size;
X
X if (n < 0)
X return (FALSE);
X if ((lastflag & CFKILL) == 0)/* Purge kill buffer. */
X bclear (&sav_buf);
X thisflag |= CFKILL;
X size = R_B_PER_U(curwp);
X while (n--)
X {
X if (move_ptr (curwp, -((long)size), TRUE, TRUE, TRUE))
X ldelete ((A32)size, TRUE);
X }
X curwp -> w_flag |= WFHARD;
X return (TRUE);
X}
X
END_OF_FILE
if test 2711 -ne `wc -c <'word.c'`; then
echo shar: \"'word.c'\" unpacked with wrong size!
fi
# end of 'word.c'
fi
echo shar: End of archive 8 \(of 9\).
cp /dev/null ark8isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 9 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...