[BACK]Return to def.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Annotation of src/usr.bin/mg/def.h, Revision 1.4

1.1       deraadt     1: /*
                      2:  * This file is the general header file for all parts
1.4     ! millert     3:  * of the Mg display editor. It contains all of the
1.1       deraadt     4:  * general definitions and macros. It also contains some
                      5:  * conditional compilation flags. All of the per-system and
                      6:  * per-terminal definitions are in special header files.
                      7:  * The most common reason to edit this file would be to zap
                      8:  * the definition of CVMVAS or BACKUP.
                      9:  */
1.4     ! millert    10: #include       "sysdef.h"      /* Order is critical.            */
1.1       deraadt    11: #include       "ttydef.h"
                     12: #include       "chrdef.h"
                     13:
                     14: /*
                     15:  * If your system and/or compiler does not support the "void" type
                     16:  * then define NO_VOID_TYPE in sysdef.h.  In the absence of some
                     17:  * other definition for VOID, the default in that case will be to
                     18:  * turn it into an int, which works with most compilers that don't
                     19:  * support void.  In the absence of any definition of VOID or
                     20:  * NO_VOID_TYPE, the default is to assume void is supported, which
                     21:  * should be the case for most modern C compilers.
                     22:  */
                     23:
                     24: #ifdef NO_VOID_TYPE
1.4     ! millert    25: #undef VOID
        !            26: #define VOID int               /* Default for no void is int */
1.1       deraadt    27: #else
                     28: #ifndef VOID
1.4     ! millert    29: #define VOID void              /* Just use normal void */
        !            30: #endif                         /* VOID */
        !            31: #endif                         /* NO_VOID_TYPE */
1.1       deraadt    32:
                     33: #ifdef NO_MACRO
                     34: #ifndef NO_STARTUP
1.4     ! millert    35: #define NO_STARTUP             /* NO_MACRO implies NO_STARTUP */
1.1       deraadt    36: #endif
                     37: #endif
                     38:
1.4     ! millert    39: typedef int     (*PF) ();      /* generaly useful type */
1.1       deraadt    40:
                     41: /*
                     42:  * Table sizes, etc.
                     43:  */
1.4     ! millert    44: #define NFILEN 80              /* Length, file name.            */
        !            45: #define NBUFN  24              /* Length, buffer name.          */
        !            46: #define NLINE  256             /* Length, line.                 */
        !            47: #define PBMODES 4              /* modes per buffer              */
        !            48: #define NKBDM  256             /* Length, keyboard macro.       */
        !            49: #define NPAT   80              /* Length, pattern.              */
        !            50: #define HUGE   1000            /* A rather large number.        */
        !            51: #define NSRCH  128             /* Undoable search commands.     */
        !            52: #define NXNAME 64              /* Length, extended command.     */
        !            53: #define NKNAME 20              /* Length, key names             */
1.1       deraadt    54: /*
                     55:  * Universal.
                     56:  */
1.4     ! millert    57: #define FALSE  0               /* False, no, bad, etc.          */
        !            58: #define TRUE   1               /* True, yes, good, etc.         */
        !            59: #define ABORT  2               /* Death, ^G, abort, etc.        */
1.1       deraadt    60:
1.4     ! millert    61: #define KPROMPT 2              /* keyboard prompt               */
1.1       deraadt    62:
                     63: /*
                     64:  * These flag bits keep track of
                     65:  * some aspects of the last command. The CFCPCN
                     66:  * flag controls goal column setting. The CFKILL
                     67:  * flag controls the clearing versus appending
                     68:  * of data in the kill buffer.
                     69:  */
1.4     ! millert    70: #define CFCPCN 0x0001          /* Last command was C-P, C-N     */
        !            71: #define CFKILL 0x0002          /* Last command was a kill       */
        !            72: #define CFINS  0x0004          /* Last command was self-insert */
1.1       deraadt    73:
                     74: /*
                     75:  * File I/O.
                     76:  */
