ule.c source documentation
                      **************************

#define VER              "V2.0x experimental!? (04/03/99)"
#define MAXLINES 111111  /* set maxlines for editor    */
                         /* i set 111111 for unix
                                    4000 for PC         */
#define MAXLENGTH  255   /* set maxlength of editorline*/
                         /* 255 should do it           */
char command;            /* user command (a-z,#, ...   */
char tabc;               /* tab char                   */
int  tabn,tabs[10];      /* # of tabs, tab stops       */
int  nlines,nhits;       /* lines to search,find, used by locate,find,etc */
char f[80],ver[80];      /* file name, ule version #   */
char u[MAXLENGTH];       /* user input command line    */
char w[MAXLENGTH];       /* work area                  */
char us1[MAXLENGTH];     /* returned from parcing command line */
char us2[MAXLENGTH];     /*  "                         */
char us3[MAXLENGTH];     /*  "                         */
char bsave[80],          /* memory of last break       */
     csave[80],          /*                change      */
     fsave[80],          /*                find        */
     hsave[80],          /*                hack        */
     lsave[80];          /*                locate      */
char *v;                 /* work holding area          */
char *b[MAXLINES];       /* buffer holding line pointers */
char **vb;               /* virtual buffer used by move and kopy(ditto) */
int  endsw;              /* end user switch            */
int  fmodsw;             /* file modified switch       */
int  n;                  /* current line pointer       */
int  e;                  /* end of file pointer        */

ule consists of an array b of MAXLINES pointers to accommodate the file ule is editing. n is the line number of record, the line to be operated on. e is the length of the file.
in operation ule prompts for a command, a command is entered, ule detects the command, processes the command, and prompts for the next command until a quit is entered. each command routine consists of its command letter followed by "command". (ie: the c-change command calls ccommand()).
lets consider the following: 30.> if (/lost/) { 30E>i print "found\n"; 31E> what happens: (see icommand() in ule.c for actual code) ule issues a prompt for the next command the user enters:i print "found\n"; the line i print "found\n"; is parsed the command icommand() is called; the string BBBBBprint "found\n"; is allocated (malloc) the array of pointers b[n] through b[e] are moved to b[n+1] through b[e+1] b[n] is set to point to the new allocation e is increased by 1 n is increased by 1 ule issues a prompt for the next command that is the jist of the mechanics of ule. all line insertion, deletion, addition, coping, and moving are extentions of the above. everything else is string and file processing.
Now you know as much if not more about ule internals as i do!
Home