Annotation of 43BSD/contrib/jove/jove.h, revision 1.1.1.1

1.1       root        1: /*************************************************************************
                      2:  * This program is copyright (C) 1985, 1986 by Jonathan Payne.  It is    *
                      3:  * provided to you without charge for use only on a licensed Unix        *
                      4:  * system.  You may copy JOVE provided that this notice is included with *
                      5:  * the copy.  You may not sell copies of this program or versions        *
                      6:  * modified for use on microcomputer systems, unless the copies are      *
                      7:  * included with a Unix system distribution and the source is provided.  *
                      8:  *************************************************************************/
                      9: 
                     10: /* jove.h header file to be included by EVERYONE */
                     11: 
                     12: #include <setjmp.h>
                     13: #include <sys/types.h>
                     14: 
                     15: #ifndef TUNED
                     16: #   include "tune.h"
                     17: #endif
                     18: 
                     19: #define private        static
                     20: 
                     21: #ifndef BSD4_2
                     22: #   ifdef MENLO_JCL
                     23: #      ifndef EUNICE
                     24: #              define signal   sigset
                     25: #      endif
                     26: #   endif MENLO_JCL
                     27: #endif
                     28: 
                     29: #define EOF    -1
                     30: #define NULL   0
                     31: #define NIL    0
                     32: 
                     33: /* kinds of regular expression compiles */
                     34: #define NORM   0       /* nothing special */
                     35: #define OKAY_RE        1       /* allow regular expressions */
                     36: #define IN_CB  2       /* in curly brace; implies OKAY_RE */
                     37: 
                     38: /* return codes for command completion (all < 0 because >= 0 are
                     39:    legitimate offsets into array of strings */
                     40: 
                     41: #define AMBIGUOUS      -2      /* matches more than one at this point */
                     42: #define UNIQUE         -3      /* matches only one string */
                     43: #define ORIGINAL       -4      /* matches no strings at all! */
                     44: #define NULLSTRING     -5      /* just hit return without typing anything */
                     45: 
                     46: /* values for the `flags' argument to complete */
                     47: #define NOTHING                0       /* opposite of RET_STATE */
                     48: #define RET_STATE      1       /* return state when we hit return */
                     49: #define RCOMMAND       2       /* we are reading a joverc file */
                     50: 
                     51: #define DEFINE         01      /* defining this macro */
                     52: #define EXECUTE                02      /* executing this macro */
                     53: #define SAVE           04      /* this macro needs saving to a file */
                     54: 
                     55: #define        LBSIZE          BUFSIZ  /* same as a logical disk block */
                     56: #define FILESIZE       256
                     57: 
                     58: #define FORWARD                1
                     59: #define BACKWARD       -1
                     60: 
                     61: #define CTL(c)         ('c' & 037)
                     62: #define META(c)                ('c' | 0200)
                     63: #define RUBOUT         '\177'
                     64: #define LF             CTL(J)
                     65: #define CR             CTL(M)
                     66: #define BS             CTL(H)
                     67: #define ESC            `\033'
                     68: 
                     69: #define DoTimes(f, n)  exp_p = 1, exp = n, f
                     70: #define HALF(wp)       ((wp->w_height - 1) / 2)
                     71: #define IsModified(b)  (b->b_modified)
                     72: #define SIZE(wp)       (wp->w_height - 1)
                     73: #define SavLine(a, b)  (a->l_dline = putline(b))
                     74: #define SetLine(line)  DotTo(line, 0)
                     75: #define bobp()         (firstp(curline) && bolp())
                     76: #define bolp()         (curchar == 0)
                     77: #define eobp()         (lastp(curline) && eolp())
                     78: #define eolp()         (linebuf[curchar] == '\0')
                     79: #define firstp(line)   (line == curbuf->b_first)
                     80: #define getDOT()       getline(curline->l_dline, linebuf)
                     81: #define isdirty(line)  (line->l_dline & DIRTY)
                     82: #define lastp(line)    (line == curbuf->b_last)
                     83: #define makedirty(line)        line->l_dline |= DIRTY
                     84: #define one_windp()    (fwind->w_next == fwind)
                     85: 
                     86: extern int     OkayAbort,      /* okay to abort redisplay */
                     87:                BufSize;
                     88: 
                     89: #define ARG_CMD                1
                     90: #define LINECMD                2
                     91: #define KILLCMD                3       /* so we can merge kills */
                     92: #define YANKCMD                4       /* so we can do ESC Y (yank-pop) */
                     93: 
                     94: /* Buffer type */
                     95: 
                     96: #define B_SCRATCH      1       /* for internal things, e.g. minibuffer ... */
                     97: #define B_FILE         2       /* normal file (We Auto-save these.) */
                     98: #define B_PROCESS      3       /* process output in this buffer */
                     99: #define B_IPROCESS     4       /* interactive process attached to this buffer */
                    100: 
                    101: /* Major modes */
                    102: #define FUNDAMENTAL    0       /* Fundamental mode */
                    103: #define TEXT           1       /* Text mode */
                    104: #define CMODE          2       /* C mode */
                    105: #ifdef LISP
                    106: #      define LISPMODE         3       /* Lisp mode */
                    107: #      define NMAJORS          4
                    108: #else
                    109: #      define NMAJORS  3
                    110: #endif
                    111: 
                    112: /* Minor Modes */
                    113: #define Indent         (1 << 0)        /* indent same as previous line after return */
                    114: #define ShowMatch      (1 << 1)        /* paren flash mode */
                    115: #define Fill           (1 << 2)        /* text fill mode */
                    116: #define OverWrite      (1 << 3)        /* over write mode */
                    117: #define Abbrev         (1 << 4)        /* abbrev mode */
                    118: 
                    119: #define BufMinorMode(b, x)     (b->b_minor & x)
                    120: 
                    121: #define MinorMode(x)   BufMinorMode(curbuf, x)
                    122: #define MajorMode(x)   (curbuf->b_major == x)
                    123: #define SetMajor(x)    ((curbuf->b_major = x), UpdModLine++)
                    124: 
                    125: extern char    CharTable[NMAJORS][128];
                    126: 
                    127: /* setjmp/longjmp args for DoKeys() mainjmp */
                    128: #define FIRSTCALL      0
                    129: #define ERROR          1
                    130: #define COMPLAIN       2       /* do the error without a getDOT */
                    131: #define QUIT           3       /* leave this level of recusion */
                    132: 
                    133: #define QUIET          1       /* sure, why not? */
                    134: 
                    135: #define YES            1
                    136: #define NO             0
                    137: #define TRUE           1
                    138: #define FALSE          0
                    139: #define ON             1
                    140: #define OFF            0
                    141: 
                    142: extern char    *Mainbuf,
                    143:                *HomeDir,       /* home directory */
                    144:                key_strokes[],  /* strokes that make up current command */
                    145:                *Inputp;
                    146: 
                    147: extern int     HomeLen;        /* length of home directory */
                    148: 
                    149: extern char    NullStr[];
                    150: 
                    151: #ifdef VMUNIX
                    152: extern char    genbuf[LBSIZE],
                    153:                linebuf[LBSIZE],
                    154:                iobuff[LBSIZE];
                    155: #else
                    156: extern char    *genbuf,        /* scratch pad points at s_genbuf (see main()) */
                    157:                *linebuf,       /* points at s_linebuf */
                    158:                *iobuff;        /* for file reading ... points at s_iobuff */
                    159: #endif
                    160: 
                    161: extern int     InJoverc,
                    162:                Interactive;
                    163: 
                    164: #define        READ    0
                    165: #define        WRITE   1
                    166: extern int     errno;
                    167: 
                    168: extern jmp_buf mainjmp;
                    169: 
                    170: typedef struct window  Window;
                    171: typedef struct position        Bufpos;
                    172: typedef struct mark    Mark;
                    173: typedef struct buffer  Buffer;
                    174: typedef struct line    Line;
                    175: typedef struct iobuf   IOBUF;
                    176: 
                    177: struct line {
                    178:        Line    *l_prev,                /* pointer to prev */
                    179:                *l_next;                /* pointer to next */
                    180:        disk_line       l_dline;        /* pointer to disk location */
                    181: };
                    182: 
                    183: struct window {
                    184:        Window  *w_prev,        /* circular list */
                    185:                *w_next;
                    186:        Buffer  *w_bufp;        /* buffer associated with this window */
                    187:        Line    *w_top,         /* top line */
                    188:                *w_line;        /* current line */
                    189:        int     w_char,
                    190:                w_height,       /* window height */
                    191:                w_topnum,       /* line number of the topline */
                    192:                w_offset,       /* currently unused */
                    193:                w_numlines,     /* display line numbervs in this window? */
                    194:                w_visspace,     /* display whitespace visibly? */
                    195:                w_dotcol,       /* UpdWindow sets this ... */
                    196:                w_dotline,      /* ... and this */
                    197:                w_flags;
                    198: #define        TOPGONE 01
                    199: #define        CURGONE 02      /* topline (curline) of window has been deleted
                    200:                           since the last time a redisplay was called */
                    201: };
                    202: 
                    203: extern Window  *fwind,         /* first window in list */
                    204:                *curwind;       /* current window */
                    205: 
                    206: struct position {
                    207:        Line    *p_line;
                    208:        int     p_char;
                    209: };
                    210: 
                    211: struct mark {
                    212:        Line    *m_line;
                    213:        int     m_char;
                    214:        Mark    *m_next;        /* list of marks */
                    215: #define FLOATER        1
                    216:        char    m_floater;      /* FLOATERing mark? */
                    217: };
                    218: 
                    219: struct buffer {
                    220:        Buffer  *b_next;                /* next buffer in chain */
                    221:        char    *b_name,                /* buffer name */
                    222:                *b_fname;               /* file name associated with buffer */
                    223:        ino_t   b_ino;                  /* inode of file name */
                    224:        time_t  b_mtime;                /* last modify time ...
                    225:                                           to detect two people writing
                    226:                                           to the same file */
                    227:        Line    *b_first,               /* pointer to first line in list */
                    228:                *b_dot,                 /* current line */
                    229:                *b_last;                /* last line in list */
                    230:        int     b_char;                 /* current character in line */
                    231: 
                    232: #define NMARKS 16                      /* number of marks in the ring */
                    233: 
                    234:        Mark    *b_markring[NMARKS],    /* new marks are pushed saved here */
                    235:                *b_marks;               /* all the marks for this buffer */
                    236:        int     b_themark;              /* current mark */
                    237:        char    b_type,                 /* file, scratch, process, iprocess */
                    238:                b_ntbf,                 /* needs to be found when we
                    239:                                           first select? */
                    240:                b_modified;             /* is the buffer modified? */
                    241:        int     b_major,                /* major mode */
                    242:                b_minor;                /* and minor mode */
                    243: };
                    244: 
                    245: struct macro {
                    246:        int     Type;           /* in this case a macro */
                    247:        char    *Name;          /* name is always second ... */
                    248:        int     m_len,          /* length of macro so we can use ^@ */
                    249:                m_buflen,       /* memory allocated for it */
                    250:                m_offset,       /* index into body for defining and running */
                    251:                m_flags,        /* defining/running this macro? */
                    252:                m_ntimes;       /* number of times to run this macro */
                    253:        char    *m_body;        /* actual body of the macro */
                    254:        struct macro
                    255:                *m_nextm;
                    256: };
                    257: 
                    258: struct variable {
                    259:        int     Type;           /* in this case a variable */
                    260:        char    *Name;          /* name is always second */
                    261:        int     *v_value,
                    262:                v_flags;
                    263: };
                    264: 
                    265: struct cmd {
                    266:        int     Type;
                    267:        char    *Name;
                    268:        int     (*c_proc)();
                    269: };
                    270: 
                    271: typedef struct data_obj {
                    272:        int     Type;
                    273:        char    *Name;
                    274: } data_obj;    /* points to cmd, macro, or variable */
                    275: 
                    276: extern data_obj
                    277:        *mainmap[],     /* various key maps */
                    278:        *pref1map[],
                    279:        *pref2map[],
                    280:        *miscmap[],
                    281:        *LastCmd;       /* Last command invoked */
                    282: 
                    283: extern char    *ProcFmt;
                    284: 
                    285: extern struct cmd      commands[];
                    286: extern struct macro    *macros;
                    287: extern struct variable variables[];
                    288: 
                    289: extern struct macro
                    290:        *macstack[],
                    291:        KeyMacro;
                    292: 
                    293: #define FUNCTION       1
                    294: #define VARIABLE       2
                    295: #define MACRO          3
                    296: #define TYPEMASK       07
                    297: #define MAJOR_MODE     010
                    298: #define MINOR_MODE     020
                    299: #define DefMajor(x)    (FUNCTION|MAJOR_MODE|(x << 8))
                    300: #define DefMinor(x)    (FUNCTION|MINOR_MODE|(x << 8))
                    301: 
                    302: extern Buffer  *world,                 /* first buffer */
                    303:                *curbuf;                /* pointer into world for current buffer */
                    304: 
                    305: #define NUMKILLS       10      /* number of kills saved in the kill ring */
                    306: 
                    307: #define DIRTY          01      /* just needs updating for some reason */
                    308: #define MODELINE       02      /* this is a modeline */
                    309: #define L_MOD          04      /* this line has been modified internally */
                    310: 
                    311: struct scrimage {
                    312:        int     s_offset,       /* offset to start printing at */
                    313:                s_flags,        /* various flags */
                    314:                s_id,           /* which buffer line */
                    315:                s_vln;          /* Visible Line Number */
                    316:        Line    *s_lp;          /* so we can turn off red bit */
                    317:        Window  *s_window;      /* window that contains this line */
                    318: };
                    319: 
                    320: extern struct scrimage
                    321:        *DesiredScreen,         /* what we want */
                    322:        *PhysScreen;            /* what we got */
                    323: 
                    324: /* Variable flags (that can be set). */
                    325: #define V_BASE10       01      /* is integer in base 10 */
                    326: #define V_BASE8                02      /* is integer in base 8 */
                    327: #define V_BOOL         04      /* is a boolean */
                    328: #define V_STRING       010     /* is a string */
                    329: #define V_CHAR         020     /* is a character */
                    330: #define V_TYPEMASK     037     /* mask off the display bits */
                    331: #define V_MODELINE     040     /* update modeline */
                    332: #define V_CLRSCREEN    0100    /* clear and redraw screen */
                    333: #define V_TTY_RESET    0200    /* redo the tty modes because we may want
                    334:                                   to change some things */
                    335: 
                    336: extern int
                    337:        OKXonXoff,              /* disable start/stop characters */
                    338:        MetaKey,                /* this terminal has a meta key */
                    339:        VisBell,                /* use visible bell (if possible) */
                    340:        WrapScan,               /* make searches wrap */
                    341:        phystab,                /* terminal's tabstop settings */ 
                    342:        tabstop,                /* expand tabs to this number of spaces */
                    343: #ifdef BACKUPFILES
                    344:        BkupOnWrite,            /* make backup files when writing */
                    345: #endif
                    346:        RMargin,                /* right margin */
                    347:        LMargin,                /* left margin */
                    348:        ScrollStep,             /* how should we scroll */
                    349:        WtOnMk,                 /* write files on compile-it command */
                    350:        EndWNewline,            /* end files with a blank line */
                    351:        MarkThresh,             /* moves greater than MarkThresh
                    352:                                   will SetMark */
                    353:        PDelay,                 /* paren flash delay in tenths of a second */
                    354:        CIndIncrmt,             /* how much each indentation level pushes
                    355:                                   over in C mode */
                    356:        CreatMode,              /* default mode for creat'ing files */
                    357:        CaseIgnore,             /* case ignore search */
                    358: #ifdef ABBREV
                    359:        AutoCaseAbbrev,         /* automatically do case on abbreviations */
                    360: #endif
                    361:        MarksShouldFloat,       /* adjust marks on insertion/deletion */
                    362:        UseRE,                  /* use regular expressions in search */
                    363:        SyncFreq,               /* how often to sync the file pointers */
                    364:        BriteMode,              /* make the mode line inverse? */
                    365:        OkayBadChars,           /* allow bad characters in files created
                    366:                                   by JOVE */
                    367:        UpdFreq,                /* how often to update modeline */
                    368:        UseBuffers,             /* use buffers with Typeout() */
                    369: #ifdef BIFF
                    370:        BiffChk,                /* turn off/on biff with entering/exiting jove */
                    371: #endif
                    372:        MailInt,                /* mail check interval */
                    373: #ifdef ID_CHAR
                    374:        UseIC,                  /* whether or not to use i/d char
                    375:                                   processesing */
                    376:        SExitChar,              /* type this to stop i-search */
                    377: #endif
                    378:        EWSize;                 /* size to make the error window */
                    379: 
                    380: extern char
                    381: #ifdef IPROCS
                    382:        proc_prompt[80],        /* process prompt */
                    383: #endif
                    384: #ifdef F_COMPLETION
                    385:        BadExtensions[128],     /* extensions (e.g., ".o" to ignore) */
                    386: #endif
                    387: #ifdef CMT_FMT
                    388:        CmtFmt[80],
                    389: #endif
                    390:        ModeFmt[120],           /* mode line format string */
                    391:        Mailbox[128],           /* mailbox name */
                    392:        TagFile[128],           /* default tag file */
                    393:        Shell[40];              /* shell to use */
                    394: 
                    395: extern int
                    396:        exp,            /* argument count */
                    397:        exp_p,          /* argument count is supplied */
                    398: 
                    399:        TOabort,        /* flag set by Typeout() */
                    400:        io,             /* file descriptor for reading and writing files */
                    401:        errormsg,       /* last message was an error message
                    402:                           so don't erase the error before it
                    403:                           has been read */
                    404:        this_cmd,       /* ... */
                    405:        last_cmd,       /* last command ... to implement appending
                    406:                           to kill buffer */
                    407:        RecDepth,       /* recursion depth */
                    408:        InputPending,   /* nonzero if there is input waiting to
                    409:                           be processed */
                    410:        killptr,        /* index into killbuf */
                    411:        CanScroll,      /* can this terminal scroll? */
                    412:        Crashing,       /* we are in the middle of crashing */
                    413:        Asking,         /* are we on read a string from the terminal? */
                    414:        inIOread;       /* so we know whether we can do a redisplay. */
                    415: 
                    416: extern char    Minibuf[LBSIZE];
                    417: 
                    418: #define curline        curbuf->b_dot
                    419: #define curchar curbuf->b_char
                    420: 
                    421: #define curmark                (curbuf->b_markring[curbuf->b_themark])
                    422: #define b_curmark(b)   (b->b_markring[b->b_themark])
                    423: 
                    424: extern Line    *killbuf[NUMKILLS];     /* array of pointers to killed stuff */
                    425: 
                    426: #define MESG_SIZE 128
                    427: extern char    mesgbuf[MESG_SIZE];
                    428: 
                    429: struct screenline {
                    430:        char    *s_line,
                    431:                *s_length;
                    432: };
                    433: 
                    434: extern int
                    435:        LastKeyStruck;
                    436: 
                    437: extern int
                    438:        stackp,
                    439: 
                    440:        CapLine,        /* cursor line and cursor column */
                    441:        CapCol,
                    442: 
                    443:        UpdModLine,     /* whether we want to update the mode line */
                    444:        UpdMesg;        /* update the message line */
                    445: 
                    446: #define CATCH \
                    447: {\
                    448:        jmp_buf sav_jmp; \
                    449: \
                    450:        push_env(sav_jmp); \
                    451:        if (setjmp(mainjmp) == 0) {
                    452: 
                    453: #define ONERROR \
                    454:        } else { \
                    455: 
                    456: #define ENDCATCH \
                    457:        } \
                    458:        pop_env(sav_jmp); \
                    459: }
                    460: 
                    461: extern int
                    462:        read(),
                    463:        write();
                    464:        getch();
                    465: 
                    466: extern time_t  time();
                    467: extern long    lseek();
                    468: 
                    469: extern disk_line
                    470:        putline();
                    471: 
                    472: extern data_obj
                    473:        *findcom(),
                    474:        *findvar(),
                    475:        *findmac();
                    476: 
                    477: extern Line
                    478:        *next_line(),
                    479:        *prev_line(),
                    480:        *nbufline(),
                    481:        *reg_delete(),
                    482:        *lastline(),
                    483:        *listput();
                    484: 
                    485: extern char
                    486:        *getsearch(),
                    487:        *pwd(),
                    488:        *itoa(),
                    489:        *get_time(),
                    490:        *copystr(),
                    491:        *basename(),
                    492:        *filename(),
                    493:        *getblock(),
                    494:        *IOerr(),
                    495:        *index(),
                    496:        *ask(),
                    497:        *do_ask(),
                    498:        *ask_buf(),
                    499:        *ask_file(),
                    500:        *getline(),
                    501:        *lcontents(),
                    502:        *getblock(),
                    503:        *malloc(),
                    504:        *emalloc(),
                    505:        *mktemp(),
                    506:        *realloc(),
                    507:        *ltobuf(),
                    508:        *lbptr(),
                    509:        *rindex(),
                    510:        *getenv(),
                    511:        *tgoto(),
                    512:        *pr_name(),
                    513:        *sprint(),
                    514:        *StrIndex();
                    515: 
                    516: extern Bufpos
                    517:        *docompiled(),
                    518:        *dosearch(),
                    519:        *DoYank(),
                    520:        *c_indent(),
                    521: #ifdef LISP
                    522:        *lisp_indent(),
                    523: #endif
                    524:        *m_paren();
                    525: 
                    526: extern Mark
                    527:        *CurMark(),
                    528:        *MakeMark();
                    529: 
                    530: extern Window
                    531:        *windlook(),
                    532:        *windbp(),
                    533:        *div_wind();
                    534: 
                    535: extern data_obj
                    536:        **IsPrefix();
                    537: 
                    538: extern Buffer
                    539:        *do_find(),
                    540:        *do_select(),
                    541:        *mak_buf(),
                    542:        *buf_exists(),
                    543:        *file_exists();
                    544: 
                    545: struct cmd *
                    546:        FindCmd();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.