1.4     ! millert    77: #define FIOSUC 0               /* Success.                      */
        !            78: #define FIOFNF 1               /* File not found.               */
        !            79: #define FIOEOF 2               /* End of file.                  */
        !            80: #define FIOERR 3               /* Error.                        */
        !            81: #define FIOLONG 4              /* long line partially read      */
1.1       deraadt    82:
                     83: /*
                     84:  * Directory I/O.
                     85:  */
1.4     ! millert    86: #define DIOSUC 0               /* Success.                      */
        !            87: #define DIOEOF 1               /* End of file.                  */
        !            88: #define DIOERR 2               /* Error.                        */
1.1       deraadt    89:
                     90: /*
                     91:  * Display colors.
                     92:  */
1.4     ! millert    93: #define CNONE  0               /* Unknown color.                */
        !            94: #define CTEXT  1               /* Text color.                   */
        !            95: #define CMODE  2               /* Mode line color.              */
        !            96:
        !            97: /*
        !            98:  * Flags for keyboard involked functions.
        !            99:  */
        !           100: #define FFUNIV         1       /* universal argument            */
        !           101: #define FFNEGARG       2       /* negitive only argument        */
        !           102: #define FFOTHARG       4       /* other argument                */
        !           103: #define FFARG          7       /* any argument                  */
        !           104: #define FFRAND         8       /* Called by other function      */
1.1       deraadt   105:
                    106: /*
                    107:  * Flags for "eread".
                    108:  */
1.4     ! millert   109: #define EFFUNC 0x0001          /* Autocomplete functions.       */
        !           110: #define EFBUF  0x0002          /* Autocomplete buffers.         */
        !           111: #define EFFILE 0x0004          /* " files (maybe someday)       */
        !           112: #define EFAUTO 0x0007          /* Some autocompleteion on       */
        !           113: #define EFNEW  0x0008          /* New prompt.                   */
        !           114: #define EFCR   0x0010          /* Echo CR at end; last read.    */
1.1       deraadt   115:
                    116: /*
                    117:  * Flags for "ldelete"/"kinsert"
                    118:  */
                    119: #define KNONE  0
                    120: #define KFORW  1
                    121: #define KBACK  2
                    122:
                    123: /*
                    124:  * All text is kept in circularly linked
                    125:  * lists of "LINE" structures. These begin at the
                    126:  * header line (which is the blank line beyond the
                    127:  * end of the buffer). This line is pointed to by
                    128:  * the "BUFFER". Each line contains a the number of
                    129:  * bytes in the line (the "used" size), the size
                    130:  * of the text array, and the text. The end of line
                    131:  * is not stored as a byte; it's implied. Future
                    132:  * additions will include update hints, and a
                    133:  * list of marks into the line.
                    134:  */
