"Fossies" - the Fresh Open Source Software Archive

Member "schily-2021-09-18/ved/ved.h" (20 Aug 2021, 10658 Bytes) of package /linux/privat/schily-2021-09-18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ved.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 2021-08-14_vs_2021-09-18 or 2021-07-29_vs_2021-09-18.

    1 /* @(#)ved.h    1.49 21/08/20 Copyr 1984-86, 88-89,97, 2000-2018 J. Schilling */
    2 /*
    3  *  Main include file for VED
    4  *
    5  *  Copyright (c) 1984, 85, 86, 88, 89, 97, 2000-2018 J. Schilling
    6  */
    7 /*
    8  * The contents of this file are subject to the terms of the
    9  * Common Development and Distribution License, Version 1.0 only
   10  * (the "License").  You may not use this file except in compliance
   11  * with the License.
   12  *
   13  * See the file CDDL.Schily.txt in this distribution for details.
   14  * A copy of the CDDL is also available via the Internet at
   15  * http://www.opensource.org/licenses/cddl1.txt
   16  *
   17  * When distributing Covered Code, include this CDDL HEADER in each
   18  * file and include the License file CDDL.Schily.txt from this distribution.
   19  */
   20 
   21 #include <schily/mconfig.h>
   22 #include <schily/stdio.h>
   23 #include <schily/stdlib.h>
   24 #include <schily/unistd.h>
   25 #include <schily/string.h>
   26 #include <schily/utypes.h>
   27 #include <schily/standard.h>
   28 #include <schily/nlsdefs.h>
   29 #include <schily/limits.h>  /* for  MB_LEN_MAX  */
   30 #include <schily/ctype.h>   /* For isprint()    */
   31 #include <schily/wchar.h>   /* wchar_t      */
   32 #include <schily/wctype.h>  /* For iswprint()   */
   33 #define GT_COMERR       /* #define comerr gtcomerr */
   34 #define GT_ERROR        /* #define error gterror   */
   35 #include <schily/schily.h>
   36 #include <schily/nlsdefs.h>
   37 
   38 #define C   (char *)
   39 #define UC  (unsigned char *)
   40 #define CP  (char **)
   41 #define UCP (unsigned char **)
   42 #define CPP (char ***)
   43 #define UCPP    (unsigned char ***)
   44 
   45 #ifndef DO_WCHAR
   46 #undef  MB_LEN_MAX
   47 #define MB_LEN_MAX  1
   48 #endif
   49 
   50 #if MB_LEN_MAX > 1          /* This is multi byte mode    */
   51 typedef wchar_t     echar_t;    /* A ved internal character   */
   52 typedef wint_t      eint_t;     /* A ved internal "getc()" result */
   53 
   54 #else                   /* This is single byte mode   */
   55 typedef unsigned char   echar_t;    /* A ved internal character   */
   56 typedef int     eint_t;     /* A ved internal "getc()" result */
   57 #endif
   58 
   59 /*#define   USE_LONGLONG_POS*/
   60 
   61 #if defined(HAVE_LARGEFILES) || defined(USE_LONGLONG_POS)
   62 /*
   63  * do not use long long to allow compilation on non long long
   64  * aware systems.
   65  */
   66 /*typedef   long long   epos_t;*/
   67 /*typedef   long long   ecnt_t;*/
   68 /*
   69  * Rather use the "best effort" long long "Llong"
   70  */
   71 typedef Llong       epos_t;
   72 typedef Llong       ecnt_t;
   73 #else
   74 typedef long        epos_t;
   75 typedef long        ecnt_t;
   76 #endif
   77 
   78 #ifdef  TESTLONGLONG
   79 enum nicht { blau, besoffen };
   80 
   81 /*typedef   long        epos_t;*/
   82 /*typedef   Llong       epos_t;*/
   83 /*typedef   double      epos_t;*/
   84 /*typedef   char        epos_t;*/
   85 /*typedef   enum nicht  epos_t;*/
   86 
   87 /*typedef   double  ecnt_t;*/
   88 /*typedef   Llong   ecnt_t;*/
   89 #endif
   90 
   91 /*
   92  * We do our own buffering for outout to the screen to make ved
   93  * fast on all operating systems independent of the I/O implementation.
   94  * Our output buffer size should be more than the size of a usual screen.
   95  * As most lines are shorter that 40 characters, a bufsize of 4096 chars
   96  * will be sufficient for a 100 line display.
   97  */
   98 #define BFSIZE  8192
   99 
  100 #ifdef  BFSIZE
  101 typedef struct {
  102     short   _count;
  103     Uchar   _buf[BFSIZE];
  104     Uchar   *_ptr;
  105 } iobuf_t;
  106 
  107 extern  iobuf_t _bb;
  108 
  109 #ifdef  putchar
  110 #undef  putchar
  111 #endif
  112 #ifdef  JOS
  113 #define putchar(c) {if (--_bb._count >= 0) *_bb._ptr++ = (c); \
  114                 else _bflush(c); }
  115 #else
  116 #define putchar(c) (--_bb._count >= 0 ? *_bb._ptr++ = (c): _bflush(c))
  117 #endif
  118 
  119 #ifdef  flush
  120 #undef  flush
  121 #endif
  122 #define flush() _bufflush()
  123 #endif  /* BFSIZE */
  124 
  125 #ifdef  JOS
  126 #define ENOENT  ENOFILE
  127 #endif
  128 
  129 #define SP  0x20                /* The vanilla space    */
  130 #define TAB 0x09                /* The TAB character    */
  131 #define DEL 0x7F                /* The DEL character    */
  132 #define SP8 0xA0                /* The non-breakable space */
  133 #ifdef  USE_DEL8
  134 #define DEL8    0xFF                /* Bef. y diaresis was added */
  135 #endif
  136 
  137 #define TABNONE 255             /* No table     */
  138 #define TABFIRST CTAB               /* The first table  */
  139 #define CTAB    0               /* The chartable    */
  140 #define ESCTAB  1               /* The ESC table    */
  141 #define ALTTAB  2               /* The ALT table    */
  142 #define AESCTAB 3               /* The ALT-ESC table    */
  143 #define XTAB    4               /* The X table      */
  144 #define TABLAST XTAB                /* The last table number */
  145 #define NCTAB   (TABLAST+1)         /* The number of tables */
  146 
  147 /*
  148  * XXX Only correct on a two's complement machine.
  149  */
  150 #define MAXULONG    (~((unsigned long)0))
  151 #define MAXLONG     (MAXULONG >> 1)
  152 
  153 #undef  min
  154 #define min(x, y)   (((x) < (y)) ? (x) : (y))
  155 #undef  max
  156 #define max(x, y)   (((x) < (y)) ? (y) : (x))
  157 /*#define   abs(x)  (((x) > 0) ? (x) : (-x))*/
  158 
  159 #define TMPNSIZE    28  /* Size of temporary filename buffers   */
  160 #define NAMESIZE    256 /* Size of several temporary buffers    */
  161 #define FNAMESIZE   1024    /* Size of edited filename      */
  162 
  163 #ifdef  JOS
  164 #define DEFSHELL    "/bin/command"
  165 #define HELPFILE    UC "/doc/cmds/ved.help"
  166 #else
  167 #define DEFSHELL    "/bin/sh"
  168 #define HELPFILE    UC "/opt/schily/share/man/help/ved.help"
  169 #endif
  170 
  171 /*
  172  * A pair of horizontal and vertical position.
  173  */
  174 typedef struct {
  175     int hp;
  176     int vp;
  177 } cpos_t;
  178 
  179 typedef struct {
  180     /*
  181      * Current Window status.
  182      */
  183     epos_t  dot;        /* The byte offset of the cursor position   */
  184     epos_t  eof;        /* The byte offset of the last character + 1 */
  185     epos_t  mark;       /* The byte offset of the selection mark    */
  186     epos_t  window;     /* The byte offset of the window start      */
  187     epos_t  ewindow;    /* The byte offset of the window end        */
  188 
  189     int eflags;     /* XXX                      */
  190     BOOL    markvalid;  /* if true: there is a mark         */
  191     BOOL    overstrikemode; /* if true: overwrite in favor of insert    */
  192     BOOL    visible;    /* if true: make TAB, CR, EOL, EOF visible  */
  193     BOOL    dosmode;    /* if true: supress '\r' in \r\n sequence   */
  194     BOOL    raw8;       /* if true: do not map non acsii 8bit chars */
  195     BOOL    markwrap;   /* if true: mark linewraps with a '\\' at eol */
  196 
  197     int pmargin;    /* Max Abstand vom oberen/unteren Rand      */
  198     int tabstop;    /* Breite eines 'tabs'              */
  199     int optline;    /* Vorzugszeile fuer Window - Adjust        */
  200 
  201     int wrapmargin; /* autowrap based on margin from linelen    */
  202     int maxlinelen; /* autowrap based on linelen            */
  203     BOOL    autoindent; /* whether to indent next line like current */
  204 
  205     void    *bhead;     /* Head of the linked list of used headers  */
  206     void    *gaplink;   /* Pointer to the header where the gap starts */
  207     epos_t  gap;        /* Byte offset of first char after the gap   */
  208     int gapoff;     /* Offset within the header the gap starts in */
  209 
  210                 /* Three variables used by findpos() only   */
  211     void    *winlink;   /* Header containing the start of the window */
  212     epos_t  winpos;     /* Byte offset of the current window start  */
  213     epos_t  winoff;     /* Byte offset for start of data in winlink */
  214 
  215     Uchar   *curfile;   /* current file name                */
  216     FILE    *curfp;     /* current file pointer (if file is locked) */
  217     long    curftime;   /* last modification time of current file   */
  218     int curfd;      /* fd used to hold writelock to current file */
  219     echar_t lastch;     /* a global copy of the last read char      */
  220     BOOL    magic;      /* wether to search in 'magic' mode     */
  221     long    modflg;     /* number of modifications since last save  */
  222     ecnt_t  curnum;     /* mult # fot next edit command         */
  223     ecnt_t  number;     /* curnum is copied from this mult # master */
  224     int column;     /* the remembered not mapped hp of the cursor */
  225     /*
  226      * Global stuff.
  227      */
  228     int psize;      /* page size of the screen          */
  229     int llen;       /* line length of the screen            */
  230 } ewin_t;
  231 
  232 extern  cpos_t  cursor;     /* position of cursor in window hp not mapped */
  233 extern  cpos_t  cpos;       /* real pos of cursor on screen hp mapped   */
  234 
  235 #define COLUPDATE   0x0001  /* if set: update 'column' to current hp    */
  236 #define SAVENUM     0x0002  /* if set: keep value in 'number'       */
  237 #define SAVEDEL     0x0004  /* if set: keep next del in delete buffer   */
  238 #define KEEPDEL     0x0010  /* if set: keep content of delete buffer    */
  239 #define DELDONE     0x0020  /* if set: last command filled delete buffer */
  240 
  241 #define FREADONLY   0x10000 /* if set: forced readonly on current file  */
  242 #define FNOLOCK     0x20000 /* if set: could not lock file          */
  243 #define FLOCKLOCAL  0x40000 /* if set: lock to file is local only       */
  244 
  245 #ifdef  notused
  246 #define MARKVALID   0x0008  /* if set: there is a mark          */
  247 #define OVERSTRIKE  0x0100  /* if set: overwrite in favor of insert     */
  248 #define VISIBLE     0x0200  /* if set: make TAB, CR, EOL, EOF visible   */
  249 #define DOSMODE     0x0400  /* if set: supress '\r' in \r\n sequence    */
  250 #define RAW8        0x0800  /* if set: do not map non acsii 8bit chars  */
  251 #define MARKWRAP    0x1000  /* if set: mark linewraps with a '\\' at eol */
  252 #endif
  253 
  254 #define LOCK_OK     2   /* A networkwide file lock is present       */
  255 #define LOCK_LOCAL  1   /* The lock is local only because of flock() */
  256 #define LOCK_CANNOT 0   /* The system does not support to lock      */
  257 #define LOCK_ALREADY    -1  /* The file is already locked           */
  258 
  259 
  260 extern  int pid;        /* process id used for unique tmp file names */
  261 
  262 extern  int mflag;      /* if > 0 : take characters from macro      */
  263 
  264 
  265 /*
  266  * Used by ved.c and io.c
  267  */
  268 extern  char    ved_version[];
  269 
  270 /*
  271  * Used by ved.c and *cmds.c
  272  */
  273 extern  FILE    *takefile;  /* FILE * of current take buffer        */
  274 extern  epos_t  takesize;   /* file size of current take buffer     */
  275 extern  Uchar   takename[TMPNSIZE]; /* file name of current take buffer     */
  276 
  277 extern  FILE    *delfile;   /* FILE * of delete buffer          */
  278 extern  epos_t  delsize;    /* file size of delete buffer           */
  279 extern  Uchar   delname[TMPNSIZE]; /* file name of delete buffer        */
  280 
  281 extern  FILE    *rubfile;   /* FILE * of rubout buffer          */
  282 extern  epos_t  rubsize;    /* file size of rubout buffer           */
  283 extern  Uchar   rubname[TMPNSIZE]; /* file name of rubout buffer        */
  284 
  285 extern  int ReadOnly;   /* if > 0 : do not allow to write back mods */
  286 extern  int nobak;      /* Es wird kein ___.bak angelegt        */
  287 extern  int nolock;     /* Es wird kein record locking versucht     */
  288 extern  int noedtmp;    /* Kein .vedtmp.* erzeugen          */
  289 extern  int recover;    /* altes File reparieren            */
  290 extern  BOOL    autodos;    /* wp->dosmode aus isdos() bestimmen        */
  291 extern  int nfiles;     /* Anzahl der zu editierenden Files     */
  292 extern  int fileidx;    /* Index des editierten Files           */
  293 extern  Uchar   **files;    /* Array der zu editierenden Files      */
  294 
  295 /*
  296  * Used by io.c and screen.c
  297  */
  298 extern  BOOL    markon;     /* if true: we are just printing the mark    */
  299 
  300 /*
  301  * Used by ved.c, message.c and cmdline.c
  302  */
  303 extern  BOOL    updatemsg;  /* infostr is temporary             */
  304 extern  BOOL    updateerr;  /* errorstr is temporary            */
  305 extern  BOOL    updatesysline;  /* whole systemline should be redrawn       */
  306 
  307 /*
  308  * Used by ved.c and executecmds.c
  309  */
  310 extern Uchar execname[TMPNSIZE]; /* file name of execute buffer         */
  311 
  312 /*
  313  * Used by ved.c and filecmds.c
  314  */
  315 extern Uchar curfname[FNAMESIZE]; /* global file name storage space     */
  316 
  317 /*
  318  * Used by tags.c and coloncmdsds.c
  319  */
  320 extern int taglength;       /* Maxnimum number of chars to compare      */
  321 extern Uchar tags[];        /* List of files to search for tags     */
  322 
  323 /*
  324  * Make function prototypes available for all.
  325  */
  326 #include "func.h"