From b4d69118f5242e3fa5b166098363845c820968c4 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 13 Aug 2021 11:06:58 +0800 Subject: [PATCH] Revise header files formatting. Finish tagging BBINDABLE functions. Modify forward-character to handle combined Unicode. Bump up version number and set default program name as 'ue'. --- basic.h | 4 +- bind.h | 4 +- bindable.h | 4 +- buffer.h | 6 +- defines.h | 3 - display.h | 35 +- estruct.h | 155 ++++---- eval.h | 14 +- exec.h | 3 +- execute.h | 17 +- file.h | 10 +- fileio.h | 20 +- flook.h | 11 +- input.h | 30 +- isa.h | 43 +- isearch.h | 2 +- line.c | 1106 +++++++++++++++++++++++++-------------------------- line.h | 41 +- lock.h | 7 +- mlout.h | 6 +- names.h | 16 +- pklock.h | 4 - random.c | 1116 ++++++++++++++++++++++++++-------------------------- random.h | 56 ++- region.h | 12 +- retcode.h | 21 +- search.h | 34 +- spawn.h | 5 +- terminal.h | 112 +++--- termio.h | 10 +- utf8.h | 6 +- util.h | 7 +- version.h | 12 +- window.h | 60 +-- word.h | 1 - wrapper.h | 6 +- 36 files changed, 1493 insertions(+), 1506 deletions(-) diff --git a/basic.h b/basic.h index 4c58267..1f4d264 100644 --- a/basic.h +++ b/basic.h @@ -1,8 +1,8 @@ /* basic.h -- basic commands for cursor movement in active window */ #ifndef _BASIC_H_ -# define _BASIC_H_ +#define _BASIC_H_ -# include "names.h" +#include "names.h" /* BINDABLE() */ /* $overlap is the size of the line overlap when kbd calls page forw/back if 0, page will move by 2/3 of the window size (1/3 page overlap) diff --git a/bind.h b/bind.h index e58fbc9..77046ff 100644 --- a/bind.h +++ b/bind.h @@ -1,9 +1,8 @@ /* bind.h -- bindable functions dealing with name and key bindings */ - #ifndef _BIND_H_ #define _BIND_H_ -#include "names.h" +#include "names.h" /* BINDABLE() */ /* Bindable uEMACS functions */ BINDABLE( apro) ; @@ -19,5 +18,4 @@ int startup( const char *fname) ; const char *transbind( char *skey) ; /* by string representation of key */ #endif - /* end of bind.h */ diff --git a/bindable.h b/bindable.h index 21a709f..5959496 100644 --- a/bindable.h +++ b/bindable.h @@ -2,13 +2,13 @@ #ifndef _BINDABLE_H_ #define _BINDABLE_H_ -#include "names.h" +#include "names.h" /* BINDABLE() */ /* functions that can be bound to keys or procedure names */ BBINDABLE( ctlxe) ; BBINDABLE( ctlxlp) ; BBINDABLE( ctlxrp) ; - BINDABLE( ctrlg) ; /* ABORT */ + BINDABLE( ctrlg) ; /* ABORT */ BINDABLE( quickexit) ; BINDABLE( quit) ; diff --git a/buffer.h b/buffer.h index 50f3b75..50b4329 100644 --- a/buffer.h +++ b/buffer.h @@ -1,9 +1,9 @@ /* buffer.h -- buffer type and functions */ #ifndef _BUFFER_H_ -# define _BUFFER_H_ +#define _BUFFER_H_ -#include "line.h" -#include "names.h" +#include "line.h" /* line_p */ +#include "names.h" /* BINDABLE() */ /* Text is kept in buffers. A buffer header, described below, exists for every buffer in the system. The buffers are kept in a big list, so that diff --git a/defines.h b/defines.h index d62ac3a..c5959f2 100644 --- a/defines.h +++ b/defines.h @@ -1,9 +1,7 @@ /* defines.h -- */ - #ifndef __DEFINES_H__ #define __DEFINES_H__ - /* Must define one of USG | BSD */ @@ -16,5 +14,4 @@ #define NSTRING 128 /* # of bytes, string buffers */ #endif - /* end of defines.h */ diff --git a/display.h b/display.h index 1e0f041..cd5564c 100644 --- a/display.h +++ b/display.h @@ -1,19 +1,19 @@ /* display.h -- display functionality */ #ifndef _DISPLAY_H_ -# define _DISPLAY_H_ +#define _DISPLAY_H_ -# include +#include -# include "estruct.h" -# include "names.h" /* BINDABLE() */ -# include "utf8.h" /* unicode_t */ +#include "estruct.h" +#include "names.h" /* BINDABLE() */ +#include "utf8.h" /* unicode_t */ -extern int mpresf ; /* Stuff in message line */ -extern int scrollcount ; /* number of lines to scroll */ -extern int discmd ; /* display command flag */ -extern int disinp ; /* display input characters (echo) */ -extern int gfcolor ; /* global forgrnd color (white) */ -extern int gbcolor ; /* global backgrnd color (black) */ +extern int mpresf ; /* Stuff in message line */ +extern int scrollcount ; /* number of lines to scroll */ +extern int discmd ; /* display command flag */ +extern int disinp ; /* display input characters (echo) */ +extern int gfcolor ; /* global forgrnd color (white) */ +extern int gbcolor ; /* global backgrnd color (black) */ /* Bindable functions */ BINDABLE( upscreen) ; @@ -37,13 +37,14 @@ void echos( const char *s) ; void rubout( void) ; void getscreensize( int *widthp, int *heightp) ; -# if UNIX -# include -# ifdef SIGWINCH -extern int chg_width, chg_height ; +#if UNIX +# include +# ifdef SIGWINCH + extern int chg_width, chg_height ; -void sizesignal( int signr) ; -# endif + void sizesignal( int signr) ; # endif +#endif + #endif /* end of display.h */ diff --git a/estruct.h b/estruct.h index a5c2ae5..1de6331 100644 --- a/estruct.h +++ b/estruct.h @@ -1,19 +1,17 @@ /* estruct.h -- */ - #ifndef _ESTRUCT_H_ #define _ESTRUCT_H_ /* Structure and preprocessor defines * - * written by Dave G. Conroy - * modified by Steve Wilhite, George Jones + * written by Dave G. Conroy + * modified by Steve Wilhite, George Jones * substantially modified by Daniel Lawrence - * modified by Petri Kutvonen + * modified by Petri Kutvonen */ - -#ifdef MSDOS -#undef MSDOS +#ifdef MSDOS +# undef MSDOS #endif /* Machine/OS definitions. */ @@ -22,121 +20,116 @@ /* Make an intelligent guess about the target system. */ -#if defined(BSD) || defined(sun) || defined(ultrix) || defined(__osf__) -#ifndef BSD -#define BSD 1 /* Berkeley UNIX */ -#endif -#else -#define BSD 0 -#endif +# if defined(BSD) || defined(sun) || defined(ultrix) || defined(__osf__) +# ifndef BSD +# define BSD 1 /* Berkeley UNIX */ +# endif +# else +# define BSD 0 +# endif -#if defined(SVR4) || defined(__linux__) /* ex. SunOS 5.3 */ -#define SVR4 1 -#define SYSV 1 -#undef BSD -#endif +# if defined(SVR4) || defined(__linux__) /* ex. SunOS 5.3 */ +# define SVR4 1 +# define SYSV 1 +# undef BSD +# endif -#if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined( __unix__) -#define USG 1 /* System V UNIX */ -#else -#define USG 0 -#endif +# if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined( __unix__) +# define USG 1 /* System V UNIX */ +# else +# define USG 0 +# endif #else -# define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ -# define USG 1 /* UNIX system V */ -#endif /*autoconf */ +# define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ +# define USG 1 /* UNIX system V */ +#endif /*autoconf || BSD || SYSV */ -#define MSDOS 0 /* MS-DOS */ +#define MSDOS 0 /* MS-DOS */ -/* Compiler definitions */ -#ifndef AUTOCONF -# define UNIX 1 /* a random UNIX compiler */ +/* Compiler definitions */ +#ifndef AUTOCONF +# define UNIX 1 /* a random UNIX compiler */ #else -# define UNIX (BSD | USG) -#endif /*autoconf */ +# define UNIX (BSD | USG) +#endif /*autoconf */ -/* Debugging options */ +/* Debugging options */ -#define RAMSIZE 0 /* dynamic RAM memory usage tracking */ +#define RAMSIZE 0 /* dynamic RAM memory usage tracking */ #if RAMSIZE -#define RAMSHOW 1 /* auto dynamic RAM reporting */ +# define RAMSHOW 1 /* auto dynamic RAM reporting */ #endif -#ifndef AUTOCONF -/* Terminal Output definitions */ -# define TERMCAP 0 /* Use TERMCAP */ -# define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ +#ifndef AUTOCONF +/* Terminal Output definitions */ +# define TERMCAP 0 /* Use TERMCAP */ +# define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ #else -# define TERMCAP UNIX -# define IBMPC MSDOS +# define TERMCAP UNIX +# define IBMPC MSDOS #endif /* Autoconf. */ -/* Configuration options */ +/* Configuration options */ -#define VISMAC 0 /* update display during keyboard macros */ - -#ifndef AUTOCONF - -#define COLOR 1 /* color commands and windows */ -#define FILOCK 0 /* file locking under unix BSD 4.2 */ +#define VISMAC 0 /* update display during keyboard macros */ +#ifndef AUTOCONF +# define COLOR 1 /* color commands and windows */ +# define FILOCK 0 /* file locking under unix BSD 4.2 */ #else - -#define COLOR MSDOS -#ifdef SVR4 -#define FILOCK 1 -#else -#define FILOCK BSD -#endif - +# define COLOR MSDOS +# ifdef SVR4 +# define FILOCK 1 +# else +# define FILOCK BSD +# endif #endif /* Autoconf. */ -#define CLEAN 0 /* de-alloc memory on exit */ +#define CLEAN 0 /* de-alloc memory on exit */ -#ifndef AUTOCONF -# define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */ +#ifndef AUTOCONF +# define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */ #else -# define XONXOFF UNIX +# define XONXOFF UNIX #endif /* Autoconf. */ -#define PKCODE 1 /* include my extensions P.K., define always */ +#define PKCODE 1 /* include my extensions P.K., define always */ #define SCROLLCODE 1 /* scrolling code P.K. */ /* Define some ability flags. */ -#if IBMPC -#define MEMMAP 1 +#if IBMPC +# define MEMMAP 1 #else -#define MEMMAP 0 +# define MEMMAP 0 #endif -#if USG | BSD -# define ENVFUNC 1 +#if USG | BSD +# define ENVFUNC 1 #else -# define ENVFUNC 0 +# define ENVFUNC 0 #endif -/* Dynamic RAM tracking and reporting redefinitions */ +/* Dynamic RAM tracking and reporting redefinitions */ -#if RAMSIZE -#include -void *allocate( size_t size) ; -void release( void *ptr) ; -#define malloc allocate -#define free release +#if RAMSIZE +# include + void *allocate( size_t size) ; + void release( void *ptr) ; +# define malloc allocate +# define free release #endif -/* De-allocate memory always on exit (if the operating system or - main program can not +/* De-allocate memory always on exit (if the operating system or + main program can not */ -#if CLEAN -#define exit(a) cexit(a) +#if CLEAN +# define exit(a) cexit(a) -void cexit( int status) ; + void cexit( int status) ; #endif #endif - /* end of estruct.h */ diff --git a/eval.h b/eval.h index 8c178ee..af9e838 100644 --- a/eval.h +++ b/eval.h @@ -1,14 +1,13 @@ /* eval.h -- variables and operands evaluation */ #ifndef _EVAL_H_ -# define _EVAL_H_ +#define _EVAL_H_ #include "names.h" #define DEBUGM 1 /* $debug triggers macro debugging */ - -# if DEBUGM -int mdbugout( char *fmt, ...) ; -# endif +#if DEBUGM + int mdbugout( char *fmt, ...) ; +#endif extern int macbug ; /* macro debuging flag */ extern int cmdstatus ; /* last command status */ @@ -25,9 +24,8 @@ char *mklower( char *str) ; /* Bindable functions */ TBINDABLE( clrmes) ; -BINDABLE( setvar) ; -BINDABLE( writemsg) ; + BINDABLE( setvar) ; + BINDABLE( writemsg) ; #endif - /* end of eval.h */ diff --git a/exec.h b/exec.h index 638064f..1bb6999 100644 --- a/exec.h +++ b/exec.h @@ -1,6 +1,6 @@ /* exec.h -- bindable functions to execute functions, macros and procedures */ #ifndef _EXEC_H_ -# define _EXEC_H_ +#define _EXEC_H_ #include "names.h" @@ -61,5 +61,4 @@ BINDABLE( cbuf39) ; BINDABLE( cbuf40) ; #endif - /* end of exec.h */ diff --git a/execute.h b/execute.h index 9949149..d514b15 100644 --- a/execute.h +++ b/execute.h @@ -1,20 +1,19 @@ /* execute.h -- */ +#ifndef _EXECUTE_H_ +#define _EXECUTE_H_ -#define CFENCE 1 /* fence matching in CMODE */ - - -#include "names.h" /* key code */ - - -extern int gasave ; /* global ASAVE size */ -extern int gacount ; /* count until next ASAVE */ +#include "names.h" /* BINDABLE() */ +extern int gasave ; /* global ASAVE size */ +extern int gacount ; /* count until next ASAVE */ int execute( unsigned keycode, int f, int n) ; void kbd_loop( void) ; +#define CFENCE 1 /* fence matching in CMODE */ #if CFENCE -BINDABLE( getfence) ; + BINDABLE( getfence) ; #endif +#endif /* end of execute.h */ diff --git a/file.h b/file.h index b168a4a..6186c6b 100644 --- a/file.h +++ b/file.h @@ -1,13 +1,12 @@ /* file.h -- file centric commands */ - #ifndef _FILE_H_ #define _FILE_H_ -#include "buffer.h" -#include "names.h" +#include "buffer.h" /* bname_t */ +#include "names.h" /* BINDABLE() */ -extern boolean restflag ; /* restricted use? */ -boolean resterr( void) ; /* restricted error message */ +extern boolean restflag ; /* restricted use? */ +boolean resterr( void) ; /* restricted error message */ /* Bindable functions */ BINDABLE( filefind) ; @@ -25,5 +24,4 @@ void unqname( char *name) ; int writeout( const char *fn) ; #endif - /* end of file.h */ diff --git a/fileio.h b/fileio.h index 7f14184..df0219a 100644 --- a/fileio.h +++ b/fileio.h @@ -1,12 +1,13 @@ +/* fileio.h -- file primitives */ #ifndef _FILEIO_H_ #define _FILEIO_H_ typedef enum { - FIOSUC, /* File I/O, success. */ - FIOFNF, /* File I/O, file not found. */ - FIOEOF, /* File I/O, end of file. */ - FIOERR, /* File I/O, error. */ - FIOMEM /* File I/O, out of memory */ + FIOSUC, /* File I/O, success. */ + FIOFNF, /* File I/O, file not found. */ + FIOEOF, /* File I/O, end of file. */ + FIOERR, /* File I/O, error. */ + FIOMEM /* File I/O, out of memory */ } fio_code ; #define FTYPE_NONE 0 @@ -21,10 +22,10 @@ typedef enum { #define FCODE_EXTND 0x82 #define FCODE_MIXED 0x83 -extern char *fline ; /* dynamic return line */ -extern int ftype ; -extern int fcode ; /* encoding type */ -extern int fpayload ; /* actual length of fline content */ +extern char *fline ; /* dynamic return line */ +extern int ftype ; +extern int fcode ; /* encoding type */ +extern int fpayload ; /* actual length of fline content */ fio_code ffclose( void) ; fio_code ffgetline( void) ; @@ -33,3 +34,4 @@ fio_code ffropen( const char *fn) ; fio_code ffwopen( const char *fn) ; #endif +/* end of fileio.h */ diff --git a/flook.h b/flook.h index e56358c..869084f 100644 --- a/flook.h +++ b/flook.h @@ -1,8 +1,11 @@ -#include "retcode.h" +/* flook.h -- */ +#ifndef _FLOOK_H_ +#define _FLOOK_H_ +#include "retcode.h" /* boolean */ -#define rcfname pathname[ 0] -#define hlpfname pathname[ 1] +#define rcfname pathname[ 0] +#define hlpfname pathname[ 1] extern const char *pathname[] ; @@ -10,3 +13,5 @@ extern const char *pathname[] ; boolean fexist( const char *fname) ; char *flook( const char *fname, boolean hflag) ; +#endif +/* end of flook.h */ diff --git a/input.h b/input.h index b9bd06d..405f1a1 100644 --- a/input.h +++ b/input.h @@ -1,25 +1,26 @@ +/* input.h -- */ #ifndef _INPUT_H_ #define _INPUT_H_ -#include "names.h" +#include "names.h" /* nbind_p */ typedef enum { - STOP, PLAY, RECORD + STOP, PLAY, RECORD } kbdstate ; -extern kbdstate kbdmode ; /* current keyboard macro mode */ -extern int lastkey ; /* last keystoke */ -extern int kbdrep ; /* number of repetitions */ -extern int kbdm[] ; /* Holds kayboard macro data */ -extern int *kbdptr ; /* current position in keyboard buf */ -extern int *kbdend ; /* ptr to end of the keyboard */ +extern kbdstate kbdmode ; /* current keyboard macro mode */ +extern int lastkey ; /* last keystoke */ +extern int kbdrep ; /* number of repetitions */ +extern int kbdm[] ; /* Holds kayboard macro data */ +extern int *kbdptr ; /* current position in keyboard buf */ +extern int *kbdend ; /* ptr to end of the keyboard */ -extern int metac ; /* current meta character */ -extern int ctlxc ; /* current control X prefix char */ -extern int reptc ; /* current universal repeat char */ -extern int abortc ; /* current abort command char */ -extern const int nlc ; /* end of input char */ +extern int metac ; /* current meta character */ +extern int ctlxc ; /* current control X prefix char */ +extern int reptc ; /* current universal repeat char */ +extern int abortc ; /* current abort command char */ +extern const int nlc ; /* end of input char */ void ue_system( const char *cmd) ; @@ -28,7 +29,7 @@ int newmlarg( char **outbufref, const char *prompt, int size) ; int newmlargt( char **outbufref, const char *prompt, int size) ; int ectoc( int c) ; -/* Get a command name from the command line or interactively */ +/* Get a command binding from the command line or interactively */ nbind_p getname( void) ; int tgetc( void) ; @@ -37,3 +38,4 @@ int getcmd( void) ; int getstring( const char *prompt, char *buf, int nbuf, int eolchar) ; #endif +/* end of input.h */ diff --git a/isa.h b/isa.h index 3f1ca06..044c9c6 100644 --- a/isa.h +++ b/isa.h @@ -1,34 +1,32 @@ /* isa.h -- isletter, islower, isupper, flipcase */ - #ifndef __ISA_H__ #define __ISA_H__ -#define NATIONL 0 /* if 1, interpret [,],\,{,},| as characters P.K. */ - - -#ifdef islower -#undef islower +#ifdef islower +# undef islower #endif -#ifdef isupper -#undef isupper +#ifdef isupper +# undef isupper #endif -#if NATIONL -#define LASTUL ']' -#define LASTLL '}' +#define NATIONL 0 /* if 1, interpret [,],\,{,},| as characters P.K. */ +#if NATIONL +# define LASTUL ']' +# define LASTLL '}' #else -#define LASTUL 'Z' -#define LASTLL 'z' +# define LASTUL 'Z' +# define LASTLL 'z' #endif -#define isletter(c) __isxletter((0xFF & (c))) -#define islower(c) isxlower((0xFF & (c))) -#define isupper(c) isxupper((0xFF & (c))) +#define isletter(c) __isxletter((0xFF & (c))) +#define islower(c) isxlower((0xFF & (c))) +#define isupper(c) isxupper((0xFF & (c))) -#define __isxletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (192<=c /* && c<=255 */)) -#define isxlower(c) (('a' <= c && LASTLL >= c) || (224 <= c && 252 >= c)) -#define isxupper(c) (('A' <= c && LASTUL >= c) || (192 <= c && 220 >= c)) +#define __isxletter(c) (('a' <= c && LASTLL >= c) || \ + ('A' <= c && LASTUL >= c) || (192<=c /* && c<=255 */)) +#define isxlower(c) (('a' <= c && LASTLL >= c) || (224 <= c && 252 >= c)) +#define isxupper(c) (('A' <= c && LASTUL >= c) || (192 <= c && 220 >= c)) /* DIFCASE represents the integer difference between upper and lower case letters. It is an xor-able value, which is fortunate, since the @@ -36,9 +34,8 @@ ascii in ebcdic. */ -#define DIFCASE 0x20 /* ASCII 'a' - 'A' */ -#define flipcase( c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */ - -#endif /* __ISA_H__ */ +#define DIFCASE 0x20 /* ASCII 'a' - 'A' */ +#define flipcase( c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */ +#endif /* end of isa.h */ diff --git a/isearch.h b/isearch.h index e687524..38d513f 100644 --- a/isearch.h +++ b/isearch.h @@ -2,7 +2,7 @@ #ifndef __ISEARCH_H__ #define __ISEARCH_H__ -# include "names.h" /* BINDABLE */ +#include "names.h" /* BINDABLE */ BINDABLE( risearch) ; BINDABLE( fisearch) ; diff --git a/line.c b/line.c index d3d90a5..c5939e4 100644 --- a/line.c +++ b/line.c @@ -15,7 +15,7 @@ */ #include -#include /* NULL, offsetof() */ +#include /* NULL, offsetof() */ #include /* malloc(), free() */ #include @@ -26,7 +26,7 @@ #include "window.h" -int tabwidth = 8 ; /* column span of a tab */ +int tabwidth = 8 ; /* column span of a tab */ static int ldelnewline( void) ; @@ -37,117 +37,121 @@ static int ldelnewline( void) ; * was taken up by the keycode structure). */ -#define KBLOCK 250 /* sizeof kill buffer chunks */ +#define KBLOCK 250 /* sizeof kill buffer chunks */ typedef struct kill { - struct kill *d_next; /* Link to next chunk, NULL if last. */ - char d_chunk[KBLOCK]; /* Deleted text. */ + struct kill *d_next; /* Link to next chunk, NULL if last. */ + char d_chunk[KBLOCK]; /* Deleted text. */ } *kill_p ; -static kill_p kbufp = NULL ; /* current kill buffer chunk pointer */ -static kill_p kbufh = NULL ; /* kill buffer header pointer */ -static int kused = KBLOCK ; /* # of bytes used in kill buffer */ -static int klen ; /* length of kill buffer content */ -static char *value = NULL ; /* temp buffer for value */ +static kill_p kbufp = NULL ; /* current kill buffer chunk pointer */ +static kill_p kbufh = NULL ; /* kill buffer header pointer */ +static int kused = KBLOCK ; /* # of bytes used in kill buffer */ +static int klen ; /* length of kill buffer content */ +static char *value = NULL ; /* temp buffer for value */ /* * return some of the contents of the kill buffer */ char *getkill( void) { - kill_p kp ; - char *cp ; + kill_p kp ; + char *cp ; - if (kbufh == NULL) - /* no kill buffer....just a null string */ - return "" ; + if (kbufh == NULL) + /* no kill buffer....just a null string */ + return "" ; - if( value != NULL) - free( value) ; + if( value != NULL) + free( value) ; - value = (char *) malloc( klen + 1) ; - cp = value ; - for( kp = kbufh ; kp != NULL ; kp = kp->d_next) { - int size ; - - if( kp->d_next != NULL) - size = KBLOCK ; - else - size = kused ; - - memcpy( cp, kp->d_chunk, size) ; - cp += size ; - } - - *cp = 0 ; + value = (char *) malloc( klen + 1) ; + cp = value ; + for( kp = kbufh ; kp != NULL ; kp = kp->d_next) { + int size ; - /* and return the constructed value */ - return value; + if( kp->d_next != NULL) + size = KBLOCK ; + else + size = kused ; + + memcpy( cp, kp->d_chunk, size) ; + cp += size ; + } + + *cp = 0 ; + + /* and return the constructed value */ + return value; } -/* - * Move the cursor backwards by "n" characters. If "n" is less than zero call - * "forwchar" to actually do the move. Otherwise compute the new cursor - * location. Error if you try and move out of the buffer. Set the flag if the - * line pointer for dot changes. + +/* Move the cursor backwards by "n" characters. If "n" is less than zero + call "forwchar" to actually do the move. Otherwise compute the new + cursor location. Error if you try and move out of the buffer. Set the + flag if the line pointer for dot changes. */ -boolean backchar( int f, int n) { - assert( f == TRUE || (f == FALSE && n == 1)) ; - if( n < 0) - return forwchar( f, -n) ; +BBINDABLE( backchar) { + assert( f == TRUE || n == 1) ; + if( n < 0) + return forwchar( f, -n) ; - while( n--) { - if( curwp->w_doto == 0) { /* at beginning of line */ - line_p lp ; + while( n--) { + if( curwp->w_doto == 0) { /* at beginning of line */ + line_p lp = lback( curwp->w_dotp) ; + if( lp == curbp->b_linep) /* at beginning of buffer */ + return FALSE ; - lp = lback( curwp->w_dotp) ; - if( lp == curbp->b_linep) /* at beginning of buffer */ - return FALSE ; + curwp->w_dotp = lp ; + curwp->w_doto = llength( lp) ; + curwp->w_flag |= WFMOVE ; + } else { + unsigned pos = curwp->w_doto -= 1 ; + if( pos > 0) + curwp->w_doto -= utf8_revdelta( (unsigned char *) &( (curwp->w_dotp)->l_text[ pos]), pos) ; + } + } - curwp->w_dotp = lp ; - curwp->w_doto = llength( lp) ; - curwp->w_flag |= WFMOVE ; - } else { - unsigned pos ; - - pos = curwp->w_doto -= 1 ; - if( pos > 0) - curwp->w_doto -= utf8_revdelta( (unsigned char *) &( (curwp->w_dotp)->l_text[ pos]), pos) ; - } - } - - return TRUE ; + return TRUE ; } -/* - * Move the cursor forwards by "n" characters. If "n" is less than zero call - * "backchar" to actually do the move. Otherwise compute the new cursor - * location, and move ".". Error if you try and move off the end of the - * buffer. Set the flag if the line pointer for dot changes. + +/* Move the cursor forwards by "n" characters. If "n" is less than zero + call "backchar" to actually do the move. Otherwise compute the new + cursor location, and move ".". Error if you try and move off the end of + the buffer. Set the flag if the line pointer for dot changes. */ -boolean forwchar( int f, int n) { - assert( f == TRUE || (f == FALSE && n == 1)) ; - if( n < 0) - return backchar( f, -n) ; +BBINDABLE( forwchar) { + assert( f == TRUE || n == 1) ; + if( n < 0) + return backchar( f, -n) ; - while( n--) { - int len = llength( curwp->w_dotp) ; - if( curwp->w_doto == len) { /* at end of line */ - if( curwp->w_dotp == curbp->b_linep) /* at end of buffer */ - return FALSE ; + while( n--) { + int len = llength( curwp->w_dotp) ; + if( curwp->w_doto == len) { /* at end of line */ + if( curwp->w_dotp == curbp->b_linep) /* at end of buffer */ + return FALSE ; - curwp->w_dotp = lforw( curwp->w_dotp) ; - curwp->w_doto = 0 ; - curwp->w_flag |= WFMOVE ; - } else { - unicode_t unc ; - unsigned bytes ; - - bytes = utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto, len, &unc) ; - curwp->w_doto += bytes ; - } - } + curwp->w_dotp = lforw( curwp->w_dotp) ; + curwp->w_doto = 0 ; + curwp->w_flag |= WFMOVE ; + } else { + unicode_t unc ; - return TRUE ; + curwp->w_doto += utf8_to_unicode( curwp->w_dotp->l_text, + curwp->w_doto, len, &unc) ; + /* check if next char is null width unicode */ + while( curwp->w_doto != len) { + unsigned bytes = utf8_to_unicode( curwp->w_dotp->l_text, + curwp->w_doto, len, &unc) ; + if( utf8_width( unc) == 0) + curwp->w_doto += bytes ; + else + break ; + } + } + } + + return TRUE ; } /* @@ -157,23 +161,23 @@ boolean forwchar( int f, int n) { * message in the message line if no space. */ line_p lalloc( int used) { -#define BLOCK_SIZE 16 /* Line block chunk size. */ +#define BLOCK_SIZE 16 /* Line block chunk size. */ /* rounding down use masking instead or modulo when BLOCK_SIZE is power of 2 */ #if (BLOCK_SIZE & -BLOCK_SIZE) == BLOCK_SIZE - int size = (used + BLOCK_SIZE) & ~(BLOCK_SIZE - 1) ; + int size = (used + BLOCK_SIZE) & ~(BLOCK_SIZE - 1) ; #else - int size = used + BLOCK_SIZE - used % BLOCK_SIZE ; + int size = used + BLOCK_SIZE - used % BLOCK_SIZE ; #endif - line_p lp = (line_p) malloc( offsetof( struct line, l_text) + size) ; - if( lp == NULL) - mloutstr( "(OUT OF MEMORY)") ; - else { - lp->l_size = size ; - lp->l_used = used ; - } + line_p lp = (line_p) malloc( offsetof( struct line, l_text) + size) ; + if( lp == NULL) + mloutstr( "(OUT OF MEMORY)") ; + else { + lp->l_size = size ; + lp->l_used = used ; + } - return lp ; + return lp ; } /* @@ -183,40 +187,40 @@ line_p lalloc( int used) { * conditions described in the above comments don't hold here. */ void lfree( line_p lp) { - buffer_p bp; - struct window *wp; + buffer_p bp; + struct window *wp; - wp = wheadp; - while (wp != NULL) { - if (wp->w_linep == lp) - wp->w_linep = lp->l_fp; - if (wp->w_dotp == lp) { - wp->w_dotp = lp->l_fp; - wp->w_doto = 0; - } - if (wp->w_markp == lp) { - wp->w_markp = lp->l_fp; - wp->w_marko = 0; - } - wp = wp->w_wndp; - } - bp = bheadp; - while (bp != NULL) { - if (bp->b_nwnd == 0) { - if (bp->b_dotp == lp) { - bp->b_dotp = lp->l_fp; - bp->b_doto = 0; - } - if (bp->b_markp == lp) { - bp->b_markp = lp->l_fp; - bp->b_marko = 0; - } - } - bp = bp->b_bufp; - } - lp->l_bp->l_fp = lp->l_fp; - lp->l_fp->l_bp = lp->l_bp; - free((char *) lp); + wp = wheadp; + while (wp != NULL) { + if (wp->w_linep == lp) + wp->w_linep = lp->l_fp; + if (wp->w_dotp == lp) { + wp->w_dotp = lp->l_fp; + wp->w_doto = 0; + } + if (wp->w_markp == lp) { + wp->w_markp = lp->l_fp; + wp->w_marko = 0; + } + wp = wp->w_wndp; + } + bp = bheadp; + while (bp != NULL) { + if (bp->b_nwnd == 0) { + if (bp->b_dotp == lp) { + bp->b_dotp = lp->l_fp; + bp->b_doto = 0; + } + if (bp->b_markp == lp) { + bp->b_markp = lp->l_fp; + bp->b_marko = 0; + } + } + bp = bp->b_bufp; + } + lp->l_bp->l_fp = lp->l_fp; + lp->l_fp->l_bp = lp->l_bp; + free((char *) lp); } /* @@ -228,32 +232,32 @@ void lfree( line_p lp) { */ void lchange(int flag) { - struct window *wp; + struct window *wp; - if (curbp->b_nwnd != 1) /* Ensure hard. */ - flag = WFHARD; - if ((curbp->b_flag & BFCHG) == 0) { /* First change, so */ - flag |= WFMODE; /* update mode lines. */ - curbp->b_flag |= BFCHG; - } - wp = wheadp; - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= flag; - wp = wp->w_wndp; - } + if (curbp->b_nwnd != 1) /* Ensure hard. */ + flag = WFHARD; + if ((curbp->b_flag & BFCHG) == 0) { /* First change, so */ + flag |= WFMODE; /* update mode lines. */ + curbp->b_flag |= BFCHG; + } + wp = wheadp; + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= flag; + wp = wp->w_wndp; + } } /* * insert spaces forward into text * - * int f, n; default flag and numeric argument + * int f, n; default flag and numeric argument */ BINDABLE( insspace) { - assert( !(curbp->b_mode & MDVIEW)) ; - linsert( n, ' ') ; - backchar( f, n) ; - return TRUE ; + assert( !(curbp->b_mode & MDVIEW)) ; + linsert( n, ' ') ; + backchar( f, n) ; + return TRUE ; } /* @@ -261,24 +265,24 @@ BINDABLE( insspace) { */ int linstr( char *instr) { - int status = TRUE ; + int status = TRUE ; - if( instr != NULL) { - unicode_t tmpc ; + if( instr != NULL) { + unicode_t tmpc ; - while( (tmpc = *instr++ & 0xFF)) { - status = - (tmpc == '\n' ? lnewline() : (int) linsert_byte( 1, tmpc)) ; + while( (tmpc = *instr++ & 0xFF)) { + status = + (tmpc == '\n' ? lnewline() : (int) linsert_byte( 1, tmpc)) ; - /* Insertion error? */ - if( status != TRUE) { - mloutstr( "%Out of memory while inserting") ; - return status ; - } - } - } + /* Insertion error? */ + if( status != TRUE) { + mloutstr( "%Out of memory while inserting") ; + return status ; + } + } + } - return status ; + return status ; } /* @@ -292,142 +296,142 @@ int linstr( char *instr) { */ boolean linsert_byte( int n, int c) { - char *cp1; - char *cp2; - line_p lp1, lp2, lp3 ; - int doto; - int i; - struct window *wp; + char *cp1; + char *cp2; + line_p lp1, lp2, lp3 ; + int doto; + int i; + struct window *wp; - assert( (curbp->b_mode & MDVIEW) == 0) ; + assert( (curbp->b_mode & MDVIEW) == 0) ; - lchange(WFEDIT); - lp1 = curwp->w_dotp; /* Current line */ - if (lp1 == curbp->b_linep) { /* At the end: special */ - if (curwp->w_doto != 0) { - mloutstr( "bug: linsert") ; - return FALSE; - } + lchange(WFEDIT); + lp1 = curwp->w_dotp; /* Current line */ + if (lp1 == curbp->b_linep) { /* At the end: special */ + if (curwp->w_doto != 0) { + mloutstr( "bug: linsert") ; + return FALSE; + } - lp2 = lalloc( n) ; /* Allocate new line */ - if( lp2 == NULL) - return FALSE ; + lp2 = lalloc( n) ; /* Allocate new line */ + if( lp2 == NULL) + return FALSE ; - lp3 = lp1->l_bp; /* Previous line */ - lp3->l_fp = lp2; /* Link in */ - lp2->l_fp = lp1; - lp1->l_bp = lp2; - lp2->l_bp = lp3; - for (i = 0; i < n; ++i) - lp2->l_text[i] = c; - curwp->w_dotp = lp2; - curwp->w_doto = n; - return TRUE; - } - doto = curwp->w_doto; /* Save for later. */ - if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */ - lp2 = lalloc( lp1->l_used + n) ; - if( lp2 == NULL) - return FALSE ; + lp3 = lp1->l_bp; /* Previous line */ + lp3->l_fp = lp2; /* Link in */ + lp2->l_fp = lp1; + lp1->l_bp = lp2; + lp2->l_bp = lp3; + for (i = 0; i < n; ++i) + lp2->l_text[i] = c; + curwp->w_dotp = lp2; + curwp->w_doto = n; + return TRUE; + } + doto = curwp->w_doto; /* Save for later. */ + if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */ + lp2 = lalloc( lp1->l_used + n) ; + if( lp2 == NULL) + return FALSE ; - cp1 = &lp1->l_text[0]; - cp2 = &lp2->l_text[0]; - while (cp1 != &lp1->l_text[doto]) - *cp2++ = *cp1++; - cp2 += n; - while (cp1 != &lp1->l_text[lp1->l_used]) - *cp2++ = *cp1++; - lp1->l_bp->l_fp = lp2; - lp2->l_fp = lp1->l_fp; - lp1->l_fp->l_bp = lp2; - lp2->l_bp = lp1->l_bp; - free((char *) lp1); - } else { /* Easy: in place */ - lp2 = lp1; /* Pretend new line */ - lp2->l_used += n; - cp2 = &lp1->l_text[lp1->l_used]; - cp1 = cp2 - n; - while (cp1 != &lp1->l_text[doto]) - *--cp2 = *--cp1; - } - for (i = 0; i < n; ++i) /* Add the characters */ - lp2->l_text[doto + i] = c; - wp = wheadp; /* Update windows */ - while (wp != NULL) { - if (wp->w_linep == lp1) - wp->w_linep = lp2; - if (wp->w_dotp == lp1) { - wp->w_dotp = lp2; - if (wp == curwp || wp->w_doto > doto) - wp->w_doto += n; - } - if (wp->w_markp == lp1) { - wp->w_markp = lp2; - if (wp->w_marko > doto) - wp->w_marko += n; - } - wp = wp->w_wndp; - } - return TRUE; + cp1 = &lp1->l_text[0]; + cp2 = &lp2->l_text[0]; + while (cp1 != &lp1->l_text[doto]) + *cp2++ = *cp1++; + cp2 += n; + while (cp1 != &lp1->l_text[lp1->l_used]) + *cp2++ = *cp1++; + lp1->l_bp->l_fp = lp2; + lp2->l_fp = lp1->l_fp; + lp1->l_fp->l_bp = lp2; + lp2->l_bp = lp1->l_bp; + free((char *) lp1); + } else { /* Easy: in place */ + lp2 = lp1; /* Pretend new line */ + lp2->l_used += n; + cp2 = &lp1->l_text[lp1->l_used]; + cp1 = cp2 - n; + while (cp1 != &lp1->l_text[doto]) + *--cp2 = *--cp1; + } + for (i = 0; i < n; ++i) /* Add the characters */ + lp2->l_text[doto + i] = c; + wp = wheadp; /* Update windows */ + while (wp != NULL) { + if (wp->w_linep == lp1) + wp->w_linep = lp2; + if (wp->w_dotp == lp1) { + wp->w_dotp = lp2; + if (wp == curwp || wp->w_doto > doto) + wp->w_doto += n; + } + if (wp->w_markp == lp1) { + wp->w_markp = lp2; + if (wp->w_marko > doto) + wp->w_marko += n; + } + wp = wp->w_wndp; + } + return TRUE; } int linsert( int n, unicode_t c) { - assert( n >= 0) ; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( n >= 0) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( n > 0) { - char utf8[ 4] ; - int bytes ; + if( n > 0) { + char utf8[ 4] ; + int bytes ; - bytes = unicode_to_utf8(c, utf8) ; - if (bytes == 1) - return linsert_byte(n, (unsigned char) utf8[0]); + bytes = unicode_to_utf8(c, utf8) ; + if (bytes == 1) + return linsert_byte(n, (unsigned char) utf8[0]); - do { - int j ; + do { + int j ; - for( j = 0 ; j < bytes ; j += 1) - if( !linsert_byte( 1, (unsigned char) utf8[ j])) - return FALSE ; - } while( --n > 0) ; - } + for( j = 0 ; j < bytes ; j += 1) + if( !linsert_byte( 1, (unsigned char) utf8[ j])) + return FALSE ; + } while( --n > 0) ; + } - return TRUE; + return TRUE; } /* Overwrite a character into the current line at the current position * - * int c ; character to overwrite on current position + * int c ; character to overwrite on current position */ static int lowrite( int c) { - if( curwp->w_doto < curwp->w_dotp->l_used - && ( lgetc( curwp->w_dotp, curwp->w_doto) != '\t' - || (curwp->w_doto % tabwidth) == (tabwidth - 1) - )) - ldelchar( 1, FALSE) ; + if( curwp->w_doto < curwp->w_dotp->l_used + && ( lgetc( curwp->w_dotp, curwp->w_doto) != '\t' + || (curwp->w_doto % tabwidth) == (tabwidth - 1) + )) + ldelchar( 1, FALSE) ; - return linsert( 1, c) ; + return linsert( 1, c) ; } /* * lover -- Overwrite a string at the current point */ int lover( char *ostr) { - int status = TRUE ; + int status = TRUE ; - if( ostr != NULL) { - char tmpc ; + if( ostr != NULL) { + char tmpc ; - while( (tmpc = *ostr++)) { - status = (tmpc == '\n' ? lnewline() : lowrite( tmpc)) ; - if( status != TRUE) { /* Insertion error? */ - mloutstr( "%Out of memory while overwriting") ; - return status ; - } - } - } - - return status ; + while( (tmpc = *ostr++)) { + status = (tmpc == '\n' ? lnewline() : lowrite( tmpc)) ; + if( status != TRUE) { /* Insertion error? */ + mloutstr( "%Out of memory while overwriting") ; + return status ; + } + } + } + + return status ; } /* @@ -439,65 +443,65 @@ int lover( char *ostr) { * split forces more updating. */ int lnewline( void) { - char *cp1; - char *cp2; - line_p lp1, lp2 ; - int doto; - struct window *wp; + char *cp1; + char *cp2; + line_p lp1, lp2 ; + int doto; + struct window *wp; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; #if SCROLLCODE - lchange(WFHARD | WFINS); + lchange(WFHARD | WFINS); #else - lchange(WFHARD); + lchange(WFHARD); #endif - lp1 = curwp->w_dotp; /* Get the address and */ - doto = curwp->w_doto; /* offset of "." */ - lp2 = lalloc( doto) ; /* New first half line */ - if( lp2 == NULL) - return FALSE ; + lp1 = curwp->w_dotp; /* Get the address and */ + doto = curwp->w_doto; /* offset of "." */ + lp2 = lalloc( doto) ; /* New first half line */ + if( lp2 == NULL) + return FALSE ; - cp1 = &lp1->l_text[0]; /* Shuffle text around */ - cp2 = &lp2->l_text[0]; - while (cp1 != &lp1->l_text[doto]) - *cp2++ = *cp1++; - cp2 = &lp1->l_text[0]; - while (cp1 != &lp1->l_text[lp1->l_used]) - *cp2++ = *cp1++; - lp1->l_used -= doto; - lp2->l_bp = lp1->l_bp; - lp1->l_bp = lp2; - lp2->l_bp->l_fp = lp2; - lp2->l_fp = lp1; - wp = wheadp; /* Windows */ - while (wp != NULL) { - if (wp->w_linep == lp1) - wp->w_linep = lp2; - if (wp->w_dotp == lp1) { - if (wp->w_doto < doto) - wp->w_dotp = lp2; - else - wp->w_doto -= doto; - } - if (wp->w_markp == lp1) { - if (wp->w_marko < doto) - wp->w_markp = lp2; - else - wp->w_marko -= doto; - } - wp = wp->w_wndp; - } - return TRUE; + cp1 = &lp1->l_text[0]; /* Shuffle text around */ + cp2 = &lp2->l_text[0]; + while (cp1 != &lp1->l_text[doto]) + *cp2++ = *cp1++; + cp2 = &lp1->l_text[0]; + while (cp1 != &lp1->l_text[lp1->l_used]) + *cp2++ = *cp1++; + lp1->l_used -= doto; + lp2->l_bp = lp1->l_bp; + lp1->l_bp = lp2; + lp2->l_bp->l_fp = lp2; + lp2->l_fp = lp1; + wp = wheadp; /* Windows */ + while (wp != NULL) { + if (wp->w_linep == lp1) + wp->w_linep = lp2; + if (wp->w_dotp == lp1) { + if (wp->w_doto < doto) + wp->w_dotp = lp2; + else + wp->w_doto -= doto; + } + if (wp->w_markp == lp1) { + if (wp->w_marko < doto) + wp->w_markp = lp2; + else + wp->w_marko -= doto; + } + wp = wp->w_wndp; + } + return TRUE; } int lgetchar( unicode_t *c) { - if( curwp->w_dotp->l_used == curwp->w_doto) { - *c = (curbp->b_mode & MDDOS) ? '\r' : '\n' ; - return 1 ; - } else - return utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto, - llength( curwp->w_dotp), c) ; + if( curwp->w_dotp->l_used == curwp->w_doto) { + *c = (curbp->b_mode & MDDOS) ? '\r' : '\n' ; + return 1 ; + } else + return utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto, + llength( curwp->w_dotp), c) ; } /* @@ -509,14 +513,14 @@ int lgetchar( unicode_t *c) { */ boolean ldelchar( long n, boolean kflag) { /* testing for read only mode is done by ldelete() */ - while( n-- > 0) { - unicode_t c; + while( n-- > 0) { + unicode_t c; - if( !ldelete( lgetchar( &c), kflag)) - return FALSE ; - } + if( !ldelete( lgetchar( &c), kflag)) + return FALSE ; + } - return TRUE ; + return TRUE ; } /* @@ -525,101 +529,101 @@ boolean ldelchar( long n, boolean kflag) { * deleted, and FALSE if they were not (because dot ran into the end of the * buffer. The "kflag" is TRUE if the text should be put in the kill buffer. * - * long n; # of chars to delete - * int kflag; put killed text in kill buffer flag + * long n; # of chars to delete + * int kflag; put killed text in kill buffer flag */ boolean ldelete( long n, boolean kflag) { - char *cp1; - char *cp2; - line_p dotp; - int doto; - int chunk; - struct window *wp; + char *cp1; + char *cp2; + line_p dotp; + int doto; + int chunk; + struct window *wp; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - while( n > 0) { - dotp = curwp->w_dotp; - doto = curwp->w_doto; - if (dotp == curbp->b_linep) /* Hit end of buffer. */ - return FALSE; - chunk = dotp->l_used - doto; /* Size of chunk. */ - if (chunk > n) - chunk = n; - if (chunk == 0) { /* End of line, merge. */ + while( n > 0) { + dotp = curwp->w_dotp; + doto = curwp->w_doto; + if (dotp == curbp->b_linep) /* Hit end of buffer. */ + return FALSE; + chunk = dotp->l_used - doto; /* Size of chunk. */ + if (chunk > n) + chunk = n; + if (chunk == 0) { /* End of line, merge. */ #if SCROLLCODE - lchange(WFHARD | WFKILLS); + lchange(WFHARD | WFKILLS); #else - lchange(WFHARD); + lchange(WFHARD); #endif - if (ldelnewline() == FALSE - || (kflag != FALSE && kinsert('\n') == FALSE)) - return FALSE; - --n; - continue; - } - lchange(WFEDIT); - cp1 = &dotp->l_text[doto]; /* Scrunch text. */ - cp2 = cp1 + chunk; - if (kflag != FALSE) { /* Kill? */ - while (cp1 != cp2) { - if (kinsert(*cp1) == FALSE) - return FALSE; - ++cp1; - } - cp1 = &dotp->l_text[doto]; - } - while (cp2 != &dotp->l_text[dotp->l_used]) - *cp1++ = *cp2++; - dotp->l_used -= chunk; - wp = wheadp; /* Fix windows */ - while (wp != NULL) { - if (wp->w_dotp == dotp && wp->w_doto >= doto) { - wp->w_doto -= chunk; - if (wp->w_doto < doto) - wp->w_doto = doto; - } - if (wp->w_markp == dotp && wp->w_marko >= doto) { - wp->w_marko -= chunk; - if (wp->w_marko < doto) - wp->w_marko = doto; - } - wp = wp->w_wndp; - } - n -= chunk; - } - return TRUE; + if (ldelnewline() == FALSE + || (kflag != FALSE && kinsert('\n') == FALSE)) + return FALSE; + --n; + continue; + } + lchange(WFEDIT); + cp1 = &dotp->l_text[doto]; /* Scrunch text. */ + cp2 = cp1 + chunk; + if (kflag != FALSE) { /* Kill? */ + while (cp1 != cp2) { + if (kinsert(*cp1) == FALSE) + return FALSE; + ++cp1; + } + cp1 = &dotp->l_text[doto]; + } + while (cp2 != &dotp->l_text[dotp->l_used]) + *cp1++ = *cp2++; + dotp->l_used -= chunk; + wp = wheadp; /* Fix windows */ + while (wp != NULL) { + if (wp->w_dotp == dotp && wp->w_doto >= doto) { + wp->w_doto -= chunk; + if (wp->w_doto < doto) + wp->w_doto = doto; + } + if (wp->w_markp == dotp && wp->w_marko >= doto) { + wp->w_marko -= chunk; + if (wp->w_marko < doto) + wp->w_marko = doto; + } + wp = wp->w_wndp; + } + n -= chunk; + } + return TRUE; } /* - * getctext: grab and return a string with the text of - * the current line + * getctext: grab and return a string with the text of + * the current line */ char *getctext( void) { - line_p lp ; /* line to copy */ - int size; /* length of line to return */ - static int rsize = 0 ; - static char *rline ; /* line to return */ + line_p lp ; /* line to copy */ + int size; /* length of line to return */ + static int rsize = 0 ; + static char *rline ; /* line to return */ - /* find the contents of the current line and its length */ - lp = curwp->w_dotp; - size = lp->l_used; - if( size >= rsize) { - if( rsize) - free( rline) ; + /* find the contents of the current line and its length */ + lp = curwp->w_dotp; + size = lp->l_used; + if( size >= rsize) { + if( rsize) + free( rline) ; - rsize = size + 1 ; - rline = malloc( rsize) ; - if( rline == NULL) { - rsize = 0 ; - return "" ; - } - } + rsize = size + 1 ; + rline = malloc( rsize) ; + if( rline == NULL) { + rsize = 0 ; + return "" ; + } + } - /* copy it across */ - memcpy( rline, lp->l_text, size) ; - rline[ size] = 0 ; - return rline ; + /* copy it across */ + memcpy( rline, lp->l_text, size) ; + rline[ size] = 0 ; + return rline ; } /* @@ -632,82 +636,82 @@ char *getctext( void) { * "ldelete" only. */ static int ldelnewline( void) { - char *cp1; - char *cp2; - line_p lp1, lp2, lp3 ; - struct window *wp; + char *cp1; + char *cp2; + line_p lp1, lp2, lp3 ; + struct window *wp; - assert( (curbp->b_mode & MDVIEW) == 0) ; + assert( (curbp->b_mode & MDVIEW) == 0) ; - lp1 = curwp->w_dotp; - lp2 = lp1->l_fp; - if (lp2 == curbp->b_linep) { /* At the buffer end. */ - if (lp1->l_used == 0) /* Blank line. */ - lfree(lp1); - return TRUE; - } - if (lp2->l_used <= lp1->l_size - lp1->l_used) { - cp1 = &lp1->l_text[lp1->l_used]; - cp2 = &lp2->l_text[0]; - while (cp2 != &lp2->l_text[lp2->l_used]) - *cp1++ = *cp2++; - wp = wheadp; - while (wp != NULL) { - if (wp->w_linep == lp2) - wp->w_linep = lp1; - if (wp->w_dotp == lp2) { - wp->w_dotp = lp1; - wp->w_doto += lp1->l_used; - } - if (wp->w_markp == lp2) { - wp->w_markp = lp1; - wp->w_marko += lp1->l_used; - } - wp = wp->w_wndp; - } - lp1->l_used += lp2->l_used; - lp1->l_fp = lp2->l_fp; - lp2->l_fp->l_bp = lp1; - free((char *) lp2); - return TRUE; - } + lp1 = curwp->w_dotp; + lp2 = lp1->l_fp; + if (lp2 == curbp->b_linep) { /* At the buffer end. */ + if (lp1->l_used == 0) /* Blank line. */ + lfree(lp1); + return TRUE; + } + if (lp2->l_used <= lp1->l_size - lp1->l_used) { + cp1 = &lp1->l_text[lp1->l_used]; + cp2 = &lp2->l_text[0]; + while (cp2 != &lp2->l_text[lp2->l_used]) + *cp1++ = *cp2++; + wp = wheadp; + while (wp != NULL) { + if (wp->w_linep == lp2) + wp->w_linep = lp1; + if (wp->w_dotp == lp2) { + wp->w_dotp = lp1; + wp->w_doto += lp1->l_used; + } + if (wp->w_markp == lp2) { + wp->w_markp = lp1; + wp->w_marko += lp1->l_used; + } + wp = wp->w_wndp; + } + lp1->l_used += lp2->l_used; + lp1->l_fp = lp2->l_fp; + lp2->l_fp->l_bp = lp1; + free((char *) lp2); + return TRUE; + } - lp3 = lalloc( lp1->l_used + lp2->l_used) ; - if( lp3 == NULL) - return FALSE ; + lp3 = lalloc( lp1->l_used + lp2->l_used) ; + if( lp3 == NULL) + return FALSE ; - cp1 = &lp1->l_text[0]; - cp2 = &lp3->l_text[0]; - while (cp1 != &lp1->l_text[lp1->l_used]) - *cp2++ = *cp1++; - cp1 = &lp2->l_text[0]; - while (cp1 != &lp2->l_text[lp2->l_used]) - *cp2++ = *cp1++; - lp1->l_bp->l_fp = lp3; - lp3->l_fp = lp2->l_fp; - lp2->l_fp->l_bp = lp3; - lp3->l_bp = lp1->l_bp; - wp = wheadp; - while (wp != NULL) { - if (wp->w_linep == lp1 || wp->w_linep == lp2) - wp->w_linep = lp3; - if (wp->w_dotp == lp1) - wp->w_dotp = lp3; - else if (wp->w_dotp == lp2) { - wp->w_dotp = lp3; - wp->w_doto += lp1->l_used; - } - if (wp->w_markp == lp1) - wp->w_markp = lp3; - else if (wp->w_markp == lp2) { - wp->w_markp = lp3; - wp->w_marko += lp1->l_used; - } - wp = wp->w_wndp; - } - free((char *) lp1); - free((char *) lp2); - return TRUE; + cp1 = &lp1->l_text[0]; + cp2 = &lp3->l_text[0]; + while (cp1 != &lp1->l_text[lp1->l_used]) + *cp2++ = *cp1++; + cp1 = &lp2->l_text[0]; + while (cp1 != &lp2->l_text[lp2->l_used]) + *cp2++ = *cp1++; + lp1->l_bp->l_fp = lp3; + lp3->l_fp = lp2->l_fp; + lp2->l_fp->l_bp = lp3; + lp3->l_bp = lp1->l_bp; + wp = wheadp; + while (wp != NULL) { + if (wp->w_linep == lp1 || wp->w_linep == lp2) + wp->w_linep = lp3; + if (wp->w_dotp == lp1) + wp->w_dotp = lp3; + else if (wp->w_dotp == lp2) { + wp->w_dotp = lp3; + wp->w_doto += lp1->l_used; + } + if (wp->w_markp == lp1) + wp->w_markp = lp3; + else if (wp->w_markp == lp2) { + wp->w_markp = lp3; + wp->w_marko += lp1->l_used; + } + wp = wp->w_wndp; + } + free((char *) lp1); + free((char *) lp2); + return TRUE; } /* @@ -717,59 +721,59 @@ static int ldelnewline( void) { */ void kdelete(void) { - kill_p kp; /* ptr to scan kill buffer chunk list */ + kill_p kp; /* ptr to scan kill buffer chunk list */ - if (kbufh != NULL) { + if (kbufh != NULL) { - /* first, delete all the chunks */ - kbufp = kbufh; - while (kbufp != NULL) { - kp = kbufp->d_next; - free(kbufp); - kbufp = kp; - } + /* first, delete all the chunks */ + kbufp = kbufh; + while (kbufp != NULL) { + kp = kbufp->d_next; + free(kbufp); + kbufp = kp; + } - /* and reset all the kill buffer pointers */ - kbufh = kbufp = NULL; - kused = KBLOCK; - klen = 0 ; - if( value != NULL) { - free( value) ; - value = NULL ; - } - } + /* and reset all the kill buffer pointers */ + kbufh = kbufp = NULL; + kused = KBLOCK; + klen = 0 ; + if( value != NULL) { + free( value) ; + value = NULL ; + } + } } /* * Insert a character to the kill buffer, allocating new chunks as needed. * Return TRUE if all is well, and FALSE on errors. * - * int c; character to insert in the kill buffer + * int c; character to insert in the kill buffer */ int kinsert( int c) { - /* check to see if we need a new chunk */ - if( kused >= KBLOCK) { - kill_p nchunk = malloc( sizeof *nchunk) ; - if( nchunk == NULL) - return FALSE ; + /* check to see if we need a new chunk */ + if( kused >= KBLOCK) { + kill_p nchunk = malloc( sizeof *nchunk) ; + if( nchunk == NULL) + return FALSE ; - if( kbufh == NULL) { /* set head ptr if first time */ - kbufh = nchunk ; - klen = 0 ; - } + if( kbufh == NULL) { /* set head ptr if first time */ + kbufh = nchunk ; + klen = 0 ; + } - if( kbufp != NULL) /* point the current to this new one */ - kbufp->d_next = nchunk ; + if( kbufp != NULL) /* point the current to this new one */ + kbufp->d_next = nchunk ; - kbufp = nchunk ; - kbufp->d_next = NULL ; - kused = 0 ; - } + kbufp = nchunk ; + kbufp->d_next = NULL ; + kused = 0 ; + } - /* and now insert the character */ - kbufp->d_chunk[ kused++] = c ; - klen += 1 ; - return TRUE ; + /* and now insert the character */ + kbufp->d_chunk[ kused++] = c ; + klen += 1 ; + return TRUE ; } /* @@ -778,41 +782,41 @@ int kinsert( int c) { * check for errors. Bound to "C-Y". */ BINDABLE( yank) { - int c; - int i; - char *sp; /* pointer into string to insert */ - kill_p kp; /* pointer into kill buffer */ + int c; + int i; + char *sp; /* pointer into string to insert */ + kill_p kp; /* pointer into kill buffer */ - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if (n < 0) - return FALSE; - /* make sure there is something to yank */ - if (kbufh == NULL) - return TRUE; /* not an error, just nothing */ + if (n < 0) + return FALSE; + /* make sure there is something to yank */ + if (kbufh == NULL) + return TRUE; /* not an error, just nothing */ - /* for each time.... */ - while (n--) { - kp = kbufh; - while (kp != NULL) { - if (kp->d_next == NULL) - i = kused; - else - i = KBLOCK; - sp = kp->d_chunk; - while (i--) { - if ((c = *sp++) == '\n') { - if (lnewline() == FALSE) - return FALSE; - } else { - if (linsert_byte(1, c) == FALSE) - return FALSE; - } - } - kp = kp->d_next; - } - } - return TRUE; + /* for each time.... */ + while (n--) { + kp = kbufh; + while (kp != NULL) { + if (kp->d_next == NULL) + i = kused; + else + i = KBLOCK; + sp = kp->d_chunk; + while (i--) { + if ((c = *sp++) == '\n') { + if (lnewline() == FALSE) + return FALSE; + } else { + if (linsert_byte(1, c) == FALSE) + return FALSE; + } + } + kp = kp->d_next; + } + } + return TRUE; } /* @@ -820,7 +824,7 @@ BINDABLE( yank) { * VIEW (read-only) mode */ boolean rdonly( void) { - return mloutfail( "(Key illegal in VIEW mode)") ; + return mloutfail( "(Key illegal in VIEW mode)") ; } /* end of line.c */ diff --git a/line.h b/line.h index 656a83b..0dc78e3 100644 --- a/line.h +++ b/line.h @@ -1,26 +1,24 @@ /* line.h -- line centric interface */ - #ifndef _LINE_H_ #define _LINE_H_ #include "names.h" #include "utf8.h" -/* - * All text is kept in circularly linked lists of "struct line" structures. - * These begin at the header line (which is the blank line beyond the end - * of the buffer). This line is pointed to by the "struct buffer". Each - * line contains a number of bytes in the line (the "used" size), the size - * of the text array, and the text. The end of line is not stored as a - * byte; it's implied. Future additions will include update hints, and a - * list of marks into the line. +/* All text is kept in circularly linked lists of "struct line" structures. + These begin at the header line (which is the blank line beyond the end + of the buffer). This line is pointed to by the "struct buffer". Each + line contains a number of bytes in the line (the "used" size), the size + of the text array, and the text. The end of line is not stored as a + byte; it's implied. Future additions will include update hints, and a + list of marks into the line. */ typedef struct line { - struct line *l_fp ; /* Forward link to the next line */ - struct line *l_bp ; /* Backward link to the previous line */ - int l_size ; /* Allocated size */ - int l_used ; /* Used size */ - char l_text[ 1] ; /* A bunch of characters */ + struct line *l_fp ; /* Forward link to the next line */ + struct line *l_bp ; /* Backward link to the previous line */ + int l_size ; /* Allocated size */ + int l_used ; /* Used size */ + char l_text[ 1] ; /* A bunch of characters */ } *line_p ; #define lforw(lp) ((lp)->l_fp) @@ -29,15 +27,15 @@ typedef struct line { #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) -extern int tabwidth ; /* Map to $tab, default to 8, can be set to [1, .. */ +extern int tabwidth ; /* Map to $tab, default to 8, can be set to [1, .. */ char *getkill( void) ; /* Bindable functions */ -boolean backchar( int f, int n) ; -boolean forwchar( int f, int n) ; -BINDABLE( insspace) ; -BINDABLE( yank) ; +BBINDABLE( backchar) ; +BBINDABLE( forwchar) ; + BINDABLE( insspace) ; + BINDABLE( yank) ; void lfree( line_p lp) ; void lchange( int flag) ; @@ -54,8 +52,7 @@ void kdelete( void) ; int kinsert( int c) ; line_p lalloc( int minsize) ; /* Allocate a line of at least minsize chars. */ -boolean rdonly( void) ; /* Read Only error message */ - -#endif /* _LINE_H_ */ +boolean rdonly( void) ; /* Read Only error message */ +#endif /* end of line.h */ diff --git a/lock.h b/lock.h index f7907c0..9b82e91 100644 --- a/lock.h +++ b/lock.h @@ -1,18 +1,15 @@ /* lock.h -- */ - #ifndef _LOCK_H_ #define _LOCK_H_ #include "estruct.h" -#if BSD | SVR4 - +#if BSD | SVR4 int lockchk( const char *fname) ; int lockrel( void) ; int lock( const char *fname) ; int unlock( const char *fname) ; - -#endif #endif +#endif /* end of lock.h */ diff --git a/mlout.h b/mlout.h index 4bb6c22..444cfde 100644 --- a/mlout.h +++ b/mlout.h @@ -1,5 +1,4 @@ /* mlout.h -- message line output interface */ - #ifndef __MLOUT_H__ #define __MLOUT_H__ @@ -8,8 +7,7 @@ extern void (*mloutfmt)( const char *, ...) ; void mloutstr( const char *str) ; -boolean mloutfail( const char *msg) ; /* output with BELL and return FALSE */ - -#endif /* __MLOUT_H__ */ +boolean mloutfail( const char *msg) ; /* output with BELL and return FALSE */ +#endif /* end of mlout.h */ diff --git a/names.h b/names.h index 6be2190..a4cdc1f 100644 --- a/names.h +++ b/names.h @@ -1,20 +1,20 @@ /* names.h -- mapping of functions to names and keys */ #ifndef _NAMES_H_ -# define _NAMES_H_ +#define _NAMES_H_ #include "retcode.h" -#define CTL_ 0x01000000 /* Control flag, or'ed in */ -#define META 0x02000000 /* Meta flag, or'ed in */ -#define CTLX 0x04000000 /* ^X flag, or'ed in */ -#define SPEC 0x08000000 /* special key (function keys) */ -#define PRFXMASK 0x0F000000 /* prefix mask */ +#define CTL_ 0x01000000 /* Control flag, or'ed in */ +#define META 0x02000000 /* Meta flag, or'ed in */ +#define CTLX 0x04000000 /* ^X flag, or'ed in */ +#define SPEC 0x08000000 /* special key (function keys) */ +#define PRFXMASK 0x0F000000 /* prefix mask */ /* Bindable uEMACS function pointer type and definition template */ #define BINDABLE( fname) int fname( boolean f, int n) #define BBINDABLE( fname) boolean fname( boolean f, int n) -#define TBINDABLE BBINDABLE +#define TBINDABLE BBINDABLE typedef BINDABLE( (*fnp_t)) ; @@ -46,7 +46,7 @@ extern kbind_p keytab ; /* key bind to functions table */ boolean init_bindings( void) ; kbind_p setkeybinding( unsigned key, nbind_p nbp) ; boolean delkeybinding( unsigned key) ; -kbind_p getkeybinding( unsigned key) ; /* look up by key code */ +kbind_p getkeybinding( unsigned key) ; /* look up by key code */ /* find a name to function association in the name to function mapping table */ nbind_p fncmatch( char *name) ; /* look up by name */ diff --git a/pklock.h b/pklock.h index 81955ee..745aec5 100644 --- a/pklock.h +++ b/pklock.h @@ -1,17 +1,13 @@ /* pklock.h -- */ - #ifndef _PKLOCK_H_ #define _PKLOCK_H_ #include "estruct.h" #if (FILOCK && BSD) || SVR4 - char *dolock( const char *fname) ; char *undolock( const char *fname) ; - #endif #endif - /* end of pklock.h */ diff --git a/random.c b/random.c index 6569ed5..aa7295b 100644 --- a/random.c +++ b/random.c @@ -1,12 +1,10 @@ /* random.c -- implements random.h */ #include "random.h" -/* random.c - * - * This file contains the command processing functions for a number of - * random commands. There is no functional grouping here, for sure. - * - * Modified by Petri Kutvonen +/* This file contains the command processing functions for a number of + random commands. There is no functional grouping here, for sure. + + Modified by Petri Kutvonen */ #include @@ -26,26 +24,26 @@ #include "window.h" -static const char *cname[] = { /* names of colors */ - "BLACK", "RED", "GREEN", "YELLOW", "BLUE", - "MAGENTA", "CYAN", "WHITE" -#if PKCODE & IBMPC - , "HIGH" +static const char *cname[] = { /* names of colors */ + "BLACK", "RED", "GREEN", "YELLOW", "BLUE", + "MAGENTA", "CYAN", "WHITE" +#if PKCODE & IBMPC + , "HIGH" #endif } ; -#define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */ +#define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */ -int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ -int gbcolor = 0 ; /* global backgrnd color (black) */ +int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ +int gbcolor = 0 ; /* global backgrnd color (black) */ -boolean hardtab = TRUE ; /* use hard tab instead of soft tab */ -int fillcol = 72 ; /* Current fill column */ +boolean hardtab = TRUE ; /* use hard tab instead of soft tab */ +int fillcol = 72 ; /* Current fill column */ /* uninitialized global definitions */ -int thisflag ; /* Flags, this command */ -int lastflag ; /* Flags, last command */ +int thisflag ; /* Flags, this command */ +int lastflag ; /* Flags, last command */ static int adjustmode( int kind, int global) ; @@ -54,9 +52,9 @@ static int cinsert( void) ; /* Set fill column to n. Bound to C-X F set-fill-column. */ BINDABLE( setfillcol) { - fillcol = n ; - mlwrite( "(Fill column is %d)", n) ; - return TRUE ; + fillcol = n ; + mlwrite( "(Fill column is %d)", n) ; + return TRUE ; } /* Display the current position of the cursor, in origin 1 X-Y coordinates, @@ -66,187 +64,188 @@ BINDABLE( setfillcol) { Normally this is bound to C-X = buffer-position. */ BINDABLE( showcpos) { - line_p lp ; /* current line */ - long numchars; /* # of chars in file */ - int numlines; /* # of lines in file */ - long predchars; /* # chars preceding point */ - int predlines; /* # lines preceding point */ - unicode_t curchar ; /* character under cursor */ - unsigned bytes ; /* length of unicode sequence */ - int ratio; - int col; - int savepos; /* temp save for current offset */ - int ecol; /* column pos/end of current line */ + line_p lp ; /* current line */ + long numchars; /* # of chars in file */ + int numlines; /* # of lines in file */ + long predchars; /* # chars preceding point */ + int predlines; /* # lines preceding point */ + unicode_t curchar ; /* character under cursor */ + unsigned bytes ; /* length of unicode sequence */ + int ratio; + int col; + int savepos; /* temp save for current offset */ + int ecol; /* column pos/end of current line */ - /* start counting chars and lines */ - numchars = 0; - numlines = 0; - predchars = 0; - predlines = 0; - bytes = lgetchar( &curchar) ; - for( lp = lforw( curbp->b_linep) ; lp != curbp->b_linep ; lp = lforw( lp)) { - /* if we are on the current line, record it */ - if (lp == curwp->w_dotp) { - predlines = numlines; - predchars = numchars + curwp->w_doto; - } - /* on to the next line */ - ++numlines; - numchars += llength( lp) + ((curbp->b_mode & MDDOS) ? 2 : 1) ; - } + /* start counting chars and lines */ + numchars = 0; + numlines = 0; + predchars = 0; + predlines = 0; + bytes = lgetchar( &curchar) ; + for( lp = lforw( curbp->b_linep) ; lp != curbp->b_linep ; lp = lforw( lp)) { + /* if we are on the current line, record it */ + if (lp == curwp->w_dotp) { + predlines = numlines; + predchars = numchars + curwp->w_doto; + } + /* on to the next line */ + ++numlines; + numchars += llength( lp) + ((curbp->b_mode & MDDOS) ? 2 : 1) ; + } - /* if at end of file, record it */ - if (curwp->w_dotp == curbp->b_linep) { - predlines = numlines; - predchars = numchars; - bytes = 0 ; - } + /* if at end of file, record it */ + if (curwp->w_dotp == curbp->b_linep) { + predlines = numlines; + predchars = numchars; + bytes = 0 ; + } - /* Get real column and end-of-line column. */ - col = getccol(FALSE); - savepos = curwp->w_doto; - curwp->w_doto = llength(curwp->w_dotp); - ecol = getccol(FALSE); - curwp->w_doto = savepos; + /* Get real column and end-of-line column. */ + col = getccol(FALSE); + savepos = curwp->w_doto; + curwp->w_doto = llength(curwp->w_dotp); + ecol = getccol(FALSE); + curwp->w_doto = savepos; - /* Ratio before dot. */ - ratio = (numchars == 0) ? 100 : (100L * predchars) / numchars ; + /* Ratio before dot. */ + ratio = (numchars == 0) ? 100 : (100L * predchars) / numchars ; - /* summarize and report the info */ - char fmtbuf[] = "Line %d/%d Col %d/%d Char %D/%D (%d%%) char = %s%x" ; - if( bytes == 0) - strcpy( &fmtbuf[ 39], "EOF") ; + /* summarize and report the info */ + char fmtbuf[] = "Line %d/%d Col %d/%d Char %D/%D (%d%%) char = %s%x" ; + if( bytes == 0) + strcpy( &fmtbuf[ 39], "EOF") ; - mlwrite( fmtbuf, predlines + 1, numlines + 1, col, ecol, predchars, - numchars, ratio, (bytes > 1) ? "\\u" : "0x", curchar) ; - return TRUE; + mlwrite( fmtbuf, predlines + 1, numlines + 1, col, ecol, predchars, + numchars, ratio, (bytes > 1) ? "\\u" : "0x", curchar) ; + return TRUE; } int getcline(void) -{ /* get the current line number */ - line_p lp ; /* current line */ - int numlines; /* # of lines before point */ +{ /* get the current line number */ + line_p lp ; /* current line */ + int numlines; /* # of lines before point */ - /* starting at the beginning of the buffer */ - lp = lforw(curbp->b_linep); + /* starting at the beginning of the buffer */ + lp = lforw(curbp->b_linep); - /* start counting lines */ - numlines = 0; - while (lp != curbp->b_linep) { - /* if we are on the current line, record it */ - if (lp == curwp->w_dotp) - break; - ++numlines; - lp = lforw(lp); - } + /* start counting lines */ + numlines = 0; + while (lp != curbp->b_linep) { + /* if we are on the current line, record it */ + if (lp == curwp->w_dotp) + break; + ++numlines; + lp = lforw(lp); + } - /* and return the resulting count */ - return numlines + 1; + /* and return the resulting count */ + return numlines + 1; } /* Return current column. Stop at first non-blank given TRUE argument. */ int getccol( int bflg) { - int i, col ; - line_p dlp = curwp->w_dotp ; - int byte_offset = curwp->w_doto ; - int len = llength( dlp) ; + int i, col ; + line_p dlp = curwp->w_dotp ; + int byte_offset = curwp->w_doto ; + int len = llength( dlp) ; - col = i = 0; - while (i < byte_offset) { - unicode_t c; + col = i = 0; + while (i < byte_offset) { + unicode_t c; - i += utf8_to_unicode(dlp->l_text, i, len, &c); - if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */ - break ; - if (c == '\t') - col += tabwidth - col % tabwidth ; - else if (c < 0x20 || c == 0x7F) /* displayed as ^c */ - col += 2 ; - else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */ - col += 3 ; - else { - int w = utf8_width( c) ; /* incomplete wc_width */ - col += (w < 0) ? 2 : w ; - } - } + i += utf8_to_unicode(dlp->l_text, i, len, &c); + if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */ + break ; + if (c == '\t') + col += tabwidth - col % tabwidth ; + else if (c < 0x20 || c == 0x7F) /* displayed as ^c */ + col += 2 ; + else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */ + col += 3 ; + else { + int w = utf8_width( c) ; /* incomplete wc_width */ + col += (w < 0) ? 2 : w ; + } + } - return col ; + return col ; } /* * Set current column. * - * int pos; position to set cursor + * int pos; position to set cursor */ boolean setccol( int pos) { - int i; /* index into current line */ - int col; /* current cursor column */ - int llen; /* length of line in bytes */ - char *text ; + int i; /* index into current line */ + int col; /* current cursor column */ + int llen; /* length of line in bytes */ + char *text ; - col = 0; - llen = llength(curwp->w_dotp); - text = curwp->w_dotp->l_text ; + col = 0; + llen = llength(curwp->w_dotp); + text = curwp->w_dotp->l_text ; - /* scan the line until we are at or past the target column */ - for( i = 0 ; i < llen && col < pos ; ) { - unicode_t c ; /* character being scanned */ + /* scan the line until we are at or past the target column */ + for( i = 0 ; i < llen && col < pos ; ) { + unicode_t c ; /* character being scanned */ - /* advance one character */ - i += utf8_to_unicode( text, i, llen, &c) ; - if (c == '\t') - col += tabwidth - col % tabwidth ; - else if (c < 0x20 || c == 0x7F) /* displayed as ^C */ - col += 2 ; - else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */ - col += 3 ; - else - col += 1 ; - } + /* advance one character */ + i += utf8_to_unicode( text, i, llen, &c) ; + if (c == '\t') + col += tabwidth - col % tabwidth ; + else if (c < 0x20 || c == 0x7F) /* displayed as ^C */ + col += 2 ; + else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */ + col += 3 ; + else + col += 1 ; + } - /* set us at the new position */ - curwp->w_doto = i; + /* set us at the new position */ + curwp->w_doto = i; - /* and tell whether we made it */ - return col >= pos; + /* and tell whether we made it */ + return col >= pos; } -/* - * Twiddle the two characters on either side of dot. If dot is at the end of - * the line twiddle the two characters before it. Return with an error if dot - * is at the beginning of line; it seems to be a bit pointless to make this - * work. This fixes up a very common typo with a single stroke. Normally bound - * to "C-T". This always works within a line, so "WFEDIT" is good enough. + +/* Twiddle the two characters on either side of dot. If dot is at the end + of the line twiddle the two characters before it. Return with an error + if dot is at the beginning of line; it seems to be a bit pointless to + make this work. This fixes up a very common typo with a single stroke. + Normally bound to "C-T". This always works within a line, so "WFEDIT" + is good enough. */ -boolean twiddle( int f, int n) { - unicode_t c ; - boolean eof_f = FALSE ; +BBINDABLE( twiddle) { + unicode_t c ; + boolean eof_f = FALSE ; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - int len = llength( curwp->w_dotp) ; - if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */ - return FALSE ; + int len = llength( curwp->w_dotp) ; + if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */ + return FALSE ; - if( curwp->w_doto == len) { /* at end of line */ - backchar( FALSE, 1) ; - eof_f = TRUE ; - } + if( curwp->w_doto == len) { /* at end of line */ + backchar( FALSE, 1) ; + eof_f = TRUE ; + } - len = lgetchar( &c) ; /* len => unicode or extended ASCII */ - ldelchar( 1, FALSE) ; - backchar( FALSE, 1) ; - if( len == 1) - linsert_byte( 1, c) ; - else - linsert( 1, c) ; + len = lgetchar( &c) ; /* len => unicode or extended ASCII */ + ldelchar( 1, FALSE) ; + backchar( FALSE, 1) ; + if( len == 1) + linsert_byte( 1, c) ; + else + linsert( 1, c) ; - if( eof_f == TRUE) - forwchar( FALSE, 1) ; + if( eof_f == TRUE) + forwchar( FALSE, 1) ; - lchange( WFEDIT) ; - return TRUE ; + lchange( WFEDIT) ; + return TRUE ; } /* Quote the next character, and insert it into the buffer. All the @@ -256,194 +255,194 @@ boolean twiddle( int f, int n) { quote-character. */ BINDABLE( quote) { - int ret ; + int ret ; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - int c = ectoc( get1key()) ; - if( n < 0) - ret = FALSE ; - else if( n == 0) - ret = TRUE ; - else if( c == '\n') - do - ret = lnewline() ; - while( ret == TRUE && --n) ; - else - ret = linsert( n, c) ; + int c = ectoc( get1key()) ; + if( n < 0) + ret = FALSE ; + else if( n == 0) + ret = TRUE ; + else if( c == '\n') + do + ret = lnewline() ; + while( ret == TRUE && --n) ; + else + ret = linsert( n, c) ; - return ret ; + return ret ; } /* Insert tab/blank/space up to nth next tabulation according to hard/soft tab current state and tab width. Bound to C-I handle-tab. */ BINDABLE( insert_tab) { - int status ; + int status ; - if( n < 0) - status = FALSE ; - else if( n == 0) - status = TRUE ; - else if( hardtab == TRUE) - status = linsert( n, '\t') ; - else /* softtab */ - do { - status = linsert( tabwidth - getccol( FALSE) % tabwidth, ' ') ; - } while( status != FALSE && --n) ; + if( n < 0) + status = FALSE ; + else if( n == 0) + status = TRUE ; + else if( hardtab == TRUE) + status = linsert( n, '\t') ; + else /* softtab */ + do { + status = linsert( tabwidth - getccol( FALSE) % tabwidth, ' ') ; + } while( status != FALSE && --n) ; - return status ; + return status ; } /* * change tabs to spaces * - * int f, n; default flag and numeric repeat count + * int f, n; default flag and numeric repeat count */ BINDABLE( detab) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( f == FALSE) - n = 1 ; + if( f == FALSE) + n = 1 ; - /* loop thru detabbing n lines */ - int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ - for( ; n ; n -= inc) { - curwp->w_doto = 0; /* start at the beginning */ + /* loop thru detabbing n lines */ + int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ + for( ; n ; n -= inc) { + curwp->w_doto = 0; /* start at the beginning */ - /* detab the entire current line */ - while (curwp->w_doto < llength(curwp->w_dotp)) { - /* if we have a tab */ - if( curwbyte() == '\t') { - int size ; + /* detab the entire current line */ + while (curwp->w_doto < llength(curwp->w_dotp)) { + /* if we have a tab */ + if( curwbyte() == '\t') { + int size ; - ldelchar( 1, FALSE) ; - size = tabwidth - curwp->w_doto % tabwidth ; - insspace( TRUE, size) ; - forwchar( TRUE, size) ; - } else - forwchar( FALSE, 1) ; - } + ldelchar( 1, FALSE) ; + size = tabwidth - curwp->w_doto % tabwidth ; + insspace( TRUE, size) ; + forwchar( TRUE, size) ; + } else + forwchar( FALSE, 1) ; + } - /* advance/or back to the next line */ - if( forwline( TRUE, inc) == FALSE) - break ; - } + /* advance/or back to the next line */ + if( forwline( TRUE, inc) == FALSE) + break ; + } - curwp->w_doto = 0; /* to the begining of the line */ - thisflag &= ~CFCPCN; /* flag that this resets the goal column */ - lchange(WFEDIT); /* yes, we have made at least an edit */ - return (n == 0) ? TRUE : FALSE ; + curwp->w_doto = 0; /* to the begining of the line */ + thisflag &= ~CFCPCN; /* flag that this resets the goal column */ + lchange(WFEDIT); /* yes, we have made at least an edit */ + return (n == 0) ? TRUE : FALSE ; } /* * change spaces to tabs where possible * - * int f, n; default flag and numeric repeat count + * int f, n; default flag and numeric repeat count */ BINDABLE( entab) { -#define nextab(a) (a + tabwidth - a % tabwidth) +#define nextab(a) (a + tabwidth - a % tabwidth) - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( f == FALSE) - n = 1 ; + if( f == FALSE) + n = 1 ; - /* loop thru entabbing n lines */ - int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ - for( ; n ; n -= inc) { - int fspace ; /* pointer to first space if in a run */ - int ccol ; /* current cursor column */ + /* loop thru entabbing n lines */ + int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ + for( ; n ; n -= inc) { + int fspace ; /* pointer to first space if in a run */ + int ccol ; /* current cursor column */ - curwp->w_doto = 0; /* start at the beginning */ + curwp->w_doto = 0; /* start at the beginning */ - /* entab the entire current line */ - fspace = -1; - ccol = 0; - while (curwp->w_doto < llength(curwp->w_dotp)) { - /* see if it is time to compress */ - if ((fspace >= 0) && (nextab(fspace) <= ccol)) { - if (ccol - fspace < 2) - fspace = -1; - else { - /* there is a bug here dealing with mixed space/tabed - lines.......it will get fixed */ - backchar(TRUE, ccol - fspace); - ldelete( (long) (ccol - fspace), FALSE) ; - linsert(1, '\t'); - fspace = -1; - } - } + /* entab the entire current line */ + fspace = -1; + ccol = 0; + while (curwp->w_doto < llength(curwp->w_dotp)) { + /* see if it is time to compress */ + if ((fspace >= 0) && (nextab(fspace) <= ccol)) { + if (ccol - fspace < 2) + fspace = -1; + else { + /* there is a bug here dealing with mixed space/tabed + lines.......it will get fixed */ + backchar(TRUE, ccol - fspace); + ldelete( (long) (ccol - fspace), FALSE) ; + linsert(1, '\t'); + fspace = -1; + } + } - /* get the current character */ - switch( curwbyte()) { - case '\t': /* a tab...count em up */ - ccol = nextab(ccol); - break; + /* get the current character */ + switch( curwbyte()) { + case '\t': /* a tab...count em up */ + ccol = nextab(ccol); + break; - case ' ': /* a space...compress? */ - if (fspace == -1) - fspace = ccol; - ccol++; - break; + case ' ': /* a space...compress? */ + if (fspace == -1) + fspace = ccol; + ccol++; + break; - default: /* any other char...just count */ - ccol++; - fspace = -1; - } + default: /* any other char...just count */ + ccol++; + fspace = -1; + } - forwchar(FALSE, 1); - } + forwchar(FALSE, 1); + } - /* advance/or back to the next line */ - if( forwline( TRUE, inc) == FALSE) - break ; - } + /* advance/or back to the next line */ + if( forwline( TRUE, inc) == FALSE) + break ; + } - curwp->w_doto = 0; /* to the begining of the line */ - thisflag &= ~CFCPCN; /* flag that this resets the goal column */ - lchange(WFEDIT); /* yes, we have made at least an edit */ - return (n == 0) ? TRUE : FALSE ; + curwp->w_doto = 0; /* to the begining of the line */ + thisflag &= ~CFCPCN; /* flag that this resets the goal column */ + lchange(WFEDIT); /* yes, we have made at least an edit */ + return (n == 0) ? TRUE : FALSE ; } /* * trim trailing whitespace from the point to eol * - * int f, n; default flag and numeric repeat count + * int f, n; default flag and numeric repeat count */ BINDABLE( trim) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( f == FALSE) - n = 1 ; + if( f == FALSE) + n = 1 ; - /* loop thru trimming n lines */ - int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ - for( ; n ; n -= inc) { - line_p lp ; /* current line pointer */ - int offset ; /* original line offset position */ - int length ; /* current length */ + /* loop thru trimming n lines */ + int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */ + for( ; n ; n -= inc) { + line_p lp ; /* current line pointer */ + int offset ; /* original line offset position */ + int length ; /* current length */ - lp = curwp->w_dotp; /* find current line text */ - offset = curwp->w_doto; /* save original offset */ + lp = curwp->w_dotp; /* find current line text */ + offset = curwp->w_doto; /* save original offset */ - /* trim the current line */ - for( length = lp->l_used ; length > offset ; length--) { - char c = lgetc( lp, length - 1) ; - if( c != ' ' && c != '\t') - break ; - } + /* trim the current line */ + for( length = lp->l_used ; length > offset ; length--) { + char c = lgetc( lp, length - 1) ; + if( c != ' ' && c != '\t') + break ; + } - lp->l_used = length; + lp->l_used = length; - /* advance/or back to the next line */ - if( forwline( TRUE, inc) == FALSE) - break ; - } + /* advance/or back to the next line */ + if( forwline( TRUE, inc) == FALSE) + break ; + } - lchange(WFEDIT); - thisflag &= ~CFCPCN; /* flag that this resets the goal column */ - return (n == 0) ? TRUE : FALSE ; + lchange(WFEDIT); + thisflag &= ~CFCPCN; /* flag that this resets the goal column */ + return (n == 0) ? TRUE : FALSE ; } /* @@ -452,16 +451,16 @@ BINDABLE( trim) { * procerssors. They even handle the looping. Normally this is bound to "C-O". */ BINDABLE( openline) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - int ret = (n < 0) ? FALSE : TRUE ; - for( int i = n ; ret == TRUE && i ; i--) /* Insert newlines. */ - ret = lnewline() ; + int ret = (n < 0) ? FALSE : TRUE ; + for( int i = n ; ret == TRUE && i ; i--) /* Insert newlines. */ + ret = lnewline() ; - if( ret == TRUE) /* Then back up overtop */ - ret = backchar( f, n) ; /* of them all. */ + if( ret == TRUE) /* Then back up overtop */ + ret = backchar( f, n) ; /* of them all. */ - return ret ; + return ret ; } /* @@ -469,95 +468,95 @@ BINDABLE( openline) { * indentation as specified. */ BINDABLE( insert_newline) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( n < 0) - return FALSE ; + if( n < 0) + return FALSE ; - /* if we are in C mode and this is a default */ - if (n == 1 && (curbp->b_mode & MDCMOD) && - curwp->w_dotp != curbp->b_linep) - return cinsert(); + /* if we are in C mode and this is a default */ + if (n == 1 && (curbp->b_mode & MDCMOD) && + curwp->w_dotp != curbp->b_linep) + return cinsert(); - /* - * If a newline was typed, fill column is defined, the argument is non- - * negative, wrap mode is enabled, and we are now past fill column, - * and we are not read-only, perform word wrap. - */ - if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && - getccol(FALSE) > fillcol && - (curwp->w_bufp->b_mode & MDVIEW) == FALSE) - execute(META | SPEC | 'W', FALSE, 1); + /* + * If a newline was typed, fill column is defined, the argument is non- + * negative, wrap mode is enabled, and we are now past fill column, + * and we are not read-only, perform word wrap. + */ + if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && + getccol(FALSE) > fillcol && + (curwp->w_bufp->b_mode & MDVIEW) == FALSE) + execute(META | SPEC | 'W', FALSE, 1); - /* insert some lines */ - while (n--) { - int s ; + /* insert some lines */ + while (n--) { + int s ; - if ((s = lnewline()) != TRUE) - return s; + if ((s = lnewline()) != TRUE) + return s; #if SCROLLCODE - curwp->w_flag |= WFINS; + curwp->w_flag |= WFINS; #endif - } - return TRUE; + } + return TRUE; } static int cinsert(void) -{ /* insert a newline and indentation for C */ - char *cptr; /* string pointer into text to copy */ - int tptr; /* index to scan into line */ - int bracef; /* was there a brace at the end of line? */ - int i, nicol ; +{ /* insert a newline and indentation for C */ + char *cptr; /* string pointer into text to copy */ + int tptr; /* index to scan into line */ + int bracef; /* was there a brace at the end of line? */ + int i, nicol ; - /* grab a pointer to text to copy indentation from */ - cptr = &curwp->w_dotp->l_text[0]; + /* grab a pointer to text to copy indentation from */ + cptr = &curwp->w_dotp->l_text[0]; - /* check for a brace */ - tptr = curwp->w_doto ; - bracef = (tptr > 0) && (cptr[ tptr - 1] == '{') ; + /* check for a brace */ + tptr = curwp->w_doto ; + bracef = (tptr > 0) && (cptr[ tptr - 1] == '{') ; - /* save the indent of the previous line */ - nicol = 0 ; - for( i = 0 ; i < tptr ; i += 1) { - int ch ; + /* save the indent of the previous line */ + nicol = 0 ; + for( i = 0 ; i < tptr ; i += 1) { + int ch ; - ch = cptr[ i] ; - if( ch == ' ') - nicol += 1 ; - else if( ch == '\t') - nicol += tabwidth - nicol % tabwidth ; - else - break ; - } + ch = cptr[ i] ; + if( ch == ' ') + nicol += 1 ; + else if( ch == '\t') + nicol += tabwidth - nicol % tabwidth ; + else + break ; + } - if( i == tptr) { /* all line is blank */ - curwp->w_doto = 0 ; /* gotobol */ - lnewline() ; - curwp->w_doto = tptr ; /* gotoeol */ - } else { - /* put in the newline */ - if (lnewline() == FALSE) - return FALSE; + if( i == tptr) { /* all line is blank */ + curwp->w_doto = 0 ; /* gotobol */ + lnewline() ; + curwp->w_doto = tptr ; /* gotoeol */ + } else { + /* put in the newline */ + if (lnewline() == FALSE) + return FALSE; - /* and the saved indentation */ - i = nicol % tabwidth ; /* spaces */ - nicol /= tabwidth ; /* tabs */ - if( bracef) { - /* and one more tab for a brace */ - nicol += 1 ; - i = 0 ; - } + /* and the saved indentation */ + i = nicol % tabwidth ; /* spaces */ + nicol /= tabwidth ; /* tabs */ + if( bracef) { + /* and one more tab for a brace */ + nicol += 1 ; + i = 0 ; + } - if( nicol > 0) - insert_tab( FALSE, nicol) ; + if( nicol > 0) + insert_tab( FALSE, nicol) ; - if( i > 0) - linsert( i, ' ') ; - } + if( i > 0) + linsert( i, ' ') ; + } #if SCROLLCODE - curwp->w_flag |= WFINS; + curwp->w_flag |= WFINS; #endif - return TRUE; + return TRUE; } @@ -566,26 +565,26 @@ static int cinsert(void) * command deletes all the blank lines above and below the current line. * If it is sitting on a non blank line then it deletes all of the blank * lines after the line. Normally this command is bound to C-X C-O - * delete-blank-lines. Any argument is ignored. + * delete-blank-lines. Any argument is ignored. */ BINDABLE( deblank) { - line_p lp1, lp2 ; - long nld ; + line_p lp1, lp2 ; + long nld ; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - lp1 = curwp->w_dotp; - while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep) - lp1 = lp2; - lp2 = lp1; - nld = 0; - while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0) - ++nld; - if (nld == 0) - return TRUE; - curwp->w_dotp = lforw(lp1); - curwp->w_doto = 0; - return ldelete(nld, FALSE); + lp1 = curwp->w_dotp; + while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep) + lp1 = lp2; + lp2 = lp1; + nld = 0; + while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0) + ++nld; + if (nld == 0) + return TRUE; + curwp->w_dotp = lforw(lp1); + curwp->w_doto = 0; + return ldelete(nld, FALSE); } /* Insert a newline, then enough tabs and spaces to duplicate the @@ -597,36 +596,36 @@ BINDABLE( deblank) { * newline-and-indent. */ BINDABLE( indent) { - int i ; + int i ; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( n < 0) - return FALSE ; + if( n < 0) + return FALSE ; /* number of columns to indent */ - int nicol = 0 ; - for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) { - int c ; + int nicol = 0 ; + for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) { + int c ; - c = lgetc( curwp->w_dotp, i) ; - if( c == '\t') - nicol += tabwidth - nicol % tabwidth ; - else if( c == ' ') - nicol += 1 ; - else - break ; - } + c = lgetc( curwp->w_dotp, i) ; + if( c == '\t') + nicol += tabwidth - nicol % tabwidth ; + else if( c == ' ') + nicol += 1 ; + else + break ; + } - i = nicol / tabwidth ; /* # of tab to insert */ - nicol %= tabwidth ; /* # of space to insert */ - while( n--) - if( lnewline() == FALSE - || ( i != 0 && insert_tab( FALSE, i) == FALSE) - || ( nicol != 0 && linsert( nicol, ' ') == FALSE)) - return FALSE ; + i = nicol / tabwidth ; /* # of tab to insert */ + nicol %= tabwidth ; /* # of space to insert */ + while( n--) + if( lnewline() == FALSE + || ( i != 0 && insert_tab( FALSE, i) == FALSE) + || ( nicol != 0 && linsert( nicol, ' ') == FALSE)) + return FALSE ; - return TRUE ; + return TRUE ; } /* @@ -636,20 +635,20 @@ BINDABLE( indent) { * of text if typed with a big argument. Normally bound to "C-D". */ BINDABLE( forwdel) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( n == 0) - return TRUE ; - else if( n < 0) - return backdel( f, -n) ; + if( n == 0) + return TRUE ; + else if( n < 0) + return backdel( f, -n) ; - if (f != FALSE) { /* Really a kill. */ - if ((lastflag & CFKILL) == 0) - kdelete(); - thisflag |= CFKILL; - } + if (f != FALSE) { /* Really a kill. */ + if ((lastflag & CFKILL) == 0) + kdelete(); + thisflag |= CFKILL; + } - return ldelchar( n, f != FALSE) ; + return ldelchar( n, f != FALSE) ; } /* @@ -659,20 +658,20 @@ BINDABLE( forwdel) { * both "RUBOUT" and "C-H". */ BINDABLE( backdel) { - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if( n == 0) - return TRUE ; - else if( n < 0) - return forwdel( f, -n) ; + if( n == 0) + return TRUE ; + else if( n < 0) + return forwdel( f, -n) ; - if (f != FALSE) { /* Really a kill. */ - if ((lastflag & CFKILL) == 0) - kdelete(); - thisflag |= CFKILL; - } + if (f != FALSE) { /* Really a kill. */ + if ((lastflag & CFKILL) == 0) + kdelete(); + thisflag |= CFKILL; + } - return backchar( f, n) && ldelchar( n, f != FALSE) ; + return backchar( f, n) && ldelchar( n, f != FALSE) ; } /* @@ -684,199 +683,198 @@ BINDABLE( backdel) { * that number of newlines. Normally bound to "C-K". */ BINDABLE( killtext) { - line_p nextp ; - long chunk; + line_p nextp ; + long chunk; - assert( !(curbp->b_mode & MDVIEW)) ; + assert( !(curbp->b_mode & MDVIEW)) ; - if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */ - kdelete(); /* last wasn't a kill. */ - thisflag |= CFKILL; - if (f == FALSE) { - chunk = llength(curwp->w_dotp) - curwp->w_doto; - if (chunk == 0) - chunk = 1; - } else if (n == 0) { - chunk = curwp->w_doto; - curwp->w_doto = 0; - } else if (n > 0) { - chunk = llength(curwp->w_dotp) - curwp->w_doto + 1; - nextp = lforw(curwp->w_dotp); - while (--n) { - if (nextp == curbp->b_linep) - return FALSE; - chunk += llength(nextp) + 1; - nextp = lforw(nextp); - } - } else { - mlwrite("neg kill"); - return FALSE; - } - return ldelete(chunk, TRUE); + if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */ + kdelete(); /* last wasn't a kill. */ + thisflag |= CFKILL; + if (f == FALSE) { + chunk = llength(curwp->w_dotp) - curwp->w_doto; + if (chunk == 0) + chunk = 1; + } else if (n == 0) { + chunk = curwp->w_doto; + curwp->w_doto = 0; + } else if (n > 0) { + chunk = llength(curwp->w_dotp) - curwp->w_doto + 1; + nextp = lforw(curwp->w_dotp); + while (--n) { + if (nextp == curbp->b_linep) + return FALSE; + chunk += llength(nextp) + 1; + nextp = lforw(nextp); + } + } else { + mlwrite("neg kill"); + return FALSE; + } + return ldelete(chunk, TRUE); } /* prompt and set an editor mode * - * int f, n; default and argument + * int f, n; default and argument */ BINDABLE( setemode) { - return adjustmode( TRUE, FALSE) ; + return adjustmode( TRUE, FALSE) ; } /* prompt and delete an editor mode * - * int f, n; default and argument + * int f, n; default and argument */ BINDABLE( delmode) { - return adjustmode( FALSE, FALSE) ; + return adjustmode( FALSE, FALSE) ; } /* prompt and set a global editor mode * - * int f, n; default and argument + * int f, n; default and argument */ BINDABLE( setgmode) { - return adjustmode( TRUE, TRUE) ; + return adjustmode( TRUE, TRUE) ; } /* prompt and delete a global editor mode * - * int f, n; default and argument + * int f, n; default and argument */ BINDABLE( delgmode) { - return adjustmode( FALSE, TRUE) ; + return adjustmode( FALSE, TRUE) ; } -/* - * change the editor mode status + +/* change the editor mode status * - * int kind; true = set, false = delete - * int global; true = global flag, false = current buffer flag + * int kind; true = set, false = delete + * int global; true = global flag, false = current buffer flag */ static int adjustmode( int kind, int global) { - unsigned i ; /* loop index */ - int status; /* error return on input */ - char prompt[50]; /* string to prompt user with */ - char *cbuf ; /* buffer to recieve mode name into */ + unsigned i ; /* loop index */ + int status; /* error return on input */ + char prompt[50]; /* string to prompt user with */ + char *cbuf ; /* buffer to recieve mode name into */ - /* build the proper prompt string */ - if (global) - strcpy(prompt, "Global mode to "); - else - strcpy(prompt, "Mode to "); + /* build the proper prompt string */ + if (global) + strcpy(prompt, "Global mode to "); + else + strcpy(prompt, "Mode to "); - if (kind == TRUE) - strcat(prompt, "add: "); - else - strcat(prompt, "delete: "); + if (kind == TRUE) + strcat(prompt, "add: "); + else + strcat(prompt, "delete: "); - /* prompt the user and get an answer */ + /* prompt the user and get an answer */ - status = newmlarg( &cbuf, prompt, 0) ; - if (status != TRUE) - return status; + status = newmlarg( &cbuf, prompt, 0) ; + if (status != TRUE) + return status; - /* test it first against the colors we know */ - for (i = 0; i < NCOLORS; i++) { - if( strcasecmp( cbuf, cname[ i]) == 0) { - /* finding the match, we set the color */ -#if COLOR - if( *cbuf >= 'A' && *cbuf <= 'Z') { - if (global) - gfcolor = i; -#if PKCODE == 0 - else + /* test it first against the colors we know */ + for (i = 0; i < NCOLORS; i++) { + if( strcasecmp( cbuf, cname[ i]) == 0) { + /* finding the match, we set the color */ +#if COLOR + if( *cbuf >= 'A' && *cbuf <= 'Z') { + if (global) + gfcolor = i; +#if PKCODE == 0 + else #endif - curwp->w_fcolor = i; - } else { - if (global) - gbcolor = i; -#if PKCODE == 0 - else + curwp->w_fcolor = i; + } else { + if (global) + gbcolor = i; +#if PKCODE == 0 + else #endif - curwp->w_bcolor = i; - } + curwp->w_bcolor = i; + } - curwp->w_flag |= WFCOLR; + curwp->w_flag |= WFCOLR; #endif - mlerase(); - free( cbuf) ; - return TRUE; - } - } + mlerase(); + free( cbuf) ; + return TRUE; + } + } - /* test it against the modes we know */ + /* test it against the modes we know */ - for (i = 0; i < NUMMODES; i++) { - if( strcasecmp( cbuf, modename[ i]) == 0) { - /* finding a match, we process it */ - if (kind == TRUE) - if (global) - gmode |= (1 << i); - else - curbp->b_mode |= (1 << i); - else if (global) - gmode &= ~(1 << i); - else - curbp->b_mode &= ~(1 << i); - /* display new mode line */ - if (global == 0) - upmode(); - mlerase(); /* erase the junk */ - free( cbuf) ; - return TRUE; - } - } + for (i = 0; i < NUMMODES; i++) { + if( strcasecmp( cbuf, modename[ i]) == 0) { + /* finding a match, we process it */ + if (kind == TRUE) + if (global) + gmode |= (1 << i); + else + curbp->b_mode |= (1 << i); + else if (global) + gmode &= ~(1 << i); + else + curbp->b_mode &= ~(1 << i); + /* display new mode line */ + if (global == 0) + upmode(); + mlerase(); /* erase the junk */ + free( cbuf) ; + return TRUE; + } + } - mlwrite("No such mode!"); - free( cbuf) ; - return FALSE; + mlwrite("No such mode!"); + free( cbuf) ; + return FALSE; } static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) { - char *tstring ; /* string to add */ + char *tstring ; /* string to add */ /* ask for string to insert */ - int status = newmlargt( &tstring, prompt, 0) ; - if( tstring == NULL) - return status ; + int status = newmlargt( &tstring, prompt, 0) ; + if( tstring == NULL) + return status ; - if( f == FALSE) - n = 1 ; - else if( n < 0) - n = -n ; + if( f == FALSE) + n = 1 ; + else if( n < 0) + n = -n ; - /* insert it */ - while( n-- && status == TRUE) - status = fun( tstring) ; + /* insert it */ + while( n-- && status == TRUE) + status = fun( tstring) ; - free( tstring) ; - return status ; + free( tstring) ; + return status ; } -/* - * ask for and insert a string into the current - * buffer at the current point - * - * int f, n; ignored arguments + +/* ask for and insert a string into the current buffer at the current point + + int f, n; ignored arguments */ BINDABLE( istring) { - return iovstring( f, n, "insert-string: ", linstr) ; + return iovstring( f, n, "insert-string: ", linstr) ; } -/* - * ask for and overwite a string into the current - * buffer at the current point - * - * int f, n; ignored arguments + +/* ask for and overwite a string into the current buffer at the current + point + + int f, n; ignored arguments */ BINDABLE( ovstring) { - return iovstring( f, n, "overwrite-string: ", lover) ; + return iovstring( f, n, "overwrite-string: ", lover) ; } /* end of random.c */ diff --git a/random.h b/random.h index 6f7e657..1668f1f 100644 --- a/random.h +++ b/random.h @@ -1,19 +1,18 @@ /* random.h -- various commands */ - #ifndef _RANDOM_H_ #define _RANDOM_H_ #include "names.h" /* Command flags */ -#define CFCPCN 0x0001 /* Flag that last command was C-P, C-N */ -#define CFKILL 0x0002 /* Flag that last command was a kill */ +#define CFCPCN 0x0001 /* Flag that last command was C-P, C-N */ +#define CFKILL 0x0002 /* Flag that last command was a kill */ -extern int thisflag ; /* Flags, this command */ -extern int lastflag ; /* Flags, last command */ +extern int thisflag ; /* Flags, this command */ +extern int lastflag ; /* Flags, last command */ -extern int fillcol ; /* Fill column */ -extern boolean hardtab ; /* Use hard tab instead of soft tab */ +extern int fillcol ; /* Fill column */ +extern boolean hardtab ; /* Use hard tab instead of soft tab */ int getcline( void) ; @@ -21,28 +20,27 @@ int getccol( int bflg) ; boolean setccol( int pos) ; /* Bindable functions */ -BINDABLE( setfillcol) ; -BINDABLE( showcpos) ; -boolean twiddle( int f, int n) ; -BINDABLE( quote) ; -BINDABLE( insert_tab) ; -BINDABLE( detab) ; -BINDABLE( entab) ; -BINDABLE( trim) ; -BINDABLE( openline) ; -BINDABLE( insert_newline) ; -BINDABLE( deblank) ; -BINDABLE( indent) ; -BINDABLE( forwdel) ; -BINDABLE( backdel) ; -BINDABLE( killtext) ; -BINDABLE( setemode) ; -BINDABLE( delmode) ; -BINDABLE( setgmode) ; -BINDABLE( delgmode) ; -BINDABLE( istring) ; -BINDABLE( ovstring) ; + BINDABLE( setfillcol) ; + BINDABLE( showcpos) ; +BBINDABLE( twiddle) ; + BINDABLE( quote) ; + BINDABLE( insert_tab) ; + BINDABLE( detab) ; + BINDABLE( entab) ; + BINDABLE( trim) ; + BINDABLE( openline) ; + BINDABLE( insert_newline) ; + BINDABLE( deblank) ; + BINDABLE( indent) ; + BINDABLE( forwdel) ; + BINDABLE( backdel) ; + BINDABLE( killtext) ; + BINDABLE( setemode) ; + BINDABLE( delmode) ; + BINDABLE( setgmode) ; + BINDABLE( delgmode) ; + BINDABLE( istring) ; + BINDABLE( ovstring) ; #endif - /* end of random.h */ diff --git a/region.h b/region.h index 991d1a0..ee69545 100644 --- a/region.h +++ b/region.h @@ -4,14 +4,13 @@ #include "line.h" -/* - * The starting position of a region, and the size of the region in - * characters, is kept in a region structure. Used by the region commands. +/* The starting position of a region, and the size of the region in + characters, is kept in a region structure. Used by the region commands. */ typedef struct { - line_p r_linep ; /* Origin struct line address. */ - int r_offset ; /* Origin struct line offset. */ - long r_size ; /* Length in characters. */ + line_p r_linep ; /* Origin struct line address. */ + int r_offset ; /* Origin struct line offset. */ + long r_size ; /* Length in characters. */ } region_t ; typedef region_t *region_p ; @@ -25,5 +24,4 @@ BINDABLE( upperregion) ; int getregion( region_p rp) ; #endif - /* end of region.h */ diff --git a/retcode.h b/retcode.h index 8a50cd6..00fe09f 100644 --- a/retcode.h +++ b/retcode.h @@ -1,20 +1,23 @@ +/* retcode.h -- */ #ifndef __RETCODE_H__ #define __RETCODE_H__ -#ifdef FALSE -#error "FALSE shouldn't be defined" -#undef FALSE +#ifdef FALSE +# error "FALSE shouldn't be defined" +# undef FALSE #endif -#ifdef TRUE -#error "TRUE shouldn't be defined" -#undef TRUE + +#ifdef TRUE +# error "TRUE shouldn't be defined" +# undef TRUE #endif typedef enum { - FALSE, /* 0, false, no, bad, etc. */ - TRUE /* 1, true, yes, good, etc. */ + FALSE, /* 0, false, no, bad, etc. */ + TRUE /* 1, true, yes, good, etc. */ } boolean ; -#define ABORT 2 /* 2, death, ^G, abort, etc. */ +#define ABORT 2 /* 2, death, ^G, abort, etc. */ #endif +/* end of retcode.h */ diff --git a/search.h b/search.h index 9b3d596..a2423ce 100644 --- a/search.h +++ b/search.h @@ -1,40 +1,38 @@ /* search.h -- */ - #ifndef _SEARCH_H_ #define _SEARCH_H_ -#define MAGIC 1 /* include regular expression matching? */ +#include "line.h" /* line_p */ +#include "names.h" /* BINDABLE() */ -#include "line.h" - -typedef char spat_t[ 128] ; /* search pattern type */ -#define NPAT sizeof( spat_t) /* # of bytes, pattern */ +typedef char spat_t[ 128] ; /* search pattern type */ +#define NPAT sizeof( spat_t) /* # of bytes, pattern */ extern unsigned int matchlen ; extern char *patmatch ; -extern spat_t pat ; /* Search pattern */ -extern spat_t tap ; /* Reversed pattern array. */ -extern spat_t rpat ; /* replacement pattern */ +extern spat_t pat ; /* Search pattern */ +extern spat_t tap ; /* Reversed pattern array. */ +extern spat_t rpat ; /* replacement pattern */ /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. */ -#define PTBEG 0 /* Leave the point at the beginning on search */ -#define PTEND 1 /* Leave the point at the end on search */ -#define FORWARD 0 /* forward direction */ -#define REVERSE 1 /* backwards direction */ +#define PTBEG 0 /* Leave the point at the beginning on search */ +#define PTEND 1 /* Leave the point at the end on search */ +#define FORWARD 0 /* forward direction */ +#define REVERSE 1 /* backwards direction */ int scanner( const char *patrn, int direct, int beg_or_end) ; /* Bindable functions */ -BINDABLE( forwsearch) ; -BINDABLE( forwhunt) ; -BINDABLE( backsearch) ; BINDABLE( backhunt) ; -BINDABLE( sreplace) ; +BINDABLE( backsearch) ; +BINDABLE( forwhunt) ; +BINDABLE( forwsearch) ; BINDABLE( qreplace) ; +BINDABLE( sreplace) ; int eq( unsigned char bc, unsigned char pc) ; void savematch( void) ; @@ -45,11 +43,11 @@ int boundary( line_p curline, int curoff, int dir) ; void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) ; +#define MAGIC 1 /* include regular expression matching? */ #if MAGIC void mcclear( void) ; void rmcclear( void) ; #endif #endif - /* end of search.h */ diff --git a/spawn.h b/spawn.h index cc219f9..a311a71 100644 --- a/spawn.h +++ b/spawn.h @@ -1,6 +1,8 @@ /* spawn.h -- various operating system access commands */ +#ifndef _SPAWN_H_ +#define _SPAWN_H_ -#include "names.h" +#include "names.h" /* BINDABLE() */ /* Bindable functions */ BINDABLE( spawncli) ; @@ -12,4 +14,5 @@ BINDABLE( filter_buffer) ; void rtfrmshell( void) ; +#endif /* end of spawn.h */ diff --git a/terminal.h b/terminal.h index a25218d..3f7d375 100644 --- a/terminal.h +++ b/terminal.h @@ -1,14 +1,12 @@ +/* terminal.h -- */ #ifndef __TERMINAL_H__ #define __TERMINAL_H__ - -#include "defines.h" /* COLOR, SCROLLCODE */ +#include "defines.h" /* COLOR, SCROLLCODE */ #include "retcode.h" #include "utf8.h" - -/* - * The editor communicates with the display using a high level interface. A +/* The editor communicates with the display using a high level interface. A * "TERM" structure holds useful variables, and indirect pointers to routines * that do useful operations. The low level get and put routines are here too. * This lets a terminal, in addition to having non standard commands, have @@ -17,69 +15,71 @@ * one terminal type. */ struct terminal { - const short t_maxrow ; /* max number of rows allowable */ - const short t_maxcol ; /* max number of columns allowable */ - short t_mrow ; /* max number of rows displayable */ - short t_nrow ; /* current number of rows displayed */ - short t_mcol ; /* max number of rows displayable */ - short t_ncol ; /* current number of columns displayed */ - short t_margin; /* min margin for extended lines */ - short t_scrsiz; /* size of scroll region " */ - int t_pause; /* # times thru update to pause */ - void (*t_open)(void); /* Open terminal at the start. */ - void (*t_close)(void); /* Close terminal at end. */ - void (*t_kopen)(void); /* Open keyboard */ - void (*t_kclose)(void); /* close keyboard */ - int (*t_getchar)(void); /* Get character from keyboard. */ - int (*t_putchar)( unicode_t) ; /* Put character to display. */ - void (*t_flush) (void); /* Flush output buffers. */ - void (*t_move)(int, int);/* Move the cursor, origin 0. */ - void (*t_eeol)(void); /* Erase to end of line. */ - void (*t_eeop)(void); /* Erase to end of page. */ - void (*t_beep)(void); /* Beep. */ - void (*t_rev)(int); /* set reverse video state */ - int (*t_rez)(char *); /* change screen resolution */ -#if COLOR - int (*t_setfor) (); /* set forground color */ - int (*t_setback) (); /* set background color */ + const short t_maxrow ; /* max number of rows allowable */ + const short t_maxcol ; /* max number of columns allowable */ + short t_mrow ; /* max number of rows displayable */ + short t_nrow ; /* current number of rows displayed */ + short t_mcol ; /* max number of rows displayable */ + short t_ncol ; /* current number of columns displayed */ + short t_margin; /* min margin for extended lines */ + short t_scrsiz; /* size of scroll region " */ + int t_pause; /* # times thru update to pause */ + void (*t_open)(void); /* Open terminal at the start. */ + void (*t_close)(void); /* Close terminal at end. */ + void (*t_kopen)(void); /* Open keyboard */ + void (*t_kclose)(void); /* close keyboard */ + int (*t_getchar)(void); /* Get character from keyboard. */ + int (*t_putchar)( unicode_t) ; /* Put character to display. */ + void (*t_flush) (void); /* Flush output buffers. */ + void (*t_move)(int, int);/* Move the cursor, origin 0. */ + void (*t_eeol)(void); /* Erase to end of line. */ + void (*t_eeop)(void); /* Erase to end of page. */ + void (*t_beep)(void); /* Beep. */ + void (*t_rev)(int); /* set reverse video state */ + int (*t_rez)(char *); /* change screen resolution */ +#if COLOR + int (*t_setfor) (); /* set forground color */ + int (*t_setback) (); /* set background color */ #endif #if SCROLLCODE - void (*t_scroll)(int, int,int); /* scroll a region of the screen */ + void (*t_scroll)(int, int,int); /* scroll a region of the screen */ #endif }; -/* TEMPORARY macros for terminal I/O (to be placed in a machine - dependant place later) */ +/* TEMPORARY macros for terminal I/O (to be placed in a machine dependant + place later) + */ -#define TTopen (*term.t_open) -#define TTclose (*term.t_close) -#define TTkopen (*term.t_kopen) -#define TTkclose (*term.t_kclose) -#define TTgetc (*term.t_getchar) -#define TTputc (*term.t_putchar) -#define TTflush (*term.t_flush) -#define TTmove (*term.t_move) -#define TTeeol (*term.t_eeol) -#define TTeeop (*term.t_eeop) -#define TTbeep (*term.t_beep) -#define TTrev (*term.t_rev) -#define TTrez (*term.t_rez) -#if COLOR -#define TTforg (*term.t_setfor) -#define TTbacg (*term.t_setback) +#define TTopen (*term.t_open) +#define TTclose (*term.t_close) +#define TTkopen (*term.t_kopen) +#define TTkclose (*term.t_kclose) +#define TTgetc (*term.t_getchar) +#define TTputc (*term.t_putchar) +#define TTflush (*term.t_flush) +#define TTmove (*term.t_move) +#define TTeeol (*term.t_eeol) +#define TTeeop (*term.t_eeop) +#define TTbeep (*term.t_beep) +#define TTrev (*term.t_rev) +#define TTrez (*term.t_rez) +#if COLOR +#define TTforg (*term.t_setfor) +#define TTbacg (*term.t_setback) #endif /* Terminal table defined only in term.c */ extern struct terminal term ; -extern int ttrow ; /* Row location of HW cursor */ -extern int ttcol ; /* Column location of HW cursor */ +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ -extern boolean eolexist ; /* does clear to EOL exist? */ -extern boolean revexist ; /* does reverse video exist? */ -extern boolean sgarbf ; /* State of screen unknown */ +extern boolean eolexist ; /* does clear to EOL exist? */ +extern boolean revexist ; /* does reverse video exist? */ +extern boolean sgarbf ; /* State of screen unknown */ -extern char sres[] ; /* Current screen resolution. */ - /* NORMAL, CGA, EGA, VGA */ +extern char sres[] ; /* Current screen resolution. */ + /* NORMAL, CGA, EGA, VGA */ #endif +/* end of terminal.h */ diff --git a/termio.h b/termio.h index 5f96f25..b2603c2 100644 --- a/termio.h +++ b/termio.h @@ -1,14 +1,15 @@ +/* termio.h -- */ #ifndef _TERMIO_H_ #define _TERMIO_H_ #include "utf8.h" -#define TYPEAH 1 /* type ahead causes update to be skipped */ +#define TYPEAH 1 /* type ahead causes update to be skipped */ -#define HUGE 1000 /* Huge number (for row/col) */ +#define HUGE 1000 /* Huge number (for row/col) */ -extern int ttrow ; /* Row location of HW cursor */ -extern int ttcol ; /* Column location of HW cursor */ +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ void ttopen( void) ; void ttclose( void) ; @@ -18,3 +19,4 @@ int ttgetc( void) ; int typahead( void) ; #endif +/* end of termio.h */ diff --git a/utf8.h b/utf8.h index b3b9505..93a95fc 100644 --- a/utf8.h +++ b/utf8.h @@ -1,5 +1,6 @@ -#ifndef UTF8_H -#define UTF8_H +/* utf8.h -- */ +#ifndef _UTF8_H_ +#define _UTF8_H_ typedef unsigned int unicode_t ; @@ -10,3 +11,4 @@ unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ; unsigned unicode_to_utf8( unicode_t c, char *utf8) ; #endif +/* end of utf8.h */ diff --git a/util.h b/util.h index d599559..e7190f1 100644 --- a/util.h +++ b/util.h @@ -1,9 +1,10 @@ /* util.h -- utility functions */ -#ifndef UTIL_H_ -# define UTIL_H_ +#ifndef _UTIL_H_ +#define _UTIL_H_ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + void mystrscpy( char *dst, const char *src, int size) ; -#endif /* UTIL_H_ */ +#endif /* end of util.h */ diff --git a/version.h b/version.h index b2ab58d..174bbd2 100644 --- a/version.h +++ b/version.h @@ -1,16 +1,18 @@ -#ifndef VERSION_H_ -#define VERSION_H_ +/* version.h -- name and version strings */ +#ifndef _VERSION_H_ +#define _VERSION_H_ #ifdef PROGRAM # define _QUOTE( s) #s # define QUOTE( s) _QUOTE( s) # define PROGRAM_NAME QUOTE(PROGRAM) #else -# define PROGRAM_NAME "em" +# define PROGRAM_NAME "ue" #endif #define PROGRAM_NAME_UTF8 "µEMACS" -#define VERSION "4.2.4" +#define VERSION "4.2.5" -#endif /* VERSION_H_ */ +#endif +/* end of version.h */ diff --git a/window.h b/window.h index e555ed3..a139562 100644 --- a/window.h +++ b/window.h @@ -2,9 +2,9 @@ #ifndef _WINDOW_H_ #define _WINDOW_H_ -#include "defines.h" /* COLOR, SCROLLCODE */ -#include "buffer.h" /* buffer_p, line_p */ -#include "names.h" /* BINDABLE() */ +#include "defines.h" /* COLOR, SCROLLCODE */ +#include "buffer.h" /* buffer_p, line_p */ +#include "names.h" /* BINDABLE() */ /* There is a window structure allocated for every active display window. The windows are kept in a big list, in top to bottom screen order, with @@ -15,40 +15,40 @@ every input character. */ typedef struct window { - struct window *w_wndp; /* Next window */ - buffer_p w_bufp ; /* Buffer displayed in window */ - line_p w_linep ; /* Top line in the window */ - line_p w_dotp ; /* Line containing "." */ - line_p w_markp ; /* Line containing "mark" */ - int w_doto ; /* Byte offset for "." */ - int w_marko ; /* Byte offset for "mark" */ - int w_toprow ; /* Origin 0 top row of window */ - int w_ntrows ; /* # of rows of text in window */ - char w_force ; /* If NZ, forcing row. */ - char w_flag ; /* Flags. */ -# if COLOR - char w_fcolor ; /* current forground color */ - char w_bcolor ; /* current background color */ -# endif + struct window *w_wndp; /* Next window */ + buffer_p w_bufp ; /* Buffer displayed in window */ + line_p w_linep ; /* Top line in the window */ + line_p w_dotp ; /* Line containing "." */ + line_p w_markp ; /* Line containing "mark" */ + int w_doto ; /* Byte offset for "." */ + int w_marko ; /* Byte offset for "mark" */ + int w_toprow ; /* Origin 0 top row of window */ + int w_ntrows ; /* # of rows of text in window */ + char w_force ; /* If NZ, forcing row. */ + char w_flag ; /* Flags. */ +#if COLOR + char w_fcolor ; /* current forground color */ + char w_bcolor ; /* current background color */ +#endif } *window_p ; -extern window_p curwp ; /* Current window */ -extern window_p wheadp ; /* Head of list of windows */ +extern window_p curwp ; /* Current window */ +extern window_p wheadp ; /* Head of list of windows */ /* curwbyte return the byte after the dot in current window */ #define curwbyte() lgetc( curwp->w_dotp, curwp->w_doto) -#define WFFORCE 0x01 /* Window needs forced reframe */ -#define WFMOVE 0x02 /* Movement from line to line */ -#define WFEDIT 0x04 /* Editing within a line */ -#define WFHARD 0x08 /* Better to a full display */ -#define WFMODE 0x10 /* Update mode line. */ -#define WFCOLR 0x20 /* Needs a color change */ +#define WFFORCE 0x01 /* Window needs forced reframe */ +#define WFMOVE 0x02 /* Movement from line to line */ +#define WFEDIT 0x04 /* Editing within a line */ +#define WFHARD 0x08 /* Better to a full display */ +#define WFMODE 0x10 /* Update mode line. */ +#define WFCOLR 0x20 /* Needs a color change */ -# if SCROLLCODE -# define WFKILLS 0x40 /* something was deleted */ -# define WFINS 0x80 /* something was inserted */ -# endif +#if SCROLLCODE +# define WFKILLS 0x40 /* something was deleted */ +# define WFINS 0x80 /* something was inserted */ +#endif /* Bindable functions */ BINDABLE( delwind) ; diff --git a/word.h b/word.h index abdb507..e4dde1f 100644 --- a/word.h +++ b/word.h @@ -21,5 +21,4 @@ BINDABLE( killpara) ; BINDABLE( wordcount) ; #endif - /* end of word.h */ diff --git a/wrapper.h b/wrapper.h index 5c609e5..0f556b2 100644 --- a/wrapper.h +++ b/wrapper.h @@ -1,10 +1,12 @@ +/* wrapper.h -- */ #ifndef WRAPPER_H_ #define WRAPPER_H_ -#include +#include /* size_t */ void xmkstemp( char *fname_template) ; void *xmalloc( size_t size) ; -#endif /* WRAPPER_H_ */ +#endif +/* end of wrapper.h */