1.4     ! millert   135: typedef struct LINE {
        !           136:        struct LINE    *l_fp;   /* Link to the next line         */
        !           137:        struct LINE    *l_bp;   /* Link to the previous line     */
        !           138:        int             l_size; /* Allocated size                */
        !           139:        int             l_used; /* Used size                     */
1.1       deraadt   140: #ifndef ZEROARRAY
1.4     ! millert   141:        char            l_text[1];      /* A bunch of chars.     */
1.1       deraadt   142: #else
1.4     ! millert   143:        char            l_text[];       /* A bunch of chars.     */
1.1       deraadt   144: #endif
1.4     ! millert   145: } LINE;
1.1       deraadt   146:
                    147: /*
                    148:  * The rationale behind these macros is that you
                    149:  * could (with some editing, like changing the type of a line
                    150:  * link from a "LINE *" to a "REFLINE", and fixing the commands
                    151:  * like file reading that break the rules) change the actual
                    152:  * storage representation of lines to use something fancy on
                    153:  * machines with small address spaces.
                    154:  */
                    155: #define lforw(lp)      ((lp)->l_fp)
                    156: #define lback(lp)      ((lp)->l_bp)
                    157: #define lgetc(lp, n)   (CHARMASK((lp)->l_text[(n)]))
                    158: #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
                    159: #define llength(lp)    ((lp)->l_used)
                    160: #define ltext(lp)      ((lp)->l_text)
                    161:
                    162: /*
                    163:  * All repeated structures are kept as linked lists of structures.
                    164:  * All of these start with a LIST structure (except lines, which
                    165:  * have their own abstraction). This will allow for
                    166:  * later conversion to generic list manipulation routines should
                    167:  * I decide to do that. it does mean that there are four extra
                    168:  * bytes per window. I feel that this is an acceptable price,
                    169:  * considering that there are usually only one or two windows.
                    170:  */
                    171: typedef struct LIST {
                    172:        union {
1.4     ! millert   173:                struct MGWIN   *l_wp;
        !           174:                struct BUFFER  *x_bp;   /* l_bp is used by LINE */
        !           175:                struct LIST    *l_nxt;
1.1       deraadt   176:        } l_p;
1.4     ! millert   177:        char *l_name;
1.1       deraadt   178: } LIST;
1.4     ! millert   179:
1.1       deraadt   180: /*
                    181:  * Usual hack - to keep from uglifying the code with lotsa
                    182:  * references through the union, we #define something for it.
                    183:  */
                    184: #define l_next l_p.l_nxt
                    185:
                    186: /*
                    187:  * There is a window structure allocated for
                    188:  * every active display window. The windows are kept in a
                    189:  * big list, in top to bottom screen order, with the listhead at
                    190:  * "wheadp". Each window contains its own values of dot and mark.
                    191:  * The flag field contains some bits that are set by commands
                    192:  * to guide redisplay; although this is a bit of a compromise in
                    193:  * terms of decoupling, the full blown redisplay is just too
                    194:  * expensive to run for every input character.
                    195:  */
1.4     ! millert   196: typedef struct MGWIN {
        !           197:        LIST            w_list;         /* List header                  */
        !           198:        struct BUFFER  *w_bufp;         /* Buffer displayed in window   */
        !           199:        struct LINE    *w_linep;        /* Top line in the window       */
        !           200:        struct LINE    *w_dotp;         /* Line containing "."          */
        !           201:        struct LINE    *w_markp;        /* Line containing "mark"       */
        !           202:        int             w_doto;         /* Byte offset for "."          */
        !           203:        int             w_marko;        /* Byte offset for "mark"       */
        !           204:        char            w_toprow;       /* Origin 0 top row of window   */
        !           205:        char            w_ntrows;       /* # of rows of text in window  */
        !           206:        char            w_force;        /* If NZ, forcing row.          */
        !           207:        char            w_flag;         /* Flags.                       */
        !           208: } MGWIN;
1.1       deraadt   209: #define w_wndp w_list.l_p.l_wp
                    210: #define w_name w_list.l_name
                    211:
                    212: /*
                    213:  * Window flags are set by command processors to
                    214:  * tell the display system what has happened to the buffer
                    215:  * mapped by the window. Setting "WFHARD" is always a safe thing
                    216:  * to do, but it may do more work than is necessary. Always try
                    217:  * to set the simplest action that achieves the required update.
                    218:  * Because commands set bits in the "w_flag", update will see
                    219:  * all change flags, and do the most general one.
                    220:  */
1.4     ! millert   221: #define WFFORCE 0x01           /* Force reframe.                */
        !           222: #define WFMOVE 0x02            /* Movement from line to line.   */
        !           223: #define WFEDIT 0x04            /* Editing within a line.        */
        !           224: #define WFHARD 0x08            /* Better to a full display.     */
        !           225: #define WFMODE 0x10            /* Update mode line.             */
1.1       deraadt   226:
                    227: /*
                    228:  * Text is kept in buffers. A buffer header, described
                    229:  * below, exists for every buffer in the system. The buffers are
                    230:  * kept in a big list, so that commands that search for a buffer by
                    231:  * name can find the buffer header. There is a safe store for the
                    232:  * dot and mark in the header, but this is only valid if the buffer
                    233:  * is not being displayed (that is, if "b_nwnd" is 0). The text for
                    234:  * the buffer is kept in a circularly linked list of lines, with
                    235:  * a pointer to the header line in "b_linep".
                    236:  */
1.4     ! millert   237: typedef struct BUFFER {
        !           238:        LIST            b_list;         /* buffer list pointer           */
        !           239:        struct BUFFER  *b_altb;         /* Link to alternate buffer      */
        !           240:        struct LINE    *b_dotp;         /* Link to "." LINE structure    */
        !           241:        struct LINE    *b_markp;        /* ditto for mark                */
        !           242:        struct LINE    *b_linep;        /* Link to the header LINE       */
        !           243:        struct MAPS_S  *b_modes[PBMODES]; /* buffer modes                */
        !           244:        int             b_doto;         /* Offset of "." in above LINE   */
        !           245:        int             b_marko;        /* ditto for the "mark"          */
        !           246:        short           b_nmodes;       /* number of non-fundamental modes */
        !           247:        char            b_nwnd;         /* Count of windows on buffer    */
        !           248:        char            b_flag;         /* Flags                         */
        !           249:        char            b_fname[NFILEN];/* File name                     */
        !           250:        struct fileinfo b_fi;           /* File attributes               */
        !           251: } BUFFER;
1.1       deraadt   252: #define b_bufp b_list.l_p.x_bp
                    253: #define b_bname b_list.l_name
                    254:
1.4     ! millert   255: #define BFCHG  0x01            /* Changed.                      */
        !           256: #define BFBAK  0x02            /* Need to make a backup.        */
1.1       deraadt   257: #ifdef NOTAB
1.4     ! millert   258: #define BFNOTAB 0x04           /* no tab mode                   */
1.1       deraadt   259: #endif
1.4     ! millert   260: #define BFOVERWRITE 0x08       /* overwrite mode                */
1.1       deraadt   261:
                    262: /*
                    263:  * This structure holds the starting position
                    264:  * (as a line/offset pair) and the number of characters in a
                    265:  * region of a buffer. This makes passing the specification
                    266:  * of a region around a little bit easier.
                    267:  */
1.4     ! millert   268: typedef struct {
        !           269:        struct LINE    *r_linep;        /* Origin LINE address.          */
        !           270:        int             r_offset;       /* Origin LINE offset.           */
        !           271:        RSIZE           r_size;         /* Length in characters.         */
        !           272: } REGION;
        !           273:
        !           274: /*
        !           275:  * Prototypes.
        !           276:  */
        !           277:
        !           278: /* tty.c */
        !           279: VOID    ttinit         __P((void));
        !           280: VOID    ttreinit       __P((void));
        !           281: VOID    tttidy         __P((void));
        !           282: VOID    ttmove         __P((int, int));
        !           283: VOID    tteeol         __P((void));
        !           284: VOID    tteeop         __P((void));
        !           285: VOID    ttbeep         __P((void));
        !           286: VOID    ttinsl         __P((int, int, int));
        !           287: VOID    ttdell         __P((int, int, int));
        !           288: VOID    ttwindow       __P((int, int));
        !           289: VOID    ttnowindow     __P((void));
        !           290: VOID    ttcolor        __P((int));
        !           291: VOID    ttresize       __P((void));
        !           292:
        !           293: /* ttyio.c */
        !           294: VOID    ttopen         __P((void));
        !           295: int     ttraw          __P((void));
        !           296: VOID    ttclose        __P((void));
        !           297: int     ttcooked       __P((void));
        !           298: int     ttputc         __P((int));
        !           299: VOID    ttflush        __P((void));
        !           300: int     ttgetc         __P((void));
        !           301: int     ttwait         __P((void));
        !           302: VOID    setttysize     __P((void));
        !           303: int     typeahead      __P((void));
        !           304:
        !           305: /* dir.c */
        !           306: VOID    dirinit        __P((VOID));
        !           307: int     changedir      __P((int, int));
        !           308: int     showcwdir      __P((int, int));
        !           309:
        !           310: /* dired.c */
        !           311: int     dired          __P((int, int));
        !           312: int     d_otherwindow  __P((int, int));
        !           313: int     d_undel        __P((int, int));
        !           314: int     d_undelbak     __P((int, int));
        !           315: int     d_findfile     __P((int, int));
        !           316: int     d_ffotherwindow __P((int, int));
        !           317: int     d_expunge      __P((int, int));
        !           318: int     d_copy         __P((int, int));
        !           319: int     d_del          __P((int, int));
        !           320: int     d_rename       __P((int, int));
        !           321:
        !           322: /* file.c */
        !           323: int     fileinsert     __P((int, int));
        !           324: int     filevisit      __P((int, int));
        !           325: int     poptofile      __P((int, int));
        !           326: BUFFER  *findbuffer    __P((char *));
        !           327: int     readin         __P((char *));
        !           328: int     insertfile     __P((char *, char *, int));
        !           329: VOID     makename      __P((char *, char *));
        !           330: int     filewrite      __P((int, int));
        !           331: int     filesave       __P((int, int));
        !           332: int     buffsave       __P((BUFFER *));
        !           333: int     makebkfile     __P((int, int));
        !           334: int     writeout       __P((BUFFER *, char *));
        !           335: VOID     upmodes       __P((BUFFER *));
        !           336:
        !           337: /* line.c */
        !           338: LINE    *lalloc                __P((int));
        !           339: LINE    *lallocx       __P((int));
        !           340: int     lnewline       __P((void));
        !           341: VOID    lfree          __P((LINE *));
        !           342: VOID     lchange       __P((int));
        !           343: VOID     kdelete       __P((void));
        !           344: int      ldelnewline   __P((void));
        !           345: int     linsert        __P((int, int));
        !           346:
        !           347: /* window.c */
        !           348: MGWIN   *wpopup                __P((void));
        !           349: int     nextwind       __P((int, int));
        !           350:
        !           351: /* buffer.c */
        !           352: BUFFER  *bfind         __P((char *, int));
        !           353: int     poptobuffer    __P((int, int));
        !           354: int     killbuffer     __P((int, int));
        !           355: int     savebuffers    __P((int, int));
        !           356: int     listbuffers    __P((int, int));
        !           357: int     addline        __P((BUFFER *, char *));
        !           358: int     anycb          __P((int));
        !           359: int     bclear         __P((BUFFER *));
        !           360: int     showbuffer     __P((BUFFER *, MGWIN *, int));
        !           361: MGWIN   *popbuf                __P((BUFFER *));
        !           362: int     bufferinsert   __P((int, int));
        !           363: int     usebuffer      __P((int, int));
        !           364: int     notmodified    __P((int, int));
        !           365: int     popbuftop      __P((BUFFER *));
        !           366:
        !           367: /* display.c */
        !           368: VOID     vtinit                __P((void));
        !           369: VOID     vttidy                __P((void));
        !           370: VOID     update                __P((void));
        !           371:
        !           372: /* echo.c */
        !           373: int     eyorn          __P((char *));
        !           374: int     eyesno         __P((char *));
        !           375: VOID     ewprintf      __P((const char *fmt, ...));
        !           376: int     ereply         __P((const char *, char *, int, ...));
        !           377: int     eread          __P((const char *, char *, int, int, ...));
        !           378: int     getxtra        __P((LIST *, LIST *, int, int));
        !           379:
        !           380: /* fileio.c */
        !           381: int     ffropen        __P((char *, BUFFER *));
        !           382: int     ffwopen        __P((char *, BUFFER *));
        !           383: int     ffclose        __P((BUFFER *));
        !           384: int     ffputbuf       __P((BUFFER *));
        !           385: int     ffgetline      __P((char *, int, int *));
        !           386: int      fbackupfile   __P((char *));
        !           387: char    *adjustname    __P((char *));
        !           388: char    *startupfile   __P((char *));
        !           389: int      copy          __P((char *, char *));
        !           390: BUFFER  *dired_                __P((char *));
        !           391: int     d_makename     __P((LINE  *, char *));
        !           392: LIST    *make_file_list        __P((char *, int));
        !           393:
        !           394: /* keymap.c */
        !           395: LIST   *complete_function_list __P((char *, int));
        !           396: int     complete_function      __P((char *, int));
        !           397:
        !           398: /* kbd.c */
        !           399: int     do_meta        __P((int, int));
        !           400: int     bsmap          __P((int, int));
        !           401: VOID    ungetkey       __P((int));
        !           402: int     getkey         __P((int));
        !           403: int     doin           __P((void));
        !           404: int     rescan         __P((int, int));
        !           405: int     universal_argument __P((int, int));
        !           406: int     digit_argument __P((int, int));
        !           407: int     negative_argument __P((int, int));
        !           408: int     selfinsert     __P((int, int));
        !           409: int     quote          __P((int, int));
        !           410:
        !           411: /* main.c */
        !           412: int     ctrlg          __P((int, int));
        !           413:
        !           414: /* ttyio.c */
        !           415: VOID     panic         __P((char *));
        !           416:
        !           417: /* cinfo.c */
        !           418: char    *keyname       __P((char  *, int));
        !           419:
        !           420: /* basic.c */
        !           421: int     gotobol        __P((int, int));
        !           422: int     backchar       __P((int, int));
        !           423: int     gotoeol        __P((int, int));
        !           424: int     forwchar       __P((int, int));
        !           425: int     gotobob        __P((int, int));
        !           426: int     gotoeob        __P((int, int));
        !           427: int     forwline       __P((int, int));
        !           428: int     backline       __P((int, int));
        !           429: VOID    setgoal        __P((void));
        !           430: int     getgoal        __P((LINE *));
        !           431: int     forwpage       __P((int, int));
        !           432: int     backpage       __P((int, int));
        !           433: int     forw1page      __P((int, int));
        !           434: int     back1page      __P((int, int));
        !           435: int     pagenext       __P((int, int));
        !           436: VOID    isetmark       __P((VOID));
        !           437: int     setmark        __P((int, int));
        !           438: int     swapmark       __P((int, int));
        !           439: int     gotoline       __P((int, int));
        !           440:
        !           441: /* random.c */
        !           442: int     getcolpos      __P((void));
        !           443: int     newline        __P((int, int));
        !           444:
        !           445: /* extend.c */
        !           446: int     insert         __P((int, int));
        !           447: int     bindtokey      __P((int, int));
        !           448: int     localbind      __P((int, int));
        !           449: int     define_key     __P((int, int));
        !           450: int     unbindtokey    __P((int, int));
        !           451: int     localunbind    __P((int, int));
        !           452: int     extend         __P((int, int));
        !           453: int     evalexpr       __P((int, int));
        !           454: int     evalbuffer     __P((int, int));
        !           455: int     evalfile       __P((int, int));
        !           456: int     load           __P((char *));
        !           457: int     excline        __P((char *));
        !           458:
        !           459: /* help.c */
        !           460: int     desckey        __P((int, int));
        !           461: int     wallchart      __P((int, int));
        !           462: int     help_help      __P((int, int));
        !           463: int     apropos_command __P((int, int));
1.1       deraadt   464:
                    465: /*
                    466:  * Externals.
                    467:  */
1.4     ! millert   468: extern int      thisflag;
        !           469: extern int      lastflag;
        !           470: extern int      curgoal;
        !           471: extern int      epresf;
        !           472: extern int      sgarbf;
        !           473: extern int      mode;
        !           474: extern MGWIN   *curwp;
        !           475: extern BUFFER  *curbp;
        !           476: extern MGWIN   *wheadp;
        !           477: extern BUFFER  *bheadp;
        !           478: extern char     pat[];
        !           479: extern int      nrow;
        !           480: extern int      ncol;
        !           481: extern int      ttrow;
        !           482: extern int      ttcol;
        !           483: extern int      tthue;
        !           484: extern int      tceeol;
        !           485: extern int      tcinsl;
        !           486: extern int      tcdell;
        !           487: extern char     cinfo[];
        !           488: extern char    *keystrings[];