home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume4
/
uemacs3.6
/
part3
< prev
next >
Wrap
Text File
|
1986-11-30
|
38KB
|
1,164 lines
Subject: MicroEMACS 3.6 (Part 3 of 8)
Newsgroups: mod.sources
Approved: jpn@panda.UUCP
Mod.sources: Volume 4, Issue 100
Submitted by: genrad!decvax!ihnp4!itivax!duncan!lawrence
echo x - ebind.h
sed 's/^X//' >ebind.h <<'*-*-END-of-ebind.h-*-*'
X/* EBIND: Initial default key to function bindings for
X MicroEMACS 3.2
X
X written by Dave G. Conroy
X modified by Steve Wilhite, George Jones
X greatly modified by Daniel Lawrence
X*/
X
X/*
X * Command table.
X * This table is *roughly* in ASCII order, left to right across the
X * characters of the command. This expains the funny location of the
X * control-X commands.
X */
XKEYTAB keytab[NBINDS] = {
X {CTRL|'A', gotobol},
X {CTRL|'B', backchar},
X {CTRL|'C', insspace},
X {CTRL|'D', forwdel},
X {CTRL|'E', gotoeol},
X {CTRL|'F', forwchar},
X {CTRL|'G', ctrlg},
X {CTRL|'H', backdel},
X {CTRL|'I', tab},
X {CTRL|'J', indent},
X {CTRL|'K', killtext},
X {CTRL|'L', refresh},
X {CTRL|'M', newline},
X {CTRL|'N', forwline},
X {CTRL|'O', openline},
X {CTRL|'P', backline},
X {CTRL|'Q', quote},
X {CTRL|'R', backsearch},
X {CTRL|'S', forwsearch},
X {CTRL|'T', twiddle},
X {CTRL|'V', forwpage},
X {CTRL|'W', killregion},
X {CTRL|'Y', yank},
X {CTRL|'Z', backpage},
X {CTLX|CTRL|'B', listbuffers},
X {CTLX|CTRL|'C', quit}, /* Hard quit. */
X {CTLX|CTRL|'F', filefind},
X {CTLX|CTRL|'I', insfile},
X {CTLX|CTRL|'L', lowerregion},
X {CTLX|CTRL|'M', delmode},
X {CTLX|CTRL|'N', mvdnwind},
X {CTLX|CTRL|'O', deblank},
X {CTLX|CTRL|'P', mvupwind},
X {CTLX|CTRL|'R', fileread},
X {CTLX|CTRL|'S', filesave},
X {CTLX|CTRL|'U', upperregion},
X {CTLX|CTRL|'V', viewfile},
X {CTLX|CTRL|'W', filewrite},
X {CTLX|CTRL|'X', swapmark},
X {CTLX|CTRL|'Z', shrinkwind},
X {CTLX|'?', deskey},
X {CTLX|'!', spawn}, /* Run 1 command. */
X {CTLX|'=', showcpos},
X {CTLX|'(', ctlxlp},
X {CTLX|')', ctlxrp},
X {CTLX|'^', enlargewind},
X {CTLX|'1', onlywind},
X {CTLX|'2', splitwind},
X {CTLX|'B', usebuffer},
X {CTLX|'C', spawncli}, /* Run CLI in subjob. */
X#if V7 & BSD
X {CTLX|'D', bktoshell}, /* suspend emacs */
X#endif
X {CTLX|'E', ctlxe},
X {CTLX|'F', setfillcol},
X {CTLX|'K', killbuffer},
X {CTLX|'M', setmode},
X {CTLX|'N', filename},
X {CTLX|'O', nextwind},
X {CTLX|'P', prevwind},
X {CTLX|'S', filesave},
X {CTLX|'X', nextbuffer},
X {CTLX|'Z', enlargewind},
X {META|CTRL|'H', delbword},
X {META|CTRL|'K', unbindkey},
X {META|CTRL|'L', reposition},
X {META|CTRL|'M', delgmode},
X {META|CTRL|'N', namebuffer},
X {META|CTRL|'R', qreplace},
X {META|CTRL|'V', scrnextdw},
X {META|CTRL|'W', killpara},
X {META|CTRL|'Z', scrnextup},
X {META|' ', setmark},
X {META|'?', help},
X {META|'!', reposition},
X {META|'.', setmark},
X {META|'>', gotoeob},
X {META|'<', gotobob},
X {META|'B', backword},
X {META|'C', capword},
X {META|'D', delfword},
X {META|'F', forwword},
X {META|'G', gotoline},
X {META|'K', bindtokey},
X {META|'L', lowerword},
X {META|'M', setgmode},
X {META|'N', gotoeop},
X {META|'P', gotobop},
X {META|'Q', fillpara},
X {META|'R', sreplace},
X#if V7 & BSD
X {META|'S', bktoshell},
X#endif
X {META|'U', upperword},
X {META|'V', backpage},
X {META|'W', copyregion},
X {META|'X', namedcmd},
X {META|'Z', quickexit},
X {META|0x7F, delbword},
X
X#if MSDOS & (HP150 == 0)
X {SPEC|CTRL|'_', forwhunt},
X {SPEC|CTRL|'S', backhunt},
X {SPEC|71, gotobob},
X {SPEC|72, backline},
X {SPEC|73, backpage},
X {SPEC|75, backchar},
X {SPEC|77, forwchar},
X {SPEC|79, gotoeob},
X {SPEC|80, forwline},
X {SPEC|81, forwpage},
X {SPEC|82, insspace},
X {SPEC|83, forwdel},
X {SPEC|115, backword},
X {SPEC|116, forwword},
X {SPEC|132, gotobop},
X {SPEC|118, gotoeop},
X#endif
X
X#if HP150
X {SPEC|32, backline},
X {SPEC|33, forwline},
X {SPEC|35, backchar},
X {SPEC|34, forwchar},
X {SPEC|44, gotobob},
X {SPEC|46, forwpage},
X {SPEC|47, backpage},
X {SPEC|82, nextwind},
X {SPEC|68, openline},
X {SPEC|69, killtext},
X {SPEC|65, forwdel},
X {SPEC|64, ctlxe},
X {SPEC|67, refresh},
X {SPEC|66, reposition},
X {SPEC|83, help},
X {SPEC|81, deskey},
X#endif
X
X#if AMIGA
X {SPEC|'?', help},
X {SPEC|'A', backline},
X {SPEC|'B', forwline},
X {SPEC|'C', forwchar},
X {SPEC|'D', backchar},
X {SPEC|'T', backpage},
X {SPEC|'S', forwpage},
X {SPEC|'a', backword},
X {SPEC|'`', forwword},
X#endif
X
X {0x7F, backdel},
X {0, NULL}
X};
X
X#if RAINBOW
X
X#include "rainbow.h"
X
X/*
X * Mapping table from the LK201 function keys to the internal EMACS character.
X */
X
Xshort lk_map[][2] = {
X Up_Key, CTRL+'P',
X Down_Key, CTRL+'N',
X Left_Key, CTRL+'B',
X Right_Key, CTRL+'F',
X Shift+Left_Key, META+'B',
X Shift+Right_Key, META+'F',
X Control+Left_Key, CTRL+'A',
X Control+Right_Key, CTRL+'E',
X Prev_Scr_Key, META+'V',
X Next_Scr_Key, CTRL+'V',
X Shift+Up_Key, META+'<',
X Shift+Down_Key, META+'>',
X Cancel_Key, CTRL+'G',
X Find_Key, CTRL+'S',
X Shift+Find_Key, CTRL+'R',
X Insert_Key, CTRL+'Y',
X Options_Key, CTRL+'D',
X Shift+Options_Key, META+'D',
X Remove_Key, CTRL+'W',
X Shift+Remove_Key, META+'W',
X Select_Key, CTRL+'@',
X Shift+Select_Key, CTLX+CTRL+'X',
X Interrupt_Key, CTRL+'U',
X Keypad_PF2, META+'L',
X Keypad_PF3, META+'C',
X Keypad_PF4, META+'U',
X Shift+Keypad_PF2, CTLX+CTRL+'L',
X Shift+Keypad_PF4, CTLX+CTRL+'U',
X Keypad_1, CTLX+'1',
X Keypad_2, CTLX+'2',
X Do_Key, CTLX+'E',
X Keypad_4, CTLX+CTRL+'B',
X Keypad_5, CTLX+'B',
X Keypad_6, CTLX+'K',
X Resume_Key, META+'!',
X Control+Next_Scr_Key, CTLX+'N',
X Control+Prev_Scr_Key, CTLX+'P',
X Control+Up_Key, CTLX+CTRL+'P',
X Control+Down_Key, CTLX+CTRL+'N',
X Help_Key, CTLX+'=',
X Shift+Do_Key, CTLX+'(',
X Control+Do_Key, CTLX+')',
X Keypad_0, CTLX+'Z',
X Shift+Keypad_0, CTLX+CTRL+'Z',
X Main_Scr_Key, CTRL+'C',
X Keypad_Enter, CTLX+'!',
X Exit_Key, CTLX+CTRL+'C',
X Shift+Exit_Key, CTRL+'Z'
X};
X
X#define lk_map_size (sizeof(lk_map)/2)
X#endif
X
*-*-END-of-ebind.h-*-*
echo x - edef.h
sed 's/^X//' >edef.h <<'*-*-END-of-edef.h-*-*'
X/* EDEF: Global variable definitions for
X MicroEMACS 3.2
X
X written by Dave G. Conroy
X modified by Steve Wilhite, George Jones
X greatly modified by Daniel Lawrence
X*/
X
X#ifdef maindef
X
X/* for MAIN.C */
X
X/* initialized global definitions */
X
Xint fillcol = 72; /* Current fill column */
Xshort kbdm[NKBDM] = {CTLX|')'}; /* Macro */
Xchar pat[NPAT]; /* Search pattern */
Xchar rpat[NPAT]; /* replacement pattern */
Xchar sarg[NSTRING] = ""; /* string argument for line exec*/
Xint eolexist = TRUE; /* does clear to EOL exist */
Xint revexist = FALSE; /* does reverse video exist? */
Xchar *modename[] = { /* name of modes */
X "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER"};
Xchar modecode[] = "WCSEVO"; /* letters to represent modes */
Xint gmode = 0; /* global editor mode */
Xint sgarbf = TRUE; /* TRUE if screen is garbage */
Xint mpresf = FALSE; /* TRUE if message in last line */
Xint clexec = FALSE; /* command line execution flag */
X
X/* uninitialized global definitions */
X
Xint currow; /* Cursor row */
Xint curcol; /* Cursor column */
Xint thisflag; /* Flags, this command */
Xint lastflag; /* Flags, last command */
Xint curgoal; /* Goal for C-P, C-N */
XWINDOW *curwp; /* Current window */
XBUFFER *curbp; /* Current buffer */
XWINDOW *wheadp; /* Head of list of windows */
XBUFFER *bheadp; /* Head of list of buffers */
XBUFFER *blistp; /* Buffer for C-X C-B */
Xshort *kbdmip; /* Input pointer for above */
Xshort *kbdmop; /* Output pointer for above */
X
XBUFFER *bfind(); /* Lookup a buffer by name */
XWINDOW *wpopup(); /* Pop up window creation */
XLINE *lalloc(); /* Allocate a line */
X
X#else
X
X/* for all the other .C files */
X
X/* initialized global external declarations */
X
Xextern int fillcol; /* Fill column */
Xextern short kbdm[]; /* Holds kayboard macro data */
Xextern char pat[]; /* Search pattern */
Xextern char rpat[]; /* Replacement pattern */
Xextern char sarg[]; /* string argument for line exec*/
Xextern int eolexist; /* does clear to EOL exist? */
Xextern int revexist; /* does reverse video exist? */
Xextern char *modename[]; /* text names of modes */
Xextern char modecode[]; /* letters to represent modes */
Xextern KEYTAB keytab[]; /* key bind to functions table */
Xextern NBIND names[]; /* name to function table */
Xextern int gmode; /* global editor mode */
Xextern int sgarbf; /* State of screen unknown */
Xextern int mpresf; /* Stuff in message line */
Xextern int clexec; /* command line execution flag */
X
X/* initialized global external declarations */
X
Xextern int currow; /* Cursor row */
Xextern int curcol; /* Cursor column */
Xextern int thisflag; /* Flags, this command */
Xextern int lastflag; /* Flags, last command */
Xextern int curgoal; /* Goal for C-P, C-N */
Xextern WINDOW *curwp; /* Current window */
Xextern BUFFER *curbp; /* Current buffer */
Xextern WINDOW *wheadp; /* Head of list of windows */
Xextern BUFFER *bheadp; /* Head of list of buffers */
Xextern BUFFER *blistp; /* Buffer for C-X C-B */
Xextern short *kbdmip; /* Input pointer for above */
Xextern short *kbdmop; /* Output pointer for above */
X
Xextern BUFFER *bfind(); /* Lookup a buffer by name */
Xextern WINDOW *wpopup(); /* Pop up window creation */
Xextern LINE *lalloc(); /* Allocate a line */
X
X#endif
X
X/* terminal table defined only in TERM.C */
X
X#ifndef termdef
Xextern TERM term; /* Terminal information. */
X#endif
X
X
*-*-END-of-edef.h-*-*
echo x - efunc.h
sed 's/^X//' >efunc.h <<'*-*-END-of-efunc.h-*-*'
X/* EFUNC.H: MicroEMACS function declarations and names
X
X This file list all the C code functions used by MicroEMACS
X and the names to use to bind keys to them. To add functions,
X declare it here in both the extern function list and the name
X binding table.
X
X Update History:
X
X Daniel Lawrence
X 29-jan-86
X - separeted out external declarations to a separate .h file
X - built original name to function binding table
X 30-jan-86
X - added command declarations for Fill Paragraph command
X 11-feb-86
X - added declaration for help and describe key commands
X 13-feb-86
X - added declarations for view-file command
X 15-feb-86
X - added declataitons for insert file command
X 17-feb-86
X - added declarations for scroll next window up/down
X 20-feb-86
X - expanded binding table to make room for new bindings
X 24-feb-86
X - added declarations for bind-to-key and unbind-key
X execute named command and describe bindings
X 26-feb-86
X - added declarations for execute command
X - changed name of "visit-file" to "find-file"
X - added declaration for execute-buffer command
X 27-feb-86
X - added declarations for execute-file command
X 3-apr-86
X - added declarations for next-buffer command
X 5-apr-86
X - added declarations for kill-paragraph command
X 8-apr-86
X - added declarations for add/delete global mode
X 8-apr-86
X - added declarations for insert space command
X*/
X
X/* External function declarations */
X
Xextern int ctrlg(); /* Abort out of things */
Xextern int quit(); /* Quit */
Xextern int ctlxlp(); /* Begin macro */
Xextern int ctlxrp(); /* End macro */
Xextern int ctlxe(); /* Execute macro */
Xextern int fileread(); /* Get a file, read only */
Xextern int filefind(); /* Get a file, read write */
Xextern int filewrite(); /* Write a file */
Xextern int filesave(); /* Save current file */
Xextern int filename(); /* Adjust file name */
Xextern int getccol(); /* Get current column */
Xextern int gotobol(); /* Move to start of line */
Xextern int forwchar(); /* Move forward by characters */
Xextern int gotoeol(); /* Move to end of line */
Xextern int backchar(); /* Move backward by characters */
Xextern int forwline(); /* Move forward by lines */
Xextern int backline(); /* Move backward by lines */
Xextern int forwpage(); /* Move forward by pages */
Xextern int backpage(); /* Move backward by pages */
Xextern int gotobob(); /* Move to start of buffer */
Xextern int gotoeob(); /* Move to end of buffer */
Xextern int setfillcol(); /* Set fill column. */
Xextern int setmark(); /* Set mark */
Xextern int swapmark(); /* Swap "." and mark */
Xextern int forwsearch(); /* Search forward */
Xextern int backsearch(); /* Search backwards */
Xextern int sreplace(); /* search and replace */
Xextern int qreplace(); /* search and replace w/query */
Xextern int showcpos(); /* Show the cursor position */
Xextern int nextwind(); /* Move to the next window */
Xextern int prevwind(); /* Move to the previous window */
Xextern int onlywind(); /* Make current window only one */
Xextern int splitwind(); /* Split current window */
Xextern int mvdnwind(); /* Move window down */
Xextern int mvupwind(); /* Move window up */
Xextern int enlargewind(); /* Enlarge display window. */
Xextern int shrinkwind(); /* Shrink window. */
Xextern int listbuffers(); /* Display list of buffers */
Xextern int usebuffer(); /* Switch a window to a buffer */
Xextern int killbuffer(); /* Make a buffer go away. */
Xextern int reposition(); /* Reposition window */
Xextern int refresh(); /* Refresh the screen */
Xextern int twiddle(); /* Twiddle characters */
Xextern int tab(); /* Insert tab */
Xextern int newline(); /* Insert CR-LF */
Xextern int indent(); /* Insert CR-LF, then indent */
Xextern int openline(); /* Open up a blank line */
Xextern int deblank(); /* Delete blank lines */
Xextern int quote(); /* Insert literal */
Xextern int backword(); /* Backup by words */
Xextern int forwword(); /* Advance by words */
Xextern int forwdel(); /* Forward delete */
Xextern int backdel(); /* Backward delete */
Xextern int killtext(); /* Kill forward */
Xextern int yank(); /* Yank back from killbuffer. */
Xextern int upperword(); /* Upper case word. */
Xextern int lowerword(); /* Lower case word. */
Xextern int upperregion(); /* Upper case region. */
Xextern int lowerregion(); /* Lower case region. */
Xextern int capword(); /* Initial capitalize word. */
Xextern int delfword(); /* Delete forward word. */
Xextern int delbword(); /* Delete backward word. */
Xextern int killregion(); /* Kill region. */
Xextern int copyregion(); /* Copy region to kill buffer. */
Xextern int spawncli(); /* Run CLI in a subjob. */
Xextern int spawn(); /* Run a command in a subjob. */
Xextern int quickexit(); /* low keystroke style exit. */
Xextern int setmode(); /* set an editor mode */
Xextern int delmode(); /* delete a mode */
Xextern int gotoline(); /* go to a numbered line */
Xextern int namebuffer(); /* rename the current buffer */
Xextern int gotobop(); /* go to begining/paragraph */
Xextern int gotoeop(); /* go to end/paragraph */
Xextern int fillpara(); /* fill current paragraph */
Xextern int help(); /* get the help file here */
Xextern int deskey(); /* describe a key's binding */
Xextern int viewfile(); /* find a file in view mode */
Xextern int insfile(); /* insert a file */
Xextern int scrnextup(); /* scroll next window back */
Xextern int scrnextdw(); /* scroll next window down */
Xextern int bindtokey(); /* bind a function to a key */
Xextern int unbindkey(); /* unbind a key's function */
Xextern int namedcmd(); /* execute named command */
Xextern int desbind(); /* describe bindings */
Xextern int execcmd(); /* execute a command line */
Xextern int execbuf(); /* exec commands from a buffer */
Xextern int execfile(); /* exec commands from a file */
Xextern int nextbuffer(); /* switch to the next buffer */
Xextern int killpara(); /* kill the current paragraph */
Xextern int setgmode(); /* set a global mode */
Xextern int delgmode(); /* delete a global mode */
Xextern int insspace(); /* insert a space forword */
Xextern int forwhunt(); /* hunt forward for next match */
Xextern int backhunt(); /* hunt backwards for next match*/
X
X#if V7 & BSD
Xextern int bktoshell(); /* suspend emacs to parent shell*/
Xextern int rtfrmshell(); /* return from a suspended state*/
X#endif
X
X/* Name to function binding table
X
X This table gives the names of all the bindable functions
X end their C function address. These are used for the bind-to-key
X function.
X*/
X
XNBIND names[] = {
X {"add-mode", setmode},
X {"add-global-mode", setgmode},
X {"backward-character", backchar},
X {"begin-macro", ctlxlp},
X {"begining-of-file", gotobob},
X {"begining-of-line", gotobol},
X {"bind-to-key", bindtokey},
X {"buffer-position", showcpos},
X {"case-region-lower", lowerregion},
X {"case-region-upper", upperregion},
X {"case-word-capitalize", capword},
X {"case-word-lower", lowerword},
X {"case-word-upper", upperword},
X {"change-file-name", filename},
X {"clear-and-redraw", refresh},
X {"copy-region", copyregion},
X {"delete-blank-lines", deblank},
X {"delete-buffer", killbuffer},
X {"delete-mode", delmode},
X {"delete-global-mode", delgmode},
X {"delete-next-character", forwdel},
X {"delete-next-word", delfword},
X {"delete-other-windows", onlywind},
X {"delete-previous-character", backdel},
X {"delete-previous-word", delbword},
X {"describe-bindings", desbind},
X {"describe-key", deskey},
X {"end-macro", ctlxrp},
X {"end-of-file", gotoeob},
X {"end-of-line", gotoeol},
X {"exchange-point-and-mark", swapmark},
X {"execute-buffer", execbuf},
X {"execute-command-line", execcmd},
X {"execute-file", execfile},
X {"execute-macro", ctlxe},
X {"execute-named-command", namedcmd},
X {"exit-emacs", quit},
X {"fill-paragraph", fillpara},
X {"find-file", filefind},
X {"forward-character", forwchar},
X {"goto-line", gotoline},
X {"grow-window", enlargewind},
X {"handle-tab", tab},
X {"hunt-forward", forwhunt},
X {"hunt-backward", backhunt},
X {"help", help},
X {"i-shell", spawncli},
X {"insert-file", insfile},
X {"insert-space", insspace},
X {"kill-paragraph", killpara},
X {"kill-region", killregion},
X {"kill-to-end-of-line", killtext},
X {"list-buffers", listbuffers},
X {"move-window-down", mvdnwind},
X {"move-window-up", mvupwind},
X {"name-buffer", namebuffer},
X {"newline", newline},
X {"newline-and-indent", indent},
X {"next-buffer", nextbuffer},
X {"next-line", forwline},
X {"next-page", forwpage},
X {"next-paragraph", gotoeop},
X {"next-window", nextwind},
X {"next-word", forwword},
X {"open-line", openline},
X {"previous-line", backline},
X {"previous-page", backpage},
X {"previous-paragraph", gotobop},
X {"previous-window", prevwind},
X {"previous-word", backword},
X {"query-replace-string", qreplace},
X {"quick-exit", quickexit},
X {"quote-character", quote},
X {"read-file", fileread},
X {"redraw-display", reposition},
X {"replace-string", sreplace},
X {"save-file", filesave},
X {"scroll-next-up", scrnextup},
X {"scroll-next-down", scrnextdw},
X {"search-forward", forwsearch},
X {"search-reverse", backsearch},
X {"select-buffer", usebuffer},
X {"set-fill-column", setfillcol},
X {"set-mark", setmark},
X {"shell-command", spawn},
X {"shrink-window", shrinkwind},
X {"split-current-window", splitwind},
X#if V7 & BSD
X {"suspend-emacs", bktoshell},
X#endif
X {"transpose-characters", twiddle},
X {"unbind-key", unbindkey},
X {"view-file", viewfile},
X {"write-file", filewrite},
X {"yank", yank},
X
X {"", NULL}
X};
*-*-END-of-efunc.h-*-*
echo x - epath.h
sed 's/^X//' >epath.h <<'*-*-END-of-epath.h-*-*'
X/* PATH: This file contains certain info needed to locate the
X MicroEMACS files on a system dependant basis.
X
X */
X
X/* possible names and paths of help files under different OSs */
X
Xchar *pathname[] = {
X
X#if AMIGA
X ".emacsrc",
X "emacs.hlp",
X "",
X ":c/",
X ":t/"
X#endif
X
X#if MSDOS
X "emacs.rc",
X "emacs.hlp",
X "\\sys\\public\\",
X "\\usr\\bin\\",
X "\\bin\\",
X "\\",
X ""
X#endif
X
X#if V7
X ".emacsrc",
X "emacs.hlp",
X "/usr/local/",
X "/usr/lib/",
X ""
X#endif
X
X#if VMS
X "emacs.rc",
X "emacs.hlp",
X "",
X "sys$sysdevice:[vmstools]"
X#endif
X
X};
X
X#define NPNAMES (sizeof(pathname)/sizeof(char *))
*-*-END-of-epath.h-*-*
echo x - ansi.c
sed 's/^X//' >ansi.c <<'*-*-END-of-ansi.c-*-*'
X/*
X * The routines in this file provide support for ANSI style terminals
X * over a serial line. The serial I/O services are provided by routines in
X * "termio.c". It compiles into nothing if not an ANSI device.
X */
X
X#define termdef 1 /* don't define "term" external */
X
X#include <stdio.h>
X#include "estruct.h"
X#include "edef.h"
X
X#if ANSI
X
X#if AMIGA
X#define NROW 23 /* Screen size. */
X#define NCOL 77 /* Edit if you want to. */
X#else
X#define NROW 25 /* Screen size. */
X#define NCOL 80 /* Edit if you want to. */
X#endif
X#define MARGIN 8 /* size of minimim margin and */
X#define SCRSIZ 64 /* scroll size for extended lines */
X#define BEL 0x07 /* BEL character. */
X#define ESC 0x1B /* ESC character. */
X
Xextern int ttopen(); /* Forward references. */
Xextern int ttgetc();
Xextern int ttputc();
Xextern int ttflush();
Xextern int ttclose();
Xextern int ansimove();
Xextern int ansieeol();
Xextern int ansieeop();
Xextern int ansibeep();
Xextern int ansiopen();
Xextern int ansirev();
X/*
X * Standard terminal interface dispatch table. Most of the fields point into
X * "termio" code.
X */
XTERM term = {
X NROW-1,
X NCOL,
X MARGIN,
X SCRSIZ,
X ansiopen,
X ttclose,
X ttgetc,
X ttputc,
X ttflush,
X ansimove,
X ansieeol,
X ansieeop,
X ansibeep,
X ansirev
X};
X
Xansimove(row, col)
X{
X ttputc(ESC);
X ttputc('[');
X ansiparm(row+1);
X ttputc(';');
X ansiparm(col+1);
X ttputc('H');
X}
X
Xansieeol()
X{
X ttputc(ESC);
X ttputc('[');
X ttputc('K');
X}
X
Xansieeop()
X{
X ttputc(ESC);
X ttputc('[');
X ttputc('J');
X}
X
Xansirev(state) /* change reverse video state */
X
Xint state; /* TRUE = reverse, FALSE = normal */
X
X{
X ttputc(ESC);
X ttputc('[');
X ttputc(state ? '7': '0');
X ttputc('m');
X}
X
Xansibeep()
X{
X ttputc(BEL);
X ttflush();
X}
X
Xansiparm(n)
Xregister int n;
X{
X register int q;
X
X q = n/10;
X if (q != 0)
X ansiparm(q);
X ttputc((n%10) + '0');
X}
X
X#endif
X
Xansiopen()
X{
X#if V7
X register char *cp;
X char *getenv();
X
X if ((cp = getenv("TERM")) == NULL) {
X puts("Shell variable TERM not defined!");
X exit(1);
X }
X if (strcmp(cp, "vt100") != 0) {
X puts("Terminal type not 'vt100'!");
X exit(1);
X }
X#endif
X revexist = TRUE;
X ttopen();
X}
*-*-END-of-ansi.c-*-*
echo x - basic.c
sed 's/^X//' >basic.c <<'*-*-END-of-basic.c-*-*'
X/*
X * The routines in this file move the cursor around on the screen. They
X * compute a new value for the cursor, then adjust ".". The display code
X * always updates the cursor location, so only moves between lines, or
X * functions that adjust the top line in the window and invalidate the
X * framing, are hard.
X */
X#include <stdio.h>
X#include "estruct.h"
X#include "edef.h"
X
X/*
X * Move the cursor to the
X * beginning of the current line.
X * Trivial.
X */
Xgotobol(f, n)
X{
X curwp->w_doto = 0;
X return (TRUE);
X}
X
X/*
X * Move the cursor backwards by "n" characters. If "n" is less than zero call
X * "forwchar" to actually do the move. Otherwise compute the new cursor
X * location. Error if you try and move out of the buffer. Set the flag if the
X * line pointer for dot changes.
X */
Xbackchar(f, n)
Xregister int n;
X{
X register LINE *lp;
X
X if (n < 0)
X return (forwchar(f, -n));
X while (n--) {
X if (curwp->w_doto == 0) {
X if ((lp=lback(curwp->w_dotp)) == curbp->b_linep)
X return (FALSE);
X curwp->w_dotp = lp;
X curwp->w_doto = llength(lp);
X curwp->w_flag |= WFMOVE;
X } else
X curwp->w_doto--;
X }
X return (TRUE);
X}
X
X/*
X * Move the cursor to the end of the current line. Trivial. No errors.
X */
Xgotoeol(f, n)
X{
X curwp->w_doto = llength(curwp->w_dotp);
X return (TRUE);
X}
X
X/*
X * Move the cursor forwwards by "n" characters. If "n" is less than zero call
X * "backchar" to actually do the move. Otherwise compute the new cursor
X * location, and move ".". Error if you try and move off the end of the
X * buffer. Set the flag if the line pointer for dot changes.
X */
Xforwchar(f, n)
Xregister int n;
X{
X if (n < 0)
X return (backchar(f, -n));
X while (n--) {
X if (curwp->w_doto == llength(curwp->w_dotp)) {
X if (curwp->w_dotp == curbp->b_linep)
X return (FALSE);
X curwp->w_dotp = lforw(curwp->w_dotp);
X curwp->w_doto = 0;
X curwp->w_flag |= WFMOVE;
X } else
X curwp->w_doto++;
X }
X return (TRUE);
X}
X
Xgotoline(f, n) /* move to a particular line.
X argument (n) must be a positive integer for
X this to actually do anything */
X
X{
X if (n < 1) /* if a bogus argument...then leave */
X return(FALSE);
X
X /* first, we go to the start of the buffer */
X curwp->w_dotp = lforw(curbp->b_linep);
X curwp->w_doto = 0;
X return(forwline(f, n-1));
X}
X
X/*
X * Goto the beginning of the buffer. Massive adjustment of dot. This is
X * considered to be hard motion; it really isn't if the original value of dot
X * is the same as the new value of dot. Normally bound to "M-<".
X */
Xgotobob(f, n)
X{
X curwp->w_dotp = lforw(curbp->b_linep);
X curwp->w_doto = 0;
X curwp->w_flag |= WFHARD;
X return (TRUE);
X}
X
X/*
X * Move to the end of the buffer. Dot is always put at the end of the file
X * (ZJ). The standard screen code does most of the hard parts of update.
X * Bound to "M->".
X */
Xgotoeob(f, n)
X{
X curwp->w_dotp = curbp->b_linep;
X curwp->w_doto = 0;
X curwp->w_flag |= WFHARD;
X return (TRUE);
X}
X
X/*
X * Move forward by full lines. If the number of lines to move is less than
X * zero, call the backward line function to actually do it. The last command
X * controls how the goal column is set. Bound to "C-N". No errors are
X * possible.
X */
Xforwline(f, n)
X{
X register LINE *dlp;
X
X if (n < 0)
X return (backline(f, -n));
X if ((lastflag&CFCPCN) == 0) /* Reset goal if last */
X curgoal = getccol(FALSE); /* not C-P or C-N */
X thisflag |= CFCPCN;
X dlp = curwp->w_dotp;
X while (n-- && dlp!=curbp->b_linep)
X dlp = lforw(dlp);
X curwp->w_dotp = dlp;
X curwp->w_doto = getgoal(dlp);
X curwp->w_flag |= WFMOVE;
X return (TRUE);
X}
X
X/*
X * This function is like "forwline", but goes backwards. The scheme is exactly
X * the same. Check for arguments that are less than zero and call your
X * alternate. Figure out the new line and call "movedot" to perform the
X * motion. No errors are possible. Bound to "C-P".
X */
Xbackline(f, n)
X{
X register LINE *dlp;
X
X if (n < 0)
X return (forwline(f, -n));
X if ((lastflag&CFCPCN) == 0) /* Reset goal if the */
X curgoal = getccol(FALSE); /* last isn't C-P, C-N */
X thisflag |= CFCPCN;
X dlp = curwp->w_dotp;
X while (n-- && lback(dlp)!=curbp->b_linep)
X dlp = lback(dlp);
X curwp->w_dotp = dlp;
X curwp->w_doto = getgoal(dlp);
X curwp->w_flag |= WFMOVE;
X return (TRUE);
X}
X
Xgotobop(f, n) /* go back to the begining of the current paragraph
X here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
X combination to delimit the begining of a paragraph */
X
Xint f, n; /* default Flag & Numeric argument */
X
X{
X register int suc; /* success of last backchar */
X
X if (n < 0) /* the other way...*/
X return(gotoeop(f, -n));
X
X while (n-- > 0) { /* for each one asked for */
X
X /* first scan back until we are in a word */
X suc = backchar(FALSE, 1);
X while (!inword() && suc)
X suc = backchar(FALSE, 1);
X curwp->w_doto = 0; /* and go to the B-O-Line */
X
X /* and scan back until we hit a <NL><NL> or <NL><TAB>
X or a <NL><SPACE> */
X while (lback(curwp->w_dotp) != curbp->b_linep)
X if (llength(curwp->w_dotp) != 0 &&
X lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
X lgetc(curwp->w_dotp, curwp->w_doto) != ' ')
X curwp->w_dotp = lback(curwp->w_dotp);
X else
X break;
X
X /* and then forward until we are in a word */
X suc = forwchar(FALSE, 1);
X while (suc && !inword())
X suc = forwchar(FALSE, 1);
X }
X curwp->w_flag |= WFMOVE; /* force screen update */
X}
X
Xgotoeop(f, n) /* go forword to the end of the current paragraph
X here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
X combination to delimit the begining of a paragraph */
X
Xint f, n; /* default Flag & Numeric argument */
X
X{
X register int suc; /* success of last backchar */
X
X if (n < 0) /* the other way...*/
X return(gotobop(f, -n));
X
X while (n-- > 0) { /* for each one asked for */
X
X /* first scan forward until we are in a word */
X suc = forwchar(FALSE, 1);
X while (!inword() && suc)
X suc = forwchar(FALSE, 1);
X curwp->w_doto = 0; /* and go to the B-O-Line */
X if (suc) /* of next line if not at EOF */
X curwp->w_dotp = lforw(curwp->w_dotp);
X
X /* and scan forword until we hit a <NL><NL> or <NL><TAB>
X or a <NL><SPACE> */
X while (curwp->w_dotp != curbp->b_linep) {
X if (llength(curwp->w_dotp) != 0 &&
X lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
X lgetc(curwp->w_dotp, curwp->w_doto) != ' ')
X curwp->w_dotp = lforw(curwp->w_dotp);
X else
X break;
X }
X
X /* and then backward until we are in a word */
X suc = backchar(FALSE, 1);
X while (suc && !inword()) {
X suc = backchar(FALSE, 1);
X }
X curwp->w_doto = llength(curwp->w_dotp); /* and to the EOL */
X }
X curwp->w_flag |= WFMOVE; /* force screen update */
X}
X
X/*
X * This routine, given a pointer to a LINE, and the current cursor goal
X * column, return the best choice for the offset. The offset is returned.
X * Used by "C-N" and "C-P".
X */
Xgetgoal(dlp)
Xregister LINE *dlp;
X{
X register int c;
X register int col;
X register int newcol;
X register int dbo;
X
X col = 0;
X dbo = 0;
X while (dbo != llength(dlp)) {
X c = lgetc(dlp, dbo);
X newcol = col;
X if (c == '\t')
X newcol |= 0x07;
X else if (c<0x20 || c==0x7F)
X ++newcol;
X ++newcol;
X if (newcol > curgoal)
X break;
X col = newcol;
X ++dbo;
X }
X return (dbo);
X}
X
X/*
X * Scroll forward by a specified number of lines, or by a full page if no
X * argument. Bound to "C-V". The "2" in the arithmetic on the window size is
X * the overlap; this value is the default overlap value in ITS EMACS. Because
X * this zaps the top line in the display window, we have to do a hard update.
X */
Xforwpage(f, n)
Xregister int n;
X{
X register LINE *lp;
X
X if (f == FALSE) {
X n = curwp->w_ntrows - 2; /* Default scroll. */
X if (n <= 0) /* Forget the overlap */
X n = 1; /* if tiny window. */
X } else if (n < 0)
X return (backpage(f, -n));
X#if CVMVAS
X else /* Convert from pages */
X n *= curwp->w_ntrows; /* to lines. */
X#endif
X lp = curwp->w_linep;
X while (n-- && lp!=curbp->b_linep)
X lp = lforw(lp);
X curwp->w_linep = lp;
X curwp->w_dotp = lp;
X curwp->w_doto = 0;
X curwp->w_flag |= WFHARD;
X return (TRUE);
X}
X
X/*
X * This command is like "forwpage", but it goes backwards. The "2", like
X * above, is the overlap between the two windows. The value is from the ITS
X * EMACS manual. Bound to "M-V". We do a hard update for exactly the same
X * reason.
X */
Xbackpage(f, n)
Xregister int n;
X{
X register LINE *lp;
X
X if (f == FALSE) {
X n = curwp->w_ntrows - 2; /* Default scroll. */
X if (n <= 0) /* Don't blow up if the */
X n = 1; /* window is tiny. */
X } else if (n < 0)
X return (forwpage(f, -n));
X#if CVMVAS
X else /* Convert from pages */
X n *= curwp->w_ntrows; /* to lines. */
X#endif
X lp = curwp->w_linep;
X while (n-- && lback(lp)!=curbp->b_linep)
X lp = lback(lp);
X curwp->w_linep = lp;
X curwp->w_dotp = lp;
X curwp->w_doto = 0;
X curwp->w_flag |= WFHARD;
X return (TRUE);
X}
X
X/*
X * Set the mark in the current window to the value of "." in the window. No
X * errors are possible. Bound to "M-.".
X */
Xsetmark(f, n)
X{
X curwp->w_markp = curwp->w_dotp;
X curwp->w_marko = curwp->w_doto;
X mlwrite("[Mark set]");
X return (TRUE);
X}
X
X/*
X * Swap the values of "." and "mark" in the current window. This is pretty
X * easy, bacause all of the hard work gets done by the standard routine
X * that moves the mark about. The only possible error is "no mark". Bound to
X * "C-X C-X".
X */
Xswapmark(f, n)
X{
X register LINE *odotp;
X register int odoto;
X
X if (curwp->w_markp == NULL) {
X mlwrite("No mark in this window");
X return (FALSE);
X }
X odotp = curwp->w_dotp;
X odoto = curwp->w_doto;
X curwp->w_dotp = curwp->w_markp;
X curwp->w_doto = curwp->w_marko;
X curwp->w_markp = odotp;
X curwp->w_marko = odoto;
X curwp->w_flag |= WFMOVE;
X return (TRUE);
X}
*-*-END-of-basic.c-*-*
exit