pvr@wang.com (Peter Reilley) (02/28/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 11)." # Contents: basic.c main.c text.c # Wrapped by pvr@elf on Wed Feb 27 14:16:47 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'basic.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'basic.c'\" else echo shar: Extracting \"'basic.c'\" \(13944 characters\) sed "s/^X//" >'basic.c' <<'END_OF_FILE' X/* X* Basic cursor motion commands. X* The routines in this file are the basic X* command functions for moving the cursor around on X* the screen, setting mark, and swapping dot with X* mark. Only moves between lines, which might make the X* current buffer framing bad, are hard. X*/ X X#include "def.h" X Xbool move_ptr (); Xbool forwchar (); Xbool wind_on_dot (); Xbool backline (); X Xextern char MSG_mark_set[]; Xextern char MSG_no_mark[]; Xextern char MSG_go_b_n[]; Xextern char MSG_bad_num[]; X#if RUNCHK Xextern char ERR_bas_1[]; X#endif Xextern char MSG_lX[]; Xextern char MSG_lO[]; Xextern char MSG_lD[]; X X#include "lintfunc.dec" X Xextern bool rplc_mode; X X/* pvr X* Move cursor backwards. Do the X* right thing if the count is less than X* 0. Error if you try to move back from X* the beginning of the buffer. X*/ Xbool backchar (f, n, k) Xregister int n; X{ X if (n < 0) X return (forwchar (f, -n, KRANDOM)); X X while (n--) X { X if (curwp -> w_unit_offset == 0) X { X if (!move_ptr (curwp, -(long)R_B_PER_U(curwp), X TRUE, TRUE, TRUE)) X return (FALSE); X X /* step to previous unit */ X curwp -> w_unit_offset = R_CHR_PER_U(curwp) - 1; X X /* if before first line in window then move window */ X wind_on_dot (curwp); X } X else X curwp -> w_unit_offset--; X } X curwp -> w_flag |= WFMODE; /* update mode line */ X return (TRUE); X} X X/* pvr X* Move cursor forwards. Do the X* right thing if the count is less than X* 0. Error if you try to move forward X* from the end of the buffer. X*/ Xbool forwchar (f, n, k) Xregister int n; X{ X if (n < 0) X return (backchar (f, -n, KRANDOM)); X X curwp -> w_flag |= WFMODE; /* update mode line */ X while (n--) X { X if (curwp -> w_unit_offset >= (R_CHR_PER_U(curwp) - 1)) X { X /* move to the mext unit */ X curwp -> w_unit_offset = 0; X X if (!move_ptr (curwp, (long)R_B_PER_U(curwp), X TRUE, TRUE, TRUE)) X { X /* I am at the the end of the buffer */ X return (FALSE); X } X X /* if after the last line in window then move window */ X wind_on_dot (curwp); X } X else /* if at last byte of buffer then do not step */ X if (DOT_POS(curwp) < BUF_SIZE(curwp)) X curwp -> w_unit_offset++;/* step within unit */ X } X return (TRUE); X} X X/* pvr X* This function moves the specified pointer by the ammount specified X* in 'len'. Move the dot pointer is 'dot' is true, else move X* the window pointer. Do the fix up if 'fix' is TRUE. X* This is a relative move if 'rel' is TRUE, else it is an X* absolute move. X*/ X Xbool move_ptr (wp, len, dot, fix, rel) XWINDOW *wp; Xlong len; Xbool dot, fix, rel; X{ X A32 cur_pos, dest_pos, fix_val, last_pos; X long rel_pos; X A32 last_fixed_pos, align; X LINE **line, *line_guess; X int *l_off; X char shift; X bool no_limit; X X no_limit = TRUE; X if (dot) X { /* move dot position */ X l_off = &wp -> w_doto; X line = &wp -> w_dotp; X align = R_SIZE(wp); /* bytes -1 in a unit */ X } X else X { /* move window position */ X l_off = &wp -> w_loff; X line = &wp -> w_linep; X align = R_ALIGN(wp) - 1; /* interval of bytes to align window */ X } X X /* get the current position in the buffer */ X cur_pos = (*line) -> l_file_offset + *l_off; X X if (rel) X { X rel_pos = len; X dest_pos = len + cur_pos; /* destination position */ X } X else X { X rel_pos = len - cur_pos; /* relative move amount */ X dest_pos = len; /* destination position */ X } X if (fix) X { X shift = wp -> w_disp_shift; X X /* limit at begining */ X if (dest_pos < shift) X { X rel_pos = shift - cur_pos; X no_limit = FALSE; X } X else X { X /* calculate fixed up destination position */ X fix_val = dest_pos &= ~align; X fix_val += shift; X X /* calculate the last position in the buffer */ X last_pos = BUF_SIZE(wp); X if (last_pos < (last_fixed_pos = (last_pos & ~align) + shift)) X last_pos = last_fixed_pos - align - 1; X X /* if we are going to limit at the end of the buffer */ X if (last_pos < fix_val) X { X fix_val = last_pos; X no_limit = FALSE; X } X rel_pos = fix_val - cur_pos; X } X } X while (TRUE) X { X if (rel_pos < 0) /* move backward through buffer */ X { X /* current line? */ X if (*l_off + rel_pos >= 0) X { X *l_off += (short) rel_pos; X return (no_limit); X } X /* are we at the first line */ X if ((*line) -> l_bp -> l_size != 0) X { /* no, so step back */ X rel_pos += *l_off; X (*line) = (*line) -> l_bp;/* move back one line */ X *l_off = (*line) -> l_used; X } X else X { /* yes, limit at the begining */ X *l_off = 0; X return (FALSE); X } X } X else /* move forward through buffer */ X { X /* is in current line? */ X if (((A32)(*l_off) + rel_pos) < ((A32)((*line) -> l_used))) X { X *l_off += (short) rel_pos; X return (no_limit); X } X if ((*line) -> l_fp -> l_size != 0) X { X rel_pos -= (*line) -> l_used - *l_off; X *l_off = 0; X (*line) = (*line) -> l_fp;/* move forward one line */ X } X else X { X *l_off = (*line) -> l_used;/* at last line so limit it */ X return (FALSE); X } X } X } X} X X/* pvr X* Move the window so that the dot is within it's X* area. Return TRUE if window was moved. X*/ X Xbool wind_on_dot (wp) X XWINDOW * wp; X{ X long diff, incr; X A32 d_offs, w_start, bytes, align; X X /* number of bytes in a row */ X bytes = R_BYTES(wp); X /* number of bytes to align on */ X align = R_ALIGN(wp); X /* offset of window from start of the buffer */ X w_start = WIND_POS(wp); X /* offset of dot from start of the buffer */ X d_offs = DOT_POS(wp); X /* calculate the amount to move that is 1/3 of the window */ X incr = bytes * wp -> w_ntrows / 3; X /* if dot is before first line in window */ X if ((diff = (d_offs - w_start)) < 0)/* diff used later */ X { X move_ptr (wp, diff - incr, FALSE, TRUE, TRUE); X wp -> w_flag |= WFHARD; X return (TRUE); X } X /* if dot is after the last line in window */ X if (0 < (diff -= (wp -> w_ntrows * bytes - 1))) X { X if (align != 1) X diff = (diff & ~(align - 1)) + align; X move_ptr (wp, diff + incr, FALSE, TRUE, TRUE); X wp -> w_flag |= WFHARD; X return (TRUE); X } X /* is window aligned? */ X if (w_start != ((w_start & ~(align - 1)) + wp -> w_disp_shift)) X { /* if no then move into alignment */ X move_ptr (wp, 0L, FALSE, TRUE, TRUE); X wp -> w_flag |= WFHARD; X return (TRUE); X } X return (FALSE); X} X X/* pvr X* Go to the beginning of the X* buffer. Setting WFHARD is conservative, X* but almost always the case. X*/ Xbool gotobob () X{ X move_ptr (curwp, 0L, TRUE, TRUE, FALSE); /* move dot */ X move_ptr (curwp, 0L, FALSE, TRUE, FALSE); /* move window */ X curwp -> w_unit_offset = 0; X curwp -> w_flag |= WFHARD; X return (TRUE); X} X X X/* pvr X* Go to the end of the buffer. X* Setting WFHARD is conservative, but X* almost always the case. X* Dot is one byte past the end of the buffer. X*/ Xbool gotoeob () X{ X long f_off; X long index; X X move_ptr (curwp, BUF_SIZE(curwp), TRUE, TRUE, FALSE); /* move dot */ X curwp -> w_unit_offset = 0; X wind_on_dot (curwp); X return (TRUE); X} X X X/* pvr X* Move forward by full lines. X* If the number of lines to move is less X* than zero, call the backward line function to X* actually do it. The last command controls how X* the goal column is set. X*/ Xbool forwline (f, n, k) X{ X if (n < 0) X return (backline (f, -n, KRANDOM)); X X if (rplc_mode) X { X next_pat (); X } X else X { X /* move dot */ X if (!move_ptr (curwp, (long)R_BYTES(curwp) * n, X TRUE, TRUE, TRUE)) X curwp -> w_unit_offset = 0; X wind_on_dot (curwp); X curwp -> w_flag |= WFMODE; /* update mode line */ X } X return (TRUE); X} X X X/* pvr X* This function is like "forwline", but X* goes backwards. The scheme is exactly the same. X* Check for arguments that are less than zero and X* call your alternate. Figure out the new line and X* call "movedot" to perform the motion. X*/ Xbool backline (f, n, k) X{ X if (n < 0) X return (forwline (f, -n, KRANDOM)); X X if (rplc_mode) X { X next_pat (); X } X else X { X if (!move_ptr (curwp, -((long)(R_BYTES(curwp) * n)), X TRUE, TRUE, TRUE)) X curwp -> w_unit_offset = 0; X X /* is dot before the top of window? */ X wind_on_dot (curwp); X curwp -> w_flag |= WFMODE; /* update mode line */ X } X return (TRUE); X} X X/* pvr X* Scroll forward by a specified number X* of lines, or by a full page if no argument. X* (KRW) Added cursor (dot) weighting to force cursor X* to same position on new page. X*/ Xbool forwpage (f, n, k) Xregister int n; X{ X long mov_lines; X X if (rplc_mode) X next_pat (); X else X { X if (curwp -> w_ntrows <= 2) X mov_lines = 2; X else X mov_lines = curwp -> w_ntrows - 2; X X /* check if last line is already displayed */ X if (WIND_POS(curwp) + (R_BYTES(curwp) * curwp -> w_ntrows) < X curwp -> w_bufp -> b_linep -> l_bp -> l_file_offset + X curwp -> w_bufp -> b_linep -> l_bp -> l_used) X { X move_ptr (curwp, (long)(R_BYTES(curwp) * mov_lines), X FALSE, TRUE, TRUE); X } X /* move dot by same amount */ X if (!move_ptr (curwp, (long)(R_BYTES(curwp) * mov_lines), X TRUE, TRUE, TRUE)) X curwp -> w_unit_offset = 0; X X curwp -> w_flag |= WFHARD; X } X return (TRUE); X} X X X/* pvr X* This command is like "forwpage", X* but it goes backwards. X*/ Xbool backpage (f, n, k) Xregister int n; X{ X long mov_lines; X X if (rplc_mode) X next_pat (); X else X { X if (curwp -> w_ntrows <= 2) X mov_lines = 2; X else X mov_lines = curwp -> w_ntrows - 2; X X /* move window */ X move_ptr (curwp, -(long)(R_BYTES(curwp) * mov_lines), X FALSE, TRUE, TRUE); X /* move dot by same amount */ X if (!move_ptr (curwp, -(long)(R_BYTES(curwp) * mov_lines), X TRUE, TRUE, TRUE)) X curwp -> w_unit_offset = 0; X X curwp -> w_flag |= WFHARD; X } X return (TRUE); X} X X X/* X* Set the mark in the current window X* to the value of dot. A message is written to X* the echo line unless we are running in a keyboard X* macro, when it would be silly. X*/ Xbool setmark () X{ X X if (curbp == blistp) /* jam - hack to do goto/kill */ X pickone (); X else X { X curwp -> w_markp = curwp -> w_dotp; X curwp -> w_marko = curwp -> w_doto; X if (kbdmop == NULL) X { X writ_echo (MSG_mark_set); X } X } X return (TRUE); X} X X X/* pvr X* Swap the values of "dot" and "mark" in X* the current window. This is pretty easy, because X* all of the hard work gets done by the standard routine X* that moves the mark about. The only possible X* error is "no mark". X*/ Xbool swapmark () X{ X register short odoto; X register LINE * odotp; X X if (curwp -> w_markp == NULL) X { X writ_echo (MSG_no_mark); X return (FALSE); X } X X odotp = curwp -> w_dotp; X curwp -> w_dotp = curwp -> w_markp; X curwp -> w_markp = odotp; X odoto = curwp -> w_doto; X curwp -> w_doto = curwp -> w_marko; X curwp -> w_marko = odoto; X wind_on_dot (curwp); X curwp -> w_flag |= WFMODE; /* update mode line */ X return (TRUE); X} X X/* pvr X* Go to a specific byte position in buffer. X* If an argument is present, then X* it is the byte number, else prompt for a byte number X* to use. X*/ Xbool gotoline (f, n, k) X{ X A32 index; X register int s; X char buf[32]; X X if (f == FALSE) X { X X if ((s = ereply (MSG_go_b_n, buf, sizeof (buf), 0) != TRUE)) X return (s); X switch (R_TYPE(curwp)) X { X case TEXT: X case ASCII: X case EBCDIC: X case BINARY: X case HEX: X sscanf (buf, MSG_lX, &index); X break; X case OCTAL: X sscanf (buf, MSG_lO, &index); X break; X case DECIMAL: X sscanf (buf, MSG_lD, &index); X break; X#if RUNCHK X default: X writ_echo (ERR_bas_1); X break; X#endif X } X } X X if (n <= 0) X { X writ_echo (MSG_bad_num); X return (FALSE); X } X X move_ptr (curwp, index, TRUE, TRUE, FALSE); X curwp -> w_unit_offset = 0; X X curwp -> w_flag |= WFMODE; /* update mode line */ X X wind_on_dot (curwp); X return (TRUE); X} X END_OF_FILE if test 13944 -ne `wc -c <'basic.c'`; then echo shar: \"'basic.c'\" unpacked with wrong size! fi chmod +x 'basic.c' # end of 'basic.c' fi if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(12527 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X/* X* BEAV is based on the source for emacs for display and keyboard handling X* functions. The binary file handling and display formats are special X* to BEAV. There is a full manual included in this release. There X* are makefiles for unix and MSC 5.1 under DOS. The old Wang PC is X* supported. This release is for unix. The def_unix.h file is the X* header for unix and the def_dos.h file is the header for dos. Rename X* the appropriate .h file to def.h to convert to your os. X* I am willing to maintain BEAV and will entertain suggestions for X* modifications and/or bug fixes. I can be reached at; X* X* pvr@wang.com X* X* or at; X* X* Peter Reilley X* 19 Heritage Cir. X* Hudson, N.H. 03051 X*/ X X/* X* X* Mainline, macro commands. X*/ X#include "def.h" X Xchar execute (); Xvoid edinit (); Xvoid flush_all (); Xchar quit (); Xchar ctrlg (); Xvoid _lowercase (); X X Xextern char MSG_ok[]; Xextern char MSG_main[]; Xextern char MSG_prog_name[]; Xextern char MSG_no_mod[]; Xextern char MSG_no_s_chg[]; Xextern char MSG_auto_fl[]; Xextern char MSG_quit[]; Xextern char MSG_not_now[]; Xextern char MSG_st_mac[]; Xextern char MSG_end_mac[]; Xextern char MSG_num_mod[]; Xextern char MSG_null[]; X X#include "lintfunc.dec" X Xint thisflag; /* Flags, this command */ Xint lastflag; /* Flags, last command */ Xint curgoal; /* Goal column */ Xint com_line_flags; /* Count of cmd line switches */ XBUFFER * curbp; /* Current buffer */ XWINDOW * curwp; /* Current window */ XBUFFER * bheadp; /* BUFFER listhead */ XWINDOW * wheadp; /* WINDOW listhead */ XBUFFER * blistp; /* Buffer list BUFFER */ Xshort kbdm[NKBDM] = {(KCTLX | ')')}; /* Macro (fitz) */ Xshort *kbdmip; /* Input for above */ Xshort *kbdmop; /* Output for above */ Xchar pat[NPAT]; /* Pattern */ XSYMBOL * symbol[NSHASH]; /* Symbol table listhead. */ XSYMBOL * binding[NKEYS]; /* Key bindings. */ Xextern ROW_FMT hex_8_fmt; Xextern bool ibm_pc, mem_map; X Xchar *okmsg = {MSG_ok}; Xint insert_mode = {TRUE}; Xint extend_buf = {FALSE}; X Xextern bool srch_mode; Xextern bool rplc_mode; Xextern char *getenv (); Xint initial_load = 0; Xint flush_count = 0; Xint flush_num = 500; Xint auto_update = 0; X Xvoid main (argc, argv) Xchar *argv[]; X{ X X register int c; X register int f; X register int n; X register int mflag; X char bname[NBUFN]; X register char *p; X extern long last_time; X long last_second; X X#if MSDOS X is_wang (); /* Check for computer type */ X#endif X init_fmt (); /* initialize format arrays */ X strcpy (bname, MSG_main); /* Get buffer name. */ X vtinit (); /* Virtual terminal. */ X keymapinit (); /* Symbols, bindings. */ X X if (argc == 1) X { X edinit (bname); X update (); X eerase (); X } X X else X { X com_line_flags = 0; X initial_load = 1; X n = (argc - 1); /* Load them backwards */ X if (n > com_line_flags) X { X/* _lowercase (argv[n]); */ X makename (bname, argv[n]); X edinit (bname); /* Buffers, windows. */ X update (); X readin (argv[n--], 0L, MAXPOS); X for (; n > com_line_flags; n--) X { X/* _lowercase (argv[n]); */ X load_file (argv[n], 0L, MAXPOS); X } X } X else X { X edinit (bname); X update (); X } X X initial_load = 0; X } X X#ifndef IBM X check_extend (getenv (MSG_prog_name)); /* check for extended keys */ X#endif X lastflag = 0; /* Fake last flags. */ X Xloop: X update (); X c = getkey (); X if (epresf != FALSE) X { X eerase (); X update (); X } X f = FALSE; X n = 1; X if (c == (KCTRL | 'U')) X { X /* ^U, start argument. */ X f = TRUE; X n = 4; X while ((c = getkey ()) == (KCTRL | 'U')) X n *= 4; X if ((c >= '0' && c <= '9') || c == '-') X { X if (c == '-') X { X n = 0; X mflag = TRUE; X } X else X { X n = c - '0'; X mflag = FALSE; X } X while ((c = getkey ()) >= '0' && c <= '9') X n = 10 * n + c - '0'; X if (mflag != FALSE) X n = -n; X } X } X if (kbdmip != NULL) X { X /* Save macro strokes. */ X if (c != (KCTLX | ')') && kbdmip > &kbdm[NKBDM - 6]) X { X ctrlg (FALSE, 0, KRANDOM); X goto loop; X } X if (f != FALSE) X { X *kbdmip++ = (KCTRL | 'U'); X *kbdmip++ = n; X } X *kbdmip++ = c; X } X execute (c, f, n); /* Do it. */ X goto loop; X} X X X/* X* Command execution. Look up the binding in the the X* binding array, and do what it says. Return a very bad status X* if there is no binding, or if the symbol has a type that X* is not usable (there is no way to get this into a symbol table X* entry now). Also fiddle with the flags. X*/ Xchar execute (c, f, n) X{ X X register SYMBOL * sp; X register int status; X X if ((sp = binding[c]) != NULL) X { X thisflag = 0; X if (sp -> s_modify & SMOD && (curbp -> b_flag & BFVIEW)) X { X writ_echo (MSG_no_mod); X return (ABORT); X } X if (sp -> s_modify & SSIZE && (curbp -> b_flag & BFSLOCK)) X { X writ_echo (MSG_no_s_chg); X return (ABORT); X } X if ((srch_mode && !(sp -> s_modify & SSRCH)) || X (rplc_mode && !(sp -> s_modify & SRPLC))) X { X ttbeep (); X return (TRUE); X } X X status = (*sp -> s_funcp) (f, n, c); X if (sp -> s_modify & SMOD) X flush_count++; X X if (flush_count >= flush_num && auto_update) X if (!(kbdmip != NULL || kbdmop != NULL))/* not during macro */ X { X ttbeep (); X writ_echo (MSG_auto_fl); X flush_all (); X } X lastflag = thisflag; X return (status); X } X else X bad_key (c); X X lastflag = 0; X return (ABORT); X} X X X/* X* Initialize all of the buffers X* and windows. The buffer name is passed down as X* an argument, because the main routine may have been X* told to read in a file by default, and we want the X* buffer name to be right. X*/ Xvoid edinit (bname) Xchar bname[]; X{ X X register BUFFER * bp; X register WINDOW * wp; X X bp = bfind (bname, TRUE); /* Text buffer. */ X blistp = bcreate (MSG_null); /* Special list buffer. */ X wp = (WINDOW *) malloc (sizeof (WINDOW));/* Initial window. */ X if (bp == NULL || wp == NULL || blistp == NULL) X abort (); X curbp = bp; /* Current ones. */ X wheadp = wp; X curwp = wp; X wp -> w_wndp = NULL; /* Initialize window. */ X wp -> w_bufp = bp; X bp -> b_nwnd = 1; /* Displayed. */ X wp -> w_fmt_ptr = &hex_8_fmt;/* HEX 8 bit display pvr */ X wp -> w_linep = bp -> b_linep; X wp -> w_dotp = bp -> b_linep; X wp -> w_doto = 0; /* set dot pos pvr */ X wp -> w_markp = NULL; X wp -> w_marko = 0; X wp -> w_toprow = 0; X wp -> w_ntrows = nrow - 2; /* 2 = mode, echo. */ X wp -> w_flag = WFMODE | WFHARD;/* Full. */ X wp -> w_intel_mode = FALSE; /* default is no byte swap pvr */ X wp -> w_disp_shift = 0; /* default to no byte shift pvr */ X wp -> w_loff = 0; /* starting line offset pvr */ X wp -> w_unit_offset = 0; /* dot offset from file start pvr */ X} X X/* X* Flush all the dirty buffers that have file names X* associated with them. X*/ Xvoid flush_all () X{ X register BUFFER * bp, X *savbp = curbp; X X for (bp = bheadp; bp != NULL; bp = bp -> b_bufp) X if (bp -> b_fname != NULL) X { X curbp = bp; /* jam */ X filesave (); X update (); X } X flush_count = 0; X writ_echo (okmsg); X curbp = savbp; X if (blistp -> b_nwnd != 0) /* update buffer display */ X listbuffers (); X update (); X} X X X/* call flush_all to empty the buffers X* and quit X*/ Xvoid flushnquit (f, n, k) X{ X flush_all (); X quit (f, n, k); X} X X X/* X* Quit command. If an argument, always X* quit. Otherwise confirm if a buffer has been X* changed and not written out. Normally bound X* to "C-X C-C". X*/ Xchar quit (f, n, k) X{ X X register char s; X X if (f != FALSE /* Argument forces it. */ X || anycb () == FALSE/* All buffers clean. */ X || (s = eyesno (MSG_quit)) == TRUE)/* User says it's OK. */ X { X X vttidy (); X exit (GOOD); X } X X return (s); X} X X X/* X* Begin a keyboard macro. X* Error if not at the top level X* in keyboard processing. Set up X* variables and return. X*/ Xbool ctlxlp (f, n, k) X{ X X if (kbdmip != NULL || kbdmop != NULL) X { X X writ_echo (MSG_not_now); X return (FALSE); X } X X writ_echo (MSG_st_mac); X kbdmip = &kbdm[0]; X return (TRUE); X} X X X/* X* End keyboard macro. Check for X* the same limit conditions as the X* above routine. Set up the variables X* and return to the caller. X*/ Xbool ctlxrp (f, n, k) X{ X X if (kbdmip == NULL) X { X X writ_echo (MSG_not_now); X return (FALSE); X } X X writ_echo (MSG_end_mac); X kbdmip = NULL; X return (TRUE); X} X X X/* X* Execute a macro. X* The command argument is the X* number of times to loop. Quit as X* soon as a command gets an error. X* Return TRUE if all ok, else X* FALSE. X*/ Xbool ctlxe (f, n, k) X{ X X register int c; X register int af; X register int an; X register int s; X X if (kbdmip != NULL || kbdmop != NULL) X { X X writ_echo (MSG_not_now); X return (FALSE); X } X X if (n <= 0) X return (TRUE); X do X { X X kbdmop = &kbdm[0]; X do X { X X af = FALSE; X an = 1; X if ((c = *kbdmop++) == (KCTRL | 'U')) X { X X af = TRUE; X an = *kbdmop++; X c = *kbdmop++; X } X X s = TRUE; X } X while (c != (KCTLX | ')') && (s = execute (c, af, an)) == TRUE); X kbdmop = NULL; X } X while (s == TRUE && --n); X return (s); X} X X X/* X* Abort. X* Beep the beeper. X* Kill off any keyboard macro, X* etc., that is in progress. X* Sometimes called as a routine, X* to do general aborting of X* stuff. X*/ Xchar ctrlg (f, n, k) X{ X/* ttbeep (); */ X if (kbdmip != NULL) X { X kbdm[0] = (KCTLX | ')'); X kbdmip = NULL; X } X return (ABORT); X} X X X/* X* Display the version. All this does X* is copy the text in the external "version" array into X* the message system, and call the message reading code. X* Don't call display if there is an argument. X*/ Xchar showversion (f, n, k) X{ Xstatic char *cp; Xchar buf[80]; X X cp = version; X sprintf (buf, cp); X writ_echo (buf); X return (TRUE); X} X X X/* ughly to_lower function for X* files read in under MSDOS setargv function X*/ Xvoid _lowercase (s) Xregister char *s; X{ X X#ifdef MSDOS X for (; *s; s++) X if (ISUPPER (*s)) X *s = TOLOWER (*s); X#endif X} X X X/* autosave control X*/ Xbool autosave () X{ X register WINDOW * wp; X register int s, X n; X char buf[32]; X X if ((s = ereply (MSG_num_mod, buf, sizeof (buf), NULL)) == TRUE) X { X X n = atoi (buf); X if (n >= 0) X auto_update = flush_num = n;/* not 0! */ X else X auto_update = 0; X } X X for (wp = wheadp; wp; wp = wp -> w_wndp) X if (wp -> w_bufp == curbp) X wp -> w_flag |= WFMODE; X return (TRUE); X} END_OF_FILE if test 12527 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi chmod +x 'main.c' # end of 'main.c' fi if test -f 'text.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'text.c'\" else echo shar: Extracting \"'text.c'\" \(15912 characters\) sed "s/^X//" >'text.c' <<'END_OF_FILE' X/* X* This file contains all text srtings X*/ X#include "def.h" X X/* in basic.c */ X char MSG_mark_set[] = "Mark set"; X char MSG_no_mark[] = "No mark in this window"; X char MSG_go_b_n[] = "Goto byte number: "; X char MSG_bad_num[] = "ERROR: Bad number"; X char MSG_lX[] = "%lX"; X char MSG_lO[] = "%lO"; X char MSG_lD[] = "%lD"; X X/* in buffer.c */ X char MSG_use_b[] = "Enter name of buffer to goto: "; X char MSG_kill_b[] = "Enter name of buffer to delete: "; X char MSG_no_del_m[] = "ERROR: Can't delete 'main'"; X char MSG_buf_disp[] = "ERROR: Buffer is displayed - continue"; X char MSG_main[] = "main"; X char MSG_l_buf_h[] = "S T Size Buffer File"; X char MSG_l_buf_h1[] = "- - ---- ------ ----"; X char MSG_no_chg[] = "Discard changes"; X char MSG_yank_b[] = "Yank from buffer: "; X char MSG_no_buf[] = "ERROR: no such buffer"; X char MSG_no_s_yank[] = "ERROR: can't yank to self!"; X char MSG_buf_nam[] = "Buffer name: "; X char MSG_bad_l[] = "ERROR: Bad line!"; X char MSG_pick[] = "%s: G(oto) or K(ill) S(ave) "; X char MSG_siz_chg[] = "Current buffer size may be changed"; X char MSG_no_siz_chg[]= "Current buffer size is locked"; X char MSG_up_arrow[] = "^"; X char MSG_null[] = ""; X X/* in display.c */ X char MSG_prn_to[] = "Print to: "; X char MSG_disp_r_n[] = "\r\n"; X char MSG_11lX[] = "%11lX:"; X char MSG_11lo[] = "%11lo:"; X char MSG_11ld[] = "%11ld:"; X char MSG_03o[] = "%03o"; X char MSG_06o[] = "%06o"; X char MSG_011lo[] = "%011lo"; X char MSG_03u[] = "%03u"; X char MSG_05u[] = "%05u"; X char MSG_010lu[] = "%010lu"; X char MSG_02X[] = "%02X"; X char MSG_04X[] = "%04X"; X char MSG_08lX[] = "%08lX"; X char MSG_prog_name[] = "BEAV"; X char MSG_disp_b_lst[]= " Buffer List "; X char MSG_file[] = "File: "; X char MSG_RO[] = " [RO]"; X char MSG_WL[] = " [WL]"; X char MSG_RW[] = " [RW]"; X char MSG_AU[] = "[AU]"; X char MSG_NOT_AU[] = " "; X char MSG_curs_asc[] = "CURSOR=%08lX, ASCII"; X char MSG_curs_ebc[] = "CURSOR=%08lX, EBCDIC"; X char MSG_curs_hex[] = "CURSOR=%08lX,%2X HEX"; X char MSG_curs_bin[] = "CURSOR=%08lX,%2X BIN"; X char MSG_curs_dec[] = "CURSOR=%08lu,%2u DEC"; X char MSG_curs_oct[] = "CURSOR=%08lo,%2o OCTAL"; X char MSG_siz_8[] = " 8 "; X char MSG_siz_16[] = " 16"; X char MSG_siz_32[] = " 32"; X char MSG_siz_null[] = " "; X char MSG_int_shift[] = " S%X"; X char MSG_mot_shift[] = " %X"; X char MSG_print1[] = "Writing: %s; Hit any key to quit"; X char MSG_print2[] = "Wrote %s lines"; X X/* in ebcdic.c */ X char ERR_ebcdic[] = X "ERROR: Character %s not found in EBCDIC table\n"; X X/* in echo.c */ X char MSG_y_n[] = "%s [y/n]? "; X char MSG_hex_dig[] = "0123456789ABCDEF"; X X/* in extend.c */ X char MSG_not_now[] = "Not now"; X char MSG_func[] = "Function: "; X char MSG_unk_func[] = "ERROR: Unknown function for binding"; X char MSG_cmd_t_ex[] = "Command to execute: "; X char MSG_unk_ext[] = "ERROR: Unknown extended command"; X char MSG_d_b[] = X "Display key binding for which key? (hit key now!)"; X char MSG_unbd[] = "%s is unbound"; X char MSG_bnd_to[] = "%s is bound to %s"; X char MSG_ins_self[] = "ins-self"; X char MSG_bnd_file[] = "Binding file: "; X char MSG_bld_wall[] = "Building help buffer"; X X/* in file.c */ X char MSG_rd_file[] = "Read file: "; X char MSG_trash[] = "#tempbuf#"; X char MSG_ins_file[] = "Insert file: "; X char MSG_not_fnd[] = "Not found"; X char MSG_visit[] = "Visit file: "; X char MSG_view[] = "View file (read only): "; X char MSG_buf_ex[] = "ERROR: Buffer exists"; X char MSG_old_buf[] = "ERROR: Old buffer"; X char MSG_cnt_cr[] = "ERROR: Cannot create buffer"; X char MSG_reading[] = "reading <%s>"; X char MSG_read_lx[] = "Read %s bytes"; X char MSG_no_mem_rd[] = X "ERROR: Insufficient memory, read %s bytes; buffer set to read only"; X char MSG_wr_file[] = "Write file: "; X char MSG_no_fn[] = "ERROR: No file name"; X char MSG_bk_err[] = "ERROR: Backup error, save anyway"; X char MSG_writing[] = "writing <%s>"; X char MSG_wrot_1[] = "Wrote 1 byte"; X char MSG_wrot_n[] = "Wrote %s bytes"; X char MSG_fil_nam[] = "File name: "; X char ERR_parse_fn[] = X "ERROR: Starting address (%s) must preceede ending address (%s)"; X char ERR_addr_neg[] = "ERROR: Addresses cannot be negative"; X char ERR_f_size[] = X "ERROR: Cannot access past end of file. (file size = %s)"; X X/* in fileio.c */ X char MSG_cnt_wr[] = "ERROR: Cannot open file for writing"; X char MSG_wr_io_er[] = "ERROR: Write I/O error"; X char MSG_rd_er[] = "ERROR: File read error"; X char MSG_bak[] = ".BAK"; X char MSG_backup[] = "Back-up of %s to %s"; X char MSG_back_er[] = "ERROR: Back-up of %s to %s FAILED !!"; X char MSG_back_of[] = "%s - Back-up of <%s> to <%s>\n"; X X/* in format.c */ X char hex_str[] = "%X"; X char hex_l_str[] = "%lX"; X char octal_str[] = "%o"; X char octal_l_str[] = "%lo"; X char decimal_str[] = "%u"; X char decimal_l_str[] = "%lu"; X char char_str[] = "%c"; X X/* in kbd.c */ X char MSG_tab[] = "Tab"; X char MSG_ret[] = "Return"; X char MSG_bksp[] = "Backspace"; X char MSG_space[] = "Space"; X char MSG_rubout[] = "Rubout"; X X/* in line.c */ X char MSG_cnt_alloc[] = "ERROR: Cannot allocate %s bytes for a line"; X char MSG_too_m_k[] = "ERROR: Too many kills"; X X/* in main.c */ X char MSG_ok[] = "ok"; X char MSG_no_mod[] = "ERROR: Buffer can not be modified"; X char MSG_no_s_chg[] = "ERROR: Buffer size can not be changed"; X char MSG_auto_fl[] = "Doing auto buffer flush"; X char MSG_quit[] = "quit-no-save"; X char MSG_st_mac[] = "Start macro"; X char MSG_end_mac[] = "End macro"; X char MSG_num_mod[] = "Number of modifcations per update: "; X char version[] = "BEAV, Ver 1.12, 02/21/91"; X X/* in random.c */ X char MSG_sh_pos[] = X "Cursor: %s, Mark: %s, Buffer Size: %s, File Size: %s"; X char MSG_sh_pos1[] = X "Cursor: %s, No Mark, Buffer Size: %s, File Size: %s"; X char MSG_f_str[] = ", File: <%s>"; X char MSG_3u[] = "%3u"; X char MSG_5u[] = "%5u"; X char MSG_lu[] = "%lu"; X char MSG_lnk[] = "All windows on buffer <%s> are %s"; X char MSG_unlink[] = "unlinked"; X char MSG_link[] = "linked"; X char MSG_bad_key[] = "ERROR: bad key = "; X char MSG_esc[] = "Esc "; X char MSG_ctl_x[] = "Ctl-X "; X char MSG_ctl[] = "Ctl-"; X char MSG_key_code[] = "%s, %s"; X X/* in region.c */ X char MSG_reg_lrg[] = "ERROR: Mark to cursor is too large"; X char MSG_sv_in_b[] = "Save in buffer: "; X char MSG_sav_slf[] = "ERROR: Can't save to self!"; X X/* in search.c */ X char MSG_sch_str[] = " Search String"; X char MSG_bsrc_str[] = "Back Search String"; X char MSG_rpl_str[] = "Replace String"; X char MSG_pat_fnd[] = "Pattern found at %s"; X char MSG_no_srch[] = "ERROR: No last search"; X char MSG_fnd_at[] = X "Found at %s, (R)eplace, (S)kip, (A)ll, (O)ne, (Q)uit."; X char MSG_no_rpl[] = "No replacements done"; X char MSG_1_rpl[] = "1 replacement done"; X char MSG_n_rpl[] = "%s replacements done"; X char MSG_srcing[] = "Searching at %s, Hit any key to quit."; X char MSG_curs[] = "%s; Curs = %s, %s Len = %s => "; X char MSG_cmp_end[] = "Compare reached the end of a buffer"; X char MSG_cmp_term[] = "Compare terminated by user"; X char MSG_cmp_dif[] = X "Difference is detected at the two cursor positions"; X char MSG_only_2[] = X "ERROR: There must be exactly two windows displayed to use Compare"; X char MSG_cmping[] = "Comparing at %s, Hit any key to quit."; X X/* in spawn.c */ X char MSG_shell[] = "COMSPEC"; X char MSG_def_shell[] = "/command.com"; X char MSG_pmpt[] = "PROMPT=[BEAV]"; X char MSG_pt[] = "PROMPT"; X char MSG_pme[] = "PROMPT="; X X/* in symbol.c */ X char MSG_byte_shift[] = "display-byte-shift"; X char MSG_back_char[] = "move-back-char"; X char MSG_forw_del_char[] = "delete-forw-char"; X char MSG_toggle_swap[] = "display-swap-order"; X char MSG_forw_char[] = "move-forw-char"; X char MSG_abort[] = "abort-cmd"; X char MSG_back_del_char[] = "delete-back-char"; X char MSG_refresh[] = "refresh-screen"; X char MSG_forw_line[] = "move-forw-line"; X char MSG_back_line[] = "move-back-line"; X char MSG_quote[] = "insert-literally"; X char MSG_recall[] = "recall-srch-string"; X char MSG_twiddle[] = "unit-twiddle"; X char MSG_forw_page[] = "move-forw-page"; X char MSG_kill_region[] = "delete-mark-to-cursor"; X char MSG_yank[] = "yank"; X char MSG_down_window[] = "move-window-down"; X char MSG_ins_toggle[] = "insert-toggle"; X char MSG_display_buffers[] = "buffers-display"; X char MSG_exit_flush_all[] = "quit-save-all"; X char MSG_set_file_name[] = "buffer-set-file-name"; X char MSG_file_insert[] = "insert-file"; X char MSG_buf_size_lock[] = "buffer-size-lock"; X char MSG_flush_all[] = "save-all-buffers"; X char MSG_up_window[] = "move-window-up"; X char MSG_file_read[] = "file-read"; X char MSG_file_save[] = "file-save"; X char MSG_file_visit[] = "file-visit"; X char MSG_file_write[] = "file-write"; X char MSG_swap_dot_and_mark[] = "swap-cursor-and-mark"; X char MSG_shrink_window[] = "window-shrink"; X char MSG_display_position[] = "show-position"; X char MSG_start_macro[] = "macro-start"; X char MSG_end_macro[] = "macro-end"; X char MSG_help[] = "binding-for-key"; X char MSG_only_window[] = "window-single"; X char MSG_split_window[] = "window-split"; X char MSG_use_buffer[] = "change-buffer"; X char MSG_spawn_cli[] = "spawn-shell"; X char MSG_execute_macro[] = "macro-execute"; X char MSG_goto_line[] = "move-to-byte"; X char MSG_ins_unit[] = "insert-unit"; X char MSG_kill_buffer[] = "kill-buffer"; X char MSG_load_bindings[] = "bindings-load"; X char MSG_forw_window[] = "change-window-forw"; X char MSG_back_window[] = "change-window-back"; X char MSG_view_file[] = "file-view"; X char MSG_enlarge_window[] = "window-enlarge"; X char MSG_ascii_mode[] = "display-ascii"; X char MSG_binary_mode[] = "display-binary"; X char MSG_buffer_name[] = "buffer-set-name"; X char MSG_decimal_mode[] = "display-decimal"; X char MSG_ebcdic_mode[] = "display-ebcdic"; X char MSG_hex_mode[] = "display-hex"; X char MSG_back_del_unit[] = "delete-back-unit"; X char MSG_octal_mode[] = "display-octal"; X char MSG_display_version[] = "show-version"; X char MSG_unit_size1[] = "display-bytes"; X char MSG_unit_size2[] = "display-words"; X char MSG_unit_size4[] = "display-double-words"; X char MSG_reposition_window[] = "window-reposition"; X char MSG_set_mark[] = "mark-set"; X char MSG_goto_eob[] = "move-to-end"; X char MSG_goto_bob[] = "move-to-begining"; X char MSG_next_buff[] = "change-to-next-buffer"; X char MSG_prev_buff[] = "change-to-prev-buffer"; X char MSG_query_replace[] = "replace"; X char MSG_display_bindings[] = "help"; X char MSG_auto_save[] = "auto-save"; X char MSG_back_unit[] = "move-back-unit"; X char MSG_compare[] = "compare"; X char MSG_forw_del_unit[] = "delete-forw-unit"; X char MSG_forw_unit[] = "move-forw-unit"; X char MSG_link_windows[] = "window-link"; X char MSG_print[] = "print-mark-to-cursor"; X char MSG_back_search[] = "search-back"; X char MSG_forw_search[] = "search-forw"; X char MSG_back_page[] = "move-back-page"; X char MSG_copy_region[] = "copy-mark-to-cursor"; X char MSG_extended_command[] = "extended-command"; X char MSG_search_again[] = "search-again"; X char MSG_bind_to_key[] = "bind-to-key"; X char MSG_file_visit_split[] = "file-visit-split"; X char MSG_yank_buffer[] = "yank-buffer"; X char MSG_save_region[] = "save-mark-to-cursor"; X char MSG_use_buffer_split[] = "move-to-buffer-split"; X char MSG_no_f_tb[] = X "ERROR: Could not find <%s> in look up table\n"; X X/* in ttykbd.c */ X char MSG_sp_key[] = "%u special keys bound\n"; X X/* in window.c */ X char MSG_no_splt[] = "ERROR: Cannot split a %s line window"; X char MSG_cnt_al_w[] = "ERROR: Cannot allocate WINDOW block"; X char MSG_one_w[] = "ERROR: Only one window"; X char MSG_imp_chg[] = "ERROR: Impossible change"; X X#if RUNCHK X/* in basic.c */ X char ERR_bas_1[] = "ERROR: unknown r_type in basic #1"; X X/* in display.c */ X char ERR_disp_1[] = "ERROR: unknown r_type in display #1"; X char ERR_disp_2[] = "ERROR: unknown r_type in display #2"; X char ERR_disp_3[] = "ERROR: row less than zero\n"; X char ERR_disp_4[] = "ERROR: row greater then window size\n"; X char ERR_disp_5[] = "ERROR: unknown r_type in display #3"; X char ERR_disp_6[] = "ERROR: unknown r_size in display "; X/* in line.c */ X char ERR_no_alloc[] = X "ERROR: new line was allocated during read pattern\n"; X char ERR_db_dalloc[] = X "ERROR: line was deallocated during read pattern\n"; X char ERR_lock[] = "ERROR: This is size locked, cannot insert."; X char ERR_lock_del[] = "ERROR: This is size locked, cannot delete."; X/* in random.c */ X char ERR_rnd_1[] = "ERROR: unknown r_type in random #1"; X char ERR_rnd_2[] = "ERROR: unknown r_size in random #2"; X char ERR_rnd_3[] = "ERROR: unknown r_type in random #3"; X char ERR_rnd_4[] = "ERROR: unknown r_size in random #4"; X char MSG_rnd_5[] = "ERROR: unknown r_size in random #5"; X char ERR_rnd_6[] = "ERROR: unknown r_size in random #6"; X char ERR_rnd_7[] = "ERROR: unknown r_size in random #7"; X/* in search.c */ X char ERR_rdpat[] = "ERROR: bad r_type in readpattern\n"; X char ERR_mask[] = "ERROR: size of mask pattern, pat=%d, mask=%d\n"; X char ERR_m_cl[] = "ERROR: in ascii mode mask byte was not cleared\n"; X/* in ttyio.c */ X char ERR_bd_pl[] = "ERROR: bad call to putline\n"; X#endif END_OF_FILE if test 15912 -ne `wc -c <'text.c'`; then echo shar: \"'text.c'\" unpacked with wrong size! fi chmod +x 'text.c' # end of 'text.c' fi echo shar: End of archive 3 \(of 11\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 11 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0