1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-07-01 05:55:24 +00:00

Bindable functions take a boolean as flag.

Emphasize which one always return TRUE.
Use mloutfail() to introduce consistency when a function fails with error message.
This commit is contained in:
Renaud 2021-08-11 17:02:19 +08:00
parent 665d9ca1da
commit 50b727bf7f
31 changed files with 1593 additions and 1789 deletions

91
basic.c
View File

@ -22,7 +22,7 @@
#define CVMVAS 1 /* arguments to page forward/back in pages */ #define CVMVAS 1 /* arguments to page forward/back in pages */
int overlap = 0 ; /* $overlap: line overlap in forw/back page */ int overlap = 0 ; /* $overlap: line overlap in forw/back page */
int curgoal ; /* $target: Goal for C-P, C-N */ int curgoal ; /* $target: column goal for C-P, C-N */
/* This routine, given a pointer to a struct line, and the current cursor /* This routine, given a pointer to a struct line, and the current cursor
@ -60,14 +60,14 @@ static unsigned getgoal( line_p dlp) {
/* Move the cursor to the beginning of the current line of active window. */ /* Move the cursor to the beginning of the current line of active window. */
boolean gotobol( int f, int n) { TBINDABLE( gotobol) {
curwp->w_doto = 0 ; curwp->w_doto = 0 ;
return TRUE ; return TRUE ;
} }
/* Move the cursor to the end of the current line of active window. */ /* Move the cursor to the end of the current line of active window. */
boolean gotoeol( int f, int n) { TBINDABLE( gotoeol) {
curwp->w_doto = llength( curwp->w_dotp) ; curwp->w_doto = llength( curwp->w_dotp) ;
return TRUE ; return TRUE ;
} }
@ -77,7 +77,7 @@ boolean gotoeol( int f, int n) {
considered to be hard motion; it really isn't if the original value of considered to be hard motion; it really isn't if the original value of
dot is the same as the new value of dot. Normally bound to "M-<". dot is the same as the new value of dot. Normally bound to "M-<".
*/ */
boolean gotobob( int f, int n) { TBINDABLE( gotobob) {
curwp->w_dotp = lforw( curbp->b_linep) ; curwp->w_dotp = lforw( curbp->b_linep) ;
curwp->w_doto = 0 ; curwp->w_doto = 0 ;
curwp->w_flag |= WFHARD ; curwp->w_flag |= WFHARD ;
@ -89,7 +89,7 @@ boolean gotobob( int f, int n) {
(ZJ). The standard screen code does most of the hard parts of update. (ZJ). The standard screen code does most of the hard parts of update.
Bound to "M->". Bound to "M->".
*/ */
boolean gotoeob( int f, int n) { TBINDABLE( gotoeob) {
curwp->w_dotp = curbp->b_linep ; curwp->w_dotp = curbp->b_linep ;
curwp->w_doto = 0 ; curwp->w_doto = 0 ;
curwp->w_flag |= WFHARD ; curwp->w_flag |= WFHARD ;
@ -102,14 +102,8 @@ boolean gotoeob( int f, int n) {
command controls how the goal column is set. Bound to "C-N". No errors command controls how the goal column is set. Bound to "C-N". No errors
are possible. are possible.
*/ */
boolean forwline( int f, int n) { BBINDABLE( forwline) {
assert( f == TRUE || n == 1) ; assert( f == TRUE || n == 1) ;
if( n < 0)
return backline( f, -n) ;
/* if we are on the last line as we start....fail the command */
if( n && curwp->w_dotp == curbp->b_linep)
return FALSE ;
/* if the last command was not a line move, reset the goal column */ /* if the last command was not a line move, reset the goal column */
if( (lastflag & CFCPCN) == 0) if( (lastflag & CFCPCN) == 0)
@ -119,16 +113,26 @@ boolean forwline( int f, int n) {
thisflag |= CFCPCN ; thisflag |= CFCPCN ;
/* and move the point down */ /* and move the point down */
line_p dlp = curwp->w_dotp ; if( n) {
while( n && dlp != curbp->b_linep) { line_p dlp = curwp->w_dotp ;
dlp = lforw( dlp) ; if( n > 0)
n -= 1 ; while( n && dlp != curbp->b_linep) {
dlp = lforw( dlp) ;
n -= 1 ;
}
else {
while( n && lback( dlp) != curbp->b_linep) {
dlp = lback( dlp) ;
n += 1 ;
}
}
/* resetting the current position */
curwp->w_dotp = dlp ;
curwp->w_doto = getgoal( dlp) ;
curwp->w_flag |= WFMOVE ;
} }
/* reseting the current position */
curwp->w_dotp = dlp ;
curwp->w_doto = getgoal( dlp) ;
curwp->w_flag |= WFMOVE ;
return (n == 0) ? TRUE : FALSE ; return (n == 0) ? TRUE : FALSE ;
} }
@ -138,33 +142,10 @@ boolean forwline( int f, int n) {
your alternate. Figure out the new line and call "movedot" to perform your alternate. Figure out the new line and call "movedot" to perform
the motion. No errors are possible. Bound to "C-P". the motion. No errors are possible. Bound to "C-P".
*/ */
boolean backline( int f, int n) { BBINDABLE( backline) {
if( n < 0) assert( f == TRUE || n == 1) ;
return forwline( f, -n) ;
/* if we are on the first line as we start....fail the command */ return forwline( TRUE, -n) ;
if( n && lback( curwp->w_dotp) == curbp->b_linep)
return FALSE ;
/* if the last command was not a line move, reset the goal column */
if( (lastflag & CFCPCN) == 0)
curgoal = getccol( FALSE) ;
/* flag this command as a line move */
thisflag |= CFCPCN ;
/* and move the point up */
line_p dlp = curwp->w_dotp ;
while( n && lback( dlp) != curbp->b_linep) {
dlp = lback( dlp) ;
n -= 1 ;
}
/* reseting the current position */
curwp->w_dotp = dlp ;
curwp->w_doto = getgoal( dlp) ;
curwp->w_flag |= WFMOVE ;
return (n == 0) ? TRUE : FALSE ;
} }
@ -209,7 +190,7 @@ BINDABLE( gotoline) {
Because this zaps the top line in the display window, we have to do a Because this zaps the top line in the display window, we have to do a
hard update. hard update.
*/ */
boolean forwpage( int f, int n) { TBINDABLE( forwpage) {
line_p lp ; line_p lp ;
if( f == FALSE) { if( f == FALSE) {
@ -226,23 +207,21 @@ boolean forwpage( int f, int n) {
if (n <= 0) /* Forget the overlap. */ if (n <= 0) /* Forget the overlap. */
n = 1; /* If tiny window. */ n = 1; /* If tiny window. */
} else if( n < 0) } else if( n < 0)
return backpage(f, -n); return backpage( f, -n) ;
#if CVMVAS #if CVMVAS
else /* Convert from pages. */ else /* Convert from pages. */
n *= curwp->w_ntrows; /* To lines. */ n *= curwp->w_ntrows; /* To lines. */
#endif #endif
/* lp = curwp->w_linep; */
lp = curwp->w_dotp ; lp = curwp->w_dotp ;
while( n && lp != curbp->b_linep) { while( n && lp != curbp->b_linep) {
lp = lforw( lp) ; lp = lforw( lp) ;
n -= 1 ; n -= 1 ;
} }
/* curwp->w_linep = lp; */ curwp->w_dotp = lp ;
curwp->w_dotp = lp; curwp->w_doto = 0 ;
curwp->w_doto = 0; reposition( TRUE, 0) ; /* center at dot, always succeed */
reposition( TRUE, 0) ;
#if SCROLLCODE #if SCROLLCODE
curwp->w_flag |= WFHARD | WFKILLS; curwp->w_flag |= WFHARD | WFKILLS;
@ -258,7 +237,7 @@ boolean forwpage( int f, int n) {
ITS EMACS manual. Bound to "M-V". We do a hard update for exactly the ITS EMACS manual. Bound to "M-V". We do a hard update for exactly the
same reason. same reason.
*/ */
boolean backpage( int f, int n) { TBINDABLE( backpage) {
line_p lp ; line_p lp ;
if( f == FALSE) { /* interactive, default n = 1 supplied */ if( f == FALSE) { /* interactive, default n = 1 supplied */
@ -313,7 +292,7 @@ boolean backpage( int f, int n) {
/* Set the mark in the current window to the value of "." in the window. /* Set the mark in the current window to the value of "." in the window.
No errors are possible. Bound to M-. set-mark. No errors are possible. Bound to M-. set-mark.
*/ */
boolean setmark( int f, int n) { TBINDABLE( setmark) {
curwp->w_markp = curwp->w_dotp ; curwp->w_markp = curwp->w_dotp ;
curwp->w_marko = curwp->w_doto ; curwp->w_marko = curwp->w_doto ;
mloutstr( "(Mark set)") ; mloutstr( "(Mark set)") ;
@ -324,7 +303,7 @@ boolean setmark( int f, int n) {
/* Swap the values of "." and "mark" in the current window. If no mark as /* Swap the values of "." and "mark" in the current window. If no mark as
been previously set, set it. Bound to C-X C-X exchange-point-and-mark. been previously set, set it. Bound to C-X C-X exchange-point-and-mark.
*/ */
boolean swapmark( int f, int n) { TBINDABLE( swapmark) {
line_p odotp = curwp->w_dotp ; line_p odotp = curwp->w_dotp ;
int odoto = curwp->w_doto ; int odoto = curwp->w_doto ;
if( curwp->w_markp) { if( curwp->w_markp) {

28
basic.h
View File

@ -1,9 +1,8 @@
/* basic.h -- basic commands for cursor movement in active window */ /* basic.h -- basic commands for cursor movement in active window */
#ifndef _BASIC_H_ #ifndef _BASIC_H_
#define _BASIC_H_ # define _BASIC_H_
#include "names.h" # include "names.h"
/* $overlap is the size of the line overlap when kbd calls page forw/back /* $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) if 0, page will move by 2/3 of the window size (1/3 page overlap)
@ -17,18 +16,17 @@ extern int curgoal ; /* $target: Goal for C-P previous-line, C-N next-line */
/* Bindable functions */ /* Bindable functions */
boolean gotobol( int f, int n) ; BBINDABLE( backline) ;
boolean gotoeol( int f, int n) ; TBINDABLE( backpage) ;
BINDABLE( gotoline) ; BBINDABLE( forwline) ;
boolean gotobob( int f, int n) ; TBINDABLE( forwpage) ;
boolean gotoeob( int f, int n) ; TBINDABLE( gotobob) ;
boolean forwline( int f, int n) ; TBINDABLE( gotobol) ;
boolean backline( int f, int n) ; TBINDABLE( gotoeob) ;
boolean forwpage( int f, int n) ; TBINDABLE( gotoeol) ;
boolean backpage( int f, int n) ; BINDABLE( gotoline) ;
boolean setmark( int f, int n) ; TBINDABLE( setmark) ;
boolean swapmark( int f, int n) ; TBINDABLE( swapmark) ;
#endif #endif
/* end of basic.h */ /* end of basic.h */

28
bind.c
View File

@ -119,8 +119,8 @@ BINDABLE( bindtokey) {
mloutfmt( "bind-to-key %s: ", bind_name( nbp)) ; mloutfmt( "bind-to-key %s: ", bind_name( nbp)) ;
/* get the command sequence to bind */ /* get the command sequence to bind */
boolean prefix_f = (kfunc == metafn) || (kfunc == cex) || boolean prefix_f = (kfunc == (fnp_t) metafn) || (kfunc == (fnp_t) cex) ||
(kfunc == unarg) || (kfunc == ctrlg) ; (kfunc == (fnp_t) unarg) || (kfunc == (fnp_t) ctrlg) ;
int c = getckey( prefix_f) ; int c = getckey( prefix_f) ;
if( c == ~0) if( c == ~0)
return invalidkey() ; return invalidkey() ;
@ -131,10 +131,10 @@ BINDABLE( bindtokey) {
/* key sequence can't be an active prefix key */ /* key sequence can't be an active prefix key */
if( c == metac || c == ctlxc || c == reptc || c == abortc) { if( c == metac || c == ctlxc || c == reptc || c == abortc) {
if( (c == metac && kfunc == metafn) if( (c == metac && kfunc == (fnp_t) metafn)
|| (c == ctlxc && kfunc == cex) || (c == ctlxc && kfunc == (fnp_t) cex)
|| (c == reptc && kfunc == unarg) || (c == reptc && kfunc == (fnp_t) unarg)
|| (c == abortc && kfunc == ctrlg)) || (c == abortc && kfunc == (fnp_t) ctrlg))
return TRUE ; /* be silent if keep current */ return TRUE ; /* be silent if keep current */
return mloutfail( "(Can't bind to active prefix)") ; return mloutfail( "(Can't bind to active prefix)") ;
@ -150,13 +150,13 @@ BINDABLE( bindtokey) {
} }
/* set the appropriate global prefix variable */ /* set the appropriate global prefix variable */
if( kfunc == metafn) if( kfunc == (fnp_t) metafn)
metac = c ; metac = c ;
else if( kfunc == cex) else if( kfunc == (fnp_t) cex)
ctlxc = c ; ctlxc = c ;
if( kfunc == unarg) if( kfunc == (fnp_t) unarg)
reptc = c ; reptc = c ;
if( kfunc == ctrlg) if( kfunc == (fnp_t) ctrlg)
abortc = c ; abortc = c ;
} }
@ -404,14 +404,14 @@ static char *cmdstr( unsigned c, char *seq) {
/* apply ^X sequence if needed */ /* apply ^X sequence if needed */
if( c & CTLX) { if( c & CTLX) {
if( ctlxc & CTRL) if( ctlxc & CTL_)
*ptr++ = '^' ; *ptr++ = '^' ;
*ptr++ = ctlxc & ~PRFXMASK ; *ptr++ = ctlxc & ~PRFXMASK ;
} }
/* apply control sequence if needed */ /* apply control sequence if needed */
if( c & CTRL) if( c & CTL_)
*ptr++ = '^' ; *ptr++ = '^' ;
/* apply SPEC sequence if needed */ /* apply SPEC sequence if needed */
@ -461,7 +461,7 @@ static unsigned int stock( char *keyname) {
/* a control char? */ /* a control char? */
if( *keyname == '^' && keyname[ 1] != 0) { if( *keyname == '^' && keyname[ 1] != 0) {
c |= CTRL ; c |= CTL_ ;
++keyname ; ++keyname ;
} }
@ -477,7 +477,7 @@ static unsigned int stock( char *keyname) {
/* only way to redefine ^X is by quoting binary value */ /* only way to redefine ^X is by quoting binary value */
if( *keyname < 32 || *keyname == 0x7F) { if( *keyname < 32 || *keyname == 0x7F) {
c |= CTRL ; c |= CTL_ ;
*keyname ^= 0x40 ; *keyname ^= 0x40 ;
} else if( c && !(c & SPEC) } else if( c && !(c & SPEC)
&& *keyname >= 'a' && *keyname <= 'z') && *keyname >= 'a' && *keyname <= 'z')

View File

@ -70,7 +70,7 @@ BINDABLE( quit) {
* Error if not at the top level in keyboard processing. Set up variables and * Error if not at the top level in keyboard processing. Set up variables and
* return. * return.
*/ */
BINDABLE( ctlxlp) { BBINDABLE( ctlxlp) {
if( kbdmode != STOP) if( kbdmode != STOP)
return mloutfail( "%Macro already active") ; return mloutfail( "%Macro already active") ;
@ -85,7 +85,7 @@ BINDABLE( ctlxlp) {
/* End keyboard macro. Check for the same limit conditions as the above /* End keyboard macro. Check for the same limit conditions as the above
* routine. Set up the variables and return to the caller. * routine. Set up the variables and return to the caller.
*/ */
BINDABLE( ctlxrp) { BBINDABLE( ctlxrp) {
if( kbdmode == STOP) if( kbdmode == STOP)
return mloutfail( "%Macro not active") ; return mloutfail( "%Macro not active") ;
@ -102,7 +102,7 @@ BINDABLE( ctlxrp) {
* The command argument is the number of times to loop. Quit as soon as a * The command argument is the number of times to loop. Quit as soon as a
* command gets an error. Return TRUE if all ok, else FALSE. * command gets an error. Return TRUE if all ok, else FALSE.
*/ */
BINDABLE( ctlxe) { BBINDABLE( ctlxe) {
if( kbdmode != STOP) if( kbdmode != STOP)
return mloutfail( "%Macro already active") ; return mloutfail( "%Macro already active") ;

View File

@ -1,18 +1,16 @@
/* bindable.h -- misc bindable functions */ /* bindable.h -- misc bindable functions */
#ifndef _BINDABLE_H_ #ifndef _BINDABLE_H_
#define _BINDABLE_H_ #define _BINDABLE_H_
#include "names.h" #include "names.h"
/* functions that can be bound to keys or procedure names */ /* functions that can be bound to keys or procedure names */
BINDABLE( quickexit) ; BBINDABLE( ctlxe) ;
BINDABLE( quit) ; BBINDABLE( ctlxlp) ;
BINDABLE( ctlxlp) ; BBINDABLE( ctlxrp) ;
BINDABLE( ctlxrp) ; BINDABLE( ctrlg) ; /* ABORT */
BINDABLE( ctlxe) ; BINDABLE( quickexit) ;
BINDABLE( ctrlg) ; BINDABLE( quit) ;
#endif #endif
/* end of bindable.h */ /* end of bindable.h */

873
buffer.c

File diff suppressed because it is too large Load Diff

120
buffer.h
View File

@ -1,74 +1,82 @@
/* buffer.h -- buffer type and functions */
#ifndef _BUFFER_H_ #ifndef _BUFFER_H_
#define _BUFFER_H_ # define _BUFFER_H_
#include "line.h" #include "line.h"
#include "names.h"
typedef char fname_t[ 256] ; /* file name type */ /* Text is kept in buffers. A buffer header, described below, exists for
typedef char bname_t[ 16] ; /* buffer name type */ every buffer in the system. The buffers are kept in a big list, so that
commands that search for a buffer by name can find the buffer header.
There is a safe store for the dot and mark in the header, but this is
only valid if the buffer is not being displayed (that is, if "b_nwnd" is
0). The text for the buffer is kept in a circularly linked list of
lines, with a pointer to the header line in "b_linep".
/* Buffers may be "Inactive" which means the files associated with them
* Text is kept in buffers. A buffer header, described below, exists for every have not been read in yet. These get read in at "use buffer" time.
* buffer in the system. The buffers are kept in a big list, so that commands
* that search for a buffer by name can find the buffer header. There is a
* safe store for the dot and mark in the header, but this is only valid if
* the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
* the buffer is kept in a circularly linked list of lines, with a pointer to
* the header line in "b_linep".
* Buffers may be "Inactive" which means the files associated with them
* have not been read in yet. These get read in at "use buffer" time.
*/ */
typedef char fname_t[ 256] ; /* file name type */
typedef char bname_t[ 16] ; /* buffer name type */
typedef struct buffer { typedef struct buffer {
struct buffer *b_bufp; /* Link to next struct buffer */ struct buffer *b_bufp ; /* Link to next struct buffer */
line_p b_dotp ; /* Link to "." struct line structure */ line_p b_dotp ; /* Link to "." struct line structure */
line_p b_markp ; /* The same as the above two, */ line_p b_markp ; /* The same as the above two, */
line_p b_linep ; /* Link to the header struct line */ line_p b_linep ; /* Link to the header struct line */
int b_doto; /* Offset of "." in above struct line */ int b_doto ; /* Offset of "." in above struct line */
int b_marko; /* but for the "mark" */ int b_marko ; /* but for the "mark" */
int b_mode; /* editor mode of this buffer */ int b_mode ; /* editor mode of this buffer */
char b_active; /* window activated flag */ char b_active ; /* window activated flag */
char b_nwnd; /* Count of windows on buffer */ char b_nwnd ; /* Count of windows on buffer */
char b_flag; /* Flags */ char b_flag ; /* Flags */
fname_t b_fname ; /* File name */ fname_t b_fname ; /* File name */
bname_t b_bname ; /* Buffer name */ bname_t b_bname ; /* Buffer name */
} *buffer_p ; } *buffer_p ;
extern buffer_p curbp ; /* Current buffer */ extern buffer_p curbp ; /* Current buffer */
extern buffer_p bheadp ; /* Head of list of buffers */ extern buffer_p bheadp ; /* Head of list of buffers */
extern buffer_p blistp ; /* Buffer for C-X C-B */ extern buffer_p blistp ; /* Buffer for C-X C-B */
#define BFINVS 0x01 /* Internal invisable buffer */ #define BFINVS 0x01 /* Internal invisable buffer */
#define BFCHG 0x02 /* Changed since last write */ #define BFCHG 0x02 /* Changed since last write */
#define BFTRUNC 0x04 /* buffer was truncated when read */ #define BFTRUNC 0x04 /* buffer was truncated when read */
/* mode flags */ /* mode flags */
#define NUMMODES 9 /* # of defined modes */ #define NUMMODES 9 /* # of defined modes */
#define MDWRAP 0x0001 /* word wrap */ #define MDWRAP 0x0001 /* word wrap */
#define MDCMOD 0x0002 /* C indentation and fence match */ #define MDCMOD 0x0002 /* C indentation and fence match */
#define MDEXACT 0x0004 /* Exact matching for searches */ #define MDEXACT 0x0004 /* Exact matching for searches */
#define MDVIEW 0x0008 /* read-only buffer */ #define MDVIEW 0x0008 /* read-only buffer */
#define MDOVER 0x0010 /* overwrite mode */ #define MDOVER 0x0010 /* overwrite mode */
#define MDMAGIC 0x0020 /* regular expresions in search */ #define MDMAGIC 0x0020 /* regular expresions in search */
#define MDASAVE 0x0040 /* auto-save mode */ #define MDASAVE 0x0040 /* auto-save mode */
#define MDUTF8 0x0080 /* utf8 mode */ #define MDUTF8 0x0080 /* utf8 mode */
#define MDDOS 0x0100 /* CRLF eol mode */ #define MDDOS 0x0100 /* CRLF eol mode */
extern const char *modename[ NUMMODES] ; /* text names of modes */
extern int gmode ; /* global editor mode */
extern const char *modename[] ; /* text names of modes */ /* Bindable functions */
extern int gmode ; /* global editor mode */ BINDABLE( killbuffer) ;
BINDABLE( listbuffers) ;
BINDABLE( namebuffer) ;
BINDABLE( nextbuffer) ;
BINDABLE( unmark) ;
BINDABLE( usebuffer) ;
boolean anycb( void) ; /* Any changed buffer? */
int bclear( buffer_p bp) ; /* empty buffer */
int swbuffer( buffer_p bp) ; /* switch to buffer, make it current */
int zotbuf( buffer_p bp) ; /* remove buffer */
int usebuffer( int f, int n) ; /* Lookup a buffer by name. If not found and create_f is TRUE then create
int nextbuffer( int f, int n) ; it with flags set.
int swbuffer( buffer_p bp) ; */
int killbuffer( int f, int n) ; buffer_p bfind( const char *bname, boolean create_f, int flags) ;
int zotbuf( buffer_p bp) ;
int namebuffer( int f, int n) ;
int listbuffers( int f, int n) ;
int anycb( void) ;
int bclear( buffer_p bp) ;
int unmark( int f, int n) ;
/* Lookup a buffer by name. */
buffer_p bfind( const char *bname, int cflag, int bflag) ;
#endif #endif
/* end of buffer.h */

View File

@ -1,17 +1,14 @@
/* display.c -- implements display.h */ /* display.c -- implements display.h */
#include "display.h" #include "display.h"
#define REVSTA 1 /* Status line appears in reverse video */ #define REVSTA 1 /* Status line appears in reverse video */
/* display.c /* The functions in this file handle redisplay. There are two halves, the
* ones that update the virtual display screen, and the ones that make the
* The functions in this file handle redisplay. There are two halves, the physical display screen the same as the virtual display screen. These
* ones that update the virtual display screen, and the ones that make the functions use hints that are left in the windows by the commands.
* physical display screen the same as the virtual display screen. These
* functions use hints that are left in the windows by the commands. Modified by Petri Kutvonen
*
* Modified by Petri Kutvonen
*/ */
#include <errno.h> #include <errno.h>
@ -251,40 +248,37 @@ static void vteeol( void) {
vcp[ vtcol++] = ' ' ; vcp[ vtcol++] = ' ' ;
} }
/* /* upscreen:
* upscreen:
* user routine to force a screen update * user routine to force a screen update
* always finishes complete update * always finishes complete update
*/ */
int upscreen(int f, int n) BINDABLE( upscreen) {
{ update( TRUE) ;
update(TRUE); return TRUE ;
return TRUE;
} }
#if SCROLLCODE #if SCROLLCODE
static int scrflags; static int scrflags;
#endif #endif
/*
* Make sure that the display is right. This is a three part process. First, /* Make sure that the display is right. This is a three part process.
* scan through all of the windows looking for dirty ones. Check the framing, First, scan through all of the windows looking for dirty ones. Check
* and refresh the screen. Second, make sure that "currow" and "curcol" are the framing, and refresh the screen. Second, make sure that "currow"
* correct for the current window. Third, make the virtual and physical and "curcol" are correct for the current window. Third, make the
* screens the same. virtual and physical screens the same.
*
* int force; force update past type ahead? boolean force_f ; force update past type ahead?
*/ */
int update(int force) int update( boolean force_f) {
{
struct window *wp; struct window *wp;
#if TYPEAH && ! PKCODE #if TYPEAH && ! PKCODE
if (force == FALSE && typahead()) if( force_f == FALSE && typahead())
return TRUE; return TRUE;
#endif #endif
#if VISMAC == 0 #if VISMAC == 0
if (force == FALSE && kbdmode == PLAY) if( force_f == FALSE && kbdmode == PLAY)
return TRUE; return TRUE;
#endif #endif
@ -359,7 +353,7 @@ int update(int force)
updgar(); updgar();
/* update the virtual screen to the physical screen */ /* update the virtual screen to the physical screen */
updupd(force); updupd( force_f) ;
/* update the cursor and flush the buffers */ /* update the cursor and flush the buffers */
movecursor(currow, curcol - lbound); movecursor(currow, curcol - lbound);

View File

@ -1,10 +1,12 @@
/* display.h -- display functionality */
#ifndef _DISPLAY_H_ #ifndef _DISPLAY_H_
#define _DISPLAY_H_ # define _DISPLAY_H_
#include <stdarg.h> # include <stdarg.h>
#include "estruct.h" # include "estruct.h"
#include "utf8.h" # include "names.h" /* BINDABLE() */
# include "utf8.h" /* unicode_t */
extern int mpresf ; /* Stuff in message line */ extern int mpresf ; /* Stuff in message line */
extern int scrollcount ; /* number of lines to scroll */ extern int scrollcount ; /* number of lines to scroll */
@ -13,11 +15,13 @@ extern int disinp ; /* display input characters (echo) */
extern int gfcolor ; /* global forgrnd color (white) */ extern int gfcolor ; /* global forgrnd color (white) */
extern int gbcolor ; /* global backgrnd color (black) */ extern int gbcolor ; /* global backgrnd color (black) */
/* Bindable functions */
BINDABLE( upscreen) ;
void vtinit( void) ; void vtinit( void) ;
void vtfree( void) ; void vtfree( void) ;
void vttidy( void) ; void vttidy( void) ;
int upscreen( int f, int n) ; int update( boolean force_f) ;
int update( int force) ;
void updpos( void) ; void updpos( void) ;
void upddex( void) ; void upddex( void) ;
void updgar( void) ; void updgar( void) ;
@ -33,13 +37,13 @@ void echos( const char *s) ;
void rubout( void) ; void rubout( void) ;
void getscreensize( int *widthp, int *heightp) ; void getscreensize( int *widthp, int *heightp) ;
#if UNIX # if UNIX
#include <signal.h> # include <signal.h>
#ifdef SIGWINCH # ifdef SIGWINCH
extern int chg_width, chg_height ; extern int chg_width, chg_height ;
void sizesignal( int signr) ; void sizesignal( int signr) ;
# endif
# endif
#endif #endif
#endif /* end of display.h */
#endif

38
eval.c
View File

@ -1,9 +1,7 @@
/* eval.c -- implements eval.h */ /* eval.c -- implements eval.h */
#include "eval.h" #include "eval.h"
/* eval.c /* Expression evaluation functions
*
* Expression evaluation functions
* *
* written 1986 by Daniel Lawrence * written 1986 by Daniel Lawrence
* modified by Petri Kutvonen * modified by Petri Kutvonen
@ -210,7 +208,7 @@ static struct {
{ "and", UFAND | DYNAMIC }, /* logical and */ { "and", UFAND | DYNAMIC }, /* logical and */
{ "asc", UFASCII | MONAMIC }, /* char to integer conversion */ { "asc", UFASCII | MONAMIC }, /* char to integer conversion */
{ "ban", UFBAND | DYNAMIC }, /* bitwise and 9-10-87 jwm */ { "ban", UFBAND | DYNAMIC }, /* bitwise and 9-10-87 jwm */
{ "bin", UFBIND | MONAMIC }, /* loopup what function name is bound to a key */ { "bin", UFBIND | MONAMIC }, /* look up function name bound to key */
{ "bno", UFBNOT | MONAMIC }, /* bitwise not */ { "bno", UFBNOT | MONAMIC }, /* bitwise not */
{ "bor", UFBOR | DYNAMIC }, /* bitwise or 9-10-87 jwm */ { "bor", UFBOR | DYNAMIC }, /* bitwise or 9-10-87 jwm */
{ "bxo", UFBXOR | DYNAMIC }, /* bitwise xor 9-10-87 jwm */ { "bxo", UFBXOR | DYNAMIC }, /* bitwise xor 9-10-87 jwm */
@ -797,14 +795,13 @@ static char *gtenv( char *vname) {
return errorm ; return errorm ;
} }
/*
* set a variable /* set a variable
* *
* int f; default flag * int f; default flag
* int n; numeric arg (can overide prompted value) * int n; numeric arg (can overide prompted value)
*/ */
int setvar(int f, int n) BINDABLE( setvar) {
{
int status; /* status return */ int status; /* status return */
struct variable_description vd; /* variable num/type */ struct variable_description vd; /* variable num/type */
char var[NVSIZE + 2]; /* name of variable to fetch %1234567890\0 */ char var[NVSIZE + 2]; /* name of variable to fetch %1234567890\0 */
@ -1466,28 +1463,25 @@ static void mlforce( char *s) {
discmd = oldcmd; /* and restore the original setting */ discmd = oldcmd; /* and restore the original setting */
} }
/*
* This function simply clears the message line, /* This function simply clears the message line, mainly for macro usage
* mainly for macro usage
* *
* int f, n; arguments ignored * int f, n; arguments ignored
*/ */
int clrmes( int f, int n) { TBINDABLE( clrmes) {
mlforce( "") ; mlforce( "") ;
return TRUE ; return TRUE ;
} }
/*
* This function writes a string on the message line
* mainly for macro usage
*
* int f, n; arguments ignored
*/
int writemsg( int f, int n) {
int status ;
char *buf ; /* buffer to receive message into */
status = newmlarg( &buf, "Message to write: ", 0) ; /* This function writes a string on the message line mainly for macro usage
*
* int f, n; arguments ignored
*/
BINDABLE( writemsg) {
char *buf ; /* buffer to receive message into */
int status = newmlarg( &buf, "write-message: ", 0) ;
if( status == TRUE) { if( status == TRUE) {
/* write the message out */ /* write the message out */
mlforce( buf) ; mlforce( buf) ;

28
eval.h
View File

@ -1,29 +1,33 @@
/* eval.h -- variables and operands evaluation */
#ifndef _EVAL_H_ #ifndef _EVAL_H_
#define _EVAL_H_ # define _EVAL_H_
#include "names.h"
#define DEBUGM 1 /* $debug triggers macro debugging */ #define DEBUGM 1 /* $debug triggers macro debugging */
#if DEBUGM # if DEBUGM
int mdbugout( char *fmt, ...) ; int mdbugout( char *fmt, ...) ;
#endif # endif
extern int macbug ; /* macro debuging flag */
extern int macbug ; /* macro debuging flag */ extern int cmdstatus ; /* last command status */
extern int cmdstatus ; /* last command status */ extern int rval ; /* return value of a subprocess */
extern int rval ; /* return value of a subprocess */ extern long envram ; /* # of bytes current in use by malloc */
extern long envram ; /* # of bytes current in use by malloc */
int readfirst_f( void) ; int readfirst_f( void) ;
int is_it_cmd( char *token) ; int is_it_cmd( char *token) ;
void varinit( void) ; void varinit( void) ;
int setvar( int f, int n) ;
const char *getval( char *token) ; const char *getval( char *token) ;
int stol( char *val) ; int stol( char *val) ;
char *mklower( char *str) ; char *mklower( char *str) ;
int clrmes( int f, int n) ; /* Bindable functions */
int writemsg( int f, int n) ; TBINDABLE( clrmes) ;
BINDABLE( setvar) ;
BINDABLE( writemsg) ;
#endif #endif
/* end of eval.h */

815
exec.c

File diff suppressed because it is too large Load Diff

114
exec.h
View File

@ -1,69 +1,65 @@
/* exec.h -- bindable functions to execute functions, macros and procedures */
#ifndef _EXEC_H_ #ifndef _EXEC_H_
#define _EXEC_H_ # define _EXEC_H_
#include "retcode.h" #include "names.h"
extern boolean clexec ; /* command line execution flag */
#define PROC 1 /* named procedures */ int dofile( const char *fname) ;
#if PROC
int storeproc( int f, int n) ;
int execproc( int f, int n) ;
#endif
extern boolean clexec ; /* command line execution flag */
int namedcmd( int f, int n) ;
int execcmd( int f, int n) ;
void gettoken( char *tok, int maxtoksize) ; void gettoken( char *tok, int maxtoksize) ;
boolean gettokval( char *tok, int maxtoksize) ; boolean gettokval( char *tok, int maxtoksize) ;
char *getnewtokval( void) ; char *getnewtokval( void) ;
int storemac( int f, int n) ;
int execbuf( int f, int n) ;
int execfile( int f, int n) ;
int dofile( const char *fname) ;
int cbuf1( int f, int n) ; /* Bindable functions */
int cbuf2( int f, int n) ; BINDABLE( execbuf) ;
int cbuf3( int f, int n) ; BINDABLE( execcmd) ;
int cbuf4( int f, int n) ; BINDABLE( execfile) ;
int cbuf5( int f, int n) ; BINDABLE( execproc) ;
int cbuf6( int f, int n) ; BINDABLE( namedcmd) ;
int cbuf7( int f, int n) ; BINDABLE( storemac) ;
int cbuf8( int f, int n) ; BINDABLE( storeproc) ;
int cbuf9( int f, int n) ; BINDABLE( cbuf1) ;
int cbuf10( int f, int n) ; BINDABLE( cbuf2) ;
int cbuf11( int f, int n) ; BINDABLE( cbuf3) ;
int cbuf12( int f, int n) ; BINDABLE( cbuf4) ;
int cbuf13( int f, int n) ; BINDABLE( cbuf5) ;
int cbuf14( int f, int n) ; BINDABLE( cbuf6) ;
int cbuf15( int f, int n) ; BINDABLE( cbuf7) ;
int cbuf16( int f, int n) ; BINDABLE( cbuf8) ;
int cbuf17( int f, int n) ; BINDABLE( cbuf9) ;
int cbuf18( int f, int n) ; BINDABLE( cbuf10) ;
int cbuf19( int f, int n) ; BINDABLE( cbuf11) ;
int cbuf20( int f, int n) ; BINDABLE( cbuf12) ;
int cbuf21( int f, int n) ; BINDABLE( cbuf13) ;
int cbuf22( int f, int n) ; BINDABLE( cbuf14) ;
int cbuf23( int f, int n) ; BINDABLE( cbuf15) ;
int cbuf24( int f, int n) ; BINDABLE( cbuf16) ;
int cbuf25( int f, int n) ; BINDABLE( cbuf17) ;
int cbuf26( int f, int n) ; BINDABLE( cbuf18) ;
int cbuf27( int f, int n) ; BINDABLE( cbuf19) ;
int cbuf28( int f, int n) ; BINDABLE( cbuf20) ;
int cbuf29( int f, int n) ; BINDABLE( cbuf21) ;
int cbuf30( int f, int n) ; BINDABLE( cbuf22) ;
int cbuf31( int f, int n) ; BINDABLE( cbuf23) ;
int cbuf32( int f, int n) ; BINDABLE( cbuf24) ;
int cbuf33( int f, int n) ; BINDABLE( cbuf25) ;
int cbuf34( int f, int n) ; BINDABLE( cbuf26) ;
int cbuf35( int f, int n) ; BINDABLE( cbuf27) ;
int cbuf36( int f, int n) ; BINDABLE( cbuf28) ;
int cbuf37( int f, int n) ; BINDABLE( cbuf29) ;
int cbuf38( int f, int n) ; BINDABLE( cbuf30) ;
int cbuf39( int f, int n) ; BINDABLE( cbuf31) ;
int cbuf40( int f, int n) ; BINDABLE( cbuf32) ;
BINDABLE( cbuf33) ;
BINDABLE( cbuf34) ;
BINDABLE( cbuf35) ;
BINDABLE( cbuf36) ;
BINDABLE( cbuf37) ;
BINDABLE( cbuf38) ;
BINDABLE( cbuf39) ;
BINDABLE( cbuf40) ;
#endif #endif
/* end of exec.h */

35
file.c
View File

@ -1,13 +1,11 @@
/* file.c -- implements file.h */ /* file.c -- implements file.h */
#include "file.h" #include "file.h"
/* file.c /* The routines in this file handle the reading, writing and lookup of disk
* files. All of details about the reading and writing of the disk are in
* The routines in this file handle the reading, writing "fileio.c".
* and lookup of disk files. All of details about the
* reading and writing of the disk are in "fileio.c". modified by Petri Kutvonen
*
* modified by Petri Kutvonen
*/ */
#include <assert.h> #include <assert.h>
@ -233,8 +231,8 @@ int getfile( const char *fname, boolean lockfl) {
return s; return s;
} }
/*
* Read file "fname" into the current buffer, blowing away any text /* Read file "fname" into the current buffer, blowing away any text
* found there. Called by both the read and find commands. Return * found there. Called by both the read and find commands. Return
* the final status of the read. Also called by the mainline, to * the final status of the read. Also called by the mainline, to
* read in a file specified on the command line as an argument. * read in a file specified on the command line as an argument.
@ -284,10 +282,10 @@ int readin(const char *fname, boolean lockfl)
/* read the file in */ /* read the file in */
mloutstr( "(Reading file)") ; mloutstr( "(Reading file)") ;
while ((s = ffgetline()) == FIOSUC) { while( (s = ffgetline()) == FIOSUC) {
line_p lp ; line_p lp ;
if( nline >= 10000000 /* MAXNLINE Maximum # of lines from one file */ if( nline >= 10000000 /* Maximum # of lines from one file */
|| (lp = lalloc( fpayload)) == NULL) { || (lp = lalloc( fpayload)) == NULL) {
s = FIOMEM ; /* Keep message on the */ s = FIOMEM ; /* Keep message on the */
break ; /* display. */ break ; /* display. */
@ -327,12 +325,11 @@ int readin(const char *fname, boolean lockfl)
if( fcode == FCODE_UTF_8) if( fcode == FCODE_UTF_8)
curbp->b_mode |= MDUTF8 ; curbp->b_mode |= MDUTF8 ;
if( s == FIOERR) { if( s == FIOERR
errmsg = "I/O ERROR, " ; || s == FIOMEM) {
curbp->b_flag |= BFTRUNC ; errmsg = (s == FIOERR) ? "I/O ERROR, " : "OUT OF MEMORY, " ;
} else if( s == FIOMEM) {
errmsg = "OUT OF MEMORY, " ;
curbp->b_flag |= BFTRUNC ; curbp->b_flag |= BFTRUNC ;
curbp->b_mode |= MDVIEW ; /* force view mode as lost data */
} else } else
errmsg = "" ; errmsg = "" ;
@ -464,10 +461,8 @@ BINDABLE( filesave) {
/* complain about truncated files */ /* complain about truncated files */
if( (curbp->b_flag & BFTRUNC) != 0 if( (curbp->b_flag & BFTRUNC) != 0
&& mlyesno("Truncated file ... write it out") == FALSE) { && mlyesno( "Truncated file ... write it out") == FALSE)
mloutfmt( "%B(Aborted)") ; return mloutfail( "(Aborted)") ;
return FALSE ;
}
return writeout( curbp->b_fname) ; return writeout( curbp->b_fname) ;
} }

52
input.c
View File

@ -15,9 +15,10 @@
#include "bind.h" #include "bind.h"
#include "estruct.h" #include "estruct.h"
#include "bindable.h" #include "bindable.h"
#include "display.h" #include "display.h" /* rubout(), echos(), echoc(), update() */
#include "exec.h" #include "exec.h"
#include "isa.h" #include "isa.h"
#include "mlout.h"
#include "names.h" #include "names.h"
#include "terminal.h" #include "terminal.h"
#include "utf8.h" #include "utf8.h"
@ -38,12 +39,12 @@ kbdstate kbdmode = STOP ; /* current keyboard macro mode */
int lastkey = 0 ; /* last keystoke */ int lastkey = 0 ; /* last keystoke */
int kbdrep = 0 ; /* number of repetitions */ int kbdrep = 0 ; /* number of repetitions */
int metac = CTRL | '[' ; /* current meta character */ int metac = CTL_ | '[' ; /* current meta character */
int ctlxc = CTRL | 'X' ; /* current control X prefix char */ int ctlxc = CTL_ | 'X' ; /* current control X prefix char */
int reptc = CTRL | 'U' ; /* current universal repeat char */ int reptc = CTL_ | 'U' ; /* current universal repeat char */
int abortc = CTRL | 'G' ; /* current abort command char */ int abortc = CTL_ | 'G' ; /* current abort command char */
const int nlc = CTRL | 'J' ; /* end of input char */ const int nlc = CTL_ | 'J' ; /* end of input char */
void ue_system( const char *cmd) { void ue_system( const char *cmd) {
@ -66,7 +67,7 @@ int mlyesno( const char *prompt)
for (;;) { for (;;) {
/* prompt the user */ /* prompt the user */
mlwrite( "%s (y/n)? ", prompt) ; mloutfmt( "%s (y/n)? ", prompt) ;
/* get the response */ /* get the response */
c = get1key() ; c = get1key() ;
@ -142,11 +143,11 @@ int newmlargt( char **outbufref, const char *prompt, int size) {
/* /*
* ectoc: * ectoc:
* expanded character to character * expanded character to character
* collapse the CTRL and SPEC flags back into an ascii code * collapse the CTL_ and SPEC flags back into an ascii code
*/ */
int ectoc( int c) { int ectoc( int c) {
if( c & CTRL) if( c & CTL_)
c ^= CTRL | 0x40 ; c ^= CTL_ | 0x40 ;
if( c & SPEC) if( c & SPEC)
c &= 255 ; c &= 255 ;
@ -189,10 +190,10 @@ nbind_p getname( void) {
/* and match it off */ /* and match it off */
return fncmatch( buf) ; return fncmatch( buf) ;
} else if (c == ectoc(abortc)) { /* Bell, abort */ } else if( c == ectoc(abortc)) { /* Bell, abort */
ctrlg(FALSE, 0); ctrlg( FALSE, 1) ;
TTflush(); TTflush() ;
return NULL; return NULL ;
} else if (c == 0x7F || c == 0x08) { /* rubout/erase */ } else if (c == 0x7F || c == 0x08) { /* rubout/erase */
if (cpos != 0) { if (cpos != 0) {
@ -322,7 +323,7 @@ int tgetc(void)
} }
/* GET1KEY: Get one keystroke. The only prefixes legal here are the SPEC /* GET1KEY: Get one keystroke. The only prefixes legal here are the SPEC
and CTRL prefixes. */ and CTL_ prefixes. */
static int get1unicode( int *up) { static int get1unicode( int *up) {
/* Accept UTF-8 sequence */ /* Accept UTF-8 sequence */
int bytes ; int bytes ;
@ -343,7 +344,7 @@ static int get1unicode( int *up) {
bytes = utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) up) ; bytes = utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) up) ;
} else { } else {
if( (c >= 0x00 && c <= 0x1F) || c == 0x7F) /* C0 control -> C- */ if( (c >= 0x00 && c <= 0x1F) || c == 0x7F) /* C0 control -> C- */
c ^= CTRL | 0x40 ; c ^= CTL_ | 0x40 ;
*up = c ; *up = c ;
bytes = 1 ; bytes = 1 ;
@ -383,7 +384,7 @@ int getcmd( void) {
c = *(kptr++) = get1key() ; c = *(kptr++) = get1key() ;
if( c == 0x9B) if( c == 0x9B)
goto foundCSI ; goto foundCSI ;
else if( c == (CTRL | '[')) { else if( c == (CTL_ | '[')) {
/* fetch terminal sequence */ /* fetch terminal sequence */
c = *(kptr++) = get1key() ; c = *(kptr++) = get1key() ;
if( c == 'O') { /* F1 .. F4 */ if( c == 'O') { /* F1 .. F4 */
@ -407,7 +408,7 @@ int getcmd( void) {
mask = META ; mask = META ;
if( (v - 1) & 4) if( (v - 1) & 4)
mask |= CTRL ; mask |= CTL_ ;
v = v1 ; v = v1 ;
} }
@ -513,7 +514,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
quote_f = FALSE; quote_f = FALSE;
/* prompt the user for the input string */ /* prompt the user for the input string */
mlwrite( "%s", prompt); mloutstr( prompt);
for (;;) { for (;;) {
#if COMPLC #if COMPLC
@ -538,23 +539,22 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
} }
/* If it is a <ret>, change it to a <NL> */ /* If it is a <ret>, change it to a <NL> */
if( c == (CTRL | 'M')) if( c == (CTL_ | 'M'))
c = CTRL | 0x40 | '\n' ; c = CTL_ | 0x40 | '\n' ;
if( c == eolchar) { if( c == eolchar) {
/* if they hit the line terminator, wrap it up */ /* if they hit the line terminator, wrap it up */
buf[ cpos] = 0 ; buf[ cpos] = 0 ;
/* clear the message line */ /* clear the message line */
mlwrite(""); mloutstr( "") ;
/* if we default the buffer, return FALSE */ /* if we default the buffer, return FALSE */
retval = cpos != 0 ; retval = cpos != 0 ;
break ; break ;
} else if( c == abortc) { } else if( c == abortc) {
/* Abort the input? */ /* Abort the input? */
ctrlg( FALSE, 0) ; retval = ctrlg( FALSE, 1) ;
retval = ABORT ;
break ; break ;
} }
@ -574,7 +574,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
} }
} else if( c == 0x15) { } else if( c == 0x15) {
/* C-U, kill */ /* C-U, kill */
mlwrite( "%s", prompt) ; mloutstr( prompt) ;
cpos = 0 ; cpos = 0 ;
#if COMPLC #if COMPLC
} else if( (c == 0x09 || c == ' ') && file_f) { } else if( (c == 0x09 || c == ' ') && file_f) {
@ -588,7 +588,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
didtry = 1; didtry = 1;
ocpos = cpos; ocpos = cpos;
mlwrite( "%s", prompt) ; mloutstr( prompt) ;
while( cpos != 0) { while( cpos != 0) {
c = buf[ --cpos] ; c = buf[ --cpos] ;
if( c == '*' || c == '?') { if( c == '*' || c == '?') {

View File

@ -1,8 +1,7 @@
/* isearch.c -- implements isearch.h */
#include "isearch.h" #include "isearch.h"
/* isearch.c /* The functions in this file implement commands that perform incremental
*
* The functions in this file implement commands that perform incremental
* searches in the forward and backward directions. This "ISearch" command * searches in the forward and backward directions. This "ISearch" command
* is intended to emulate the same command from the original EMACS * is intended to emulate the same command from the original EMACS
* implementation (ITS). Contains references to routines internal to * implementation (ITS). Contains references to routines internal to
@ -24,7 +23,6 @@
* Modified by Petri Kutvonen * Modified by Petri Kutvonen
*/ */
#include <stdio.h>
#include <string.h> #include <string.h>
#include "basic.h" #include "basic.h"
@ -42,8 +40,6 @@
/* /*
* Incremental search defines. * Incremental search defines.
*/ */
#if ISRCH
#define CMDBUFLEN 256 /* Length of our command buffer */ #define CMDBUFLEN 256 /* Length of our command buffer */
#define IS_ABORT 0x07 /* Abort the isearch */ #define IS_ABORT 0x07 /* Abort the isearch */
@ -60,10 +56,7 @@
/* IS_QUIT is no longer used, the variable metac is used instead */ /* IS_QUIT is no longer used, the variable metac is used instead */
#endif static BINDABLE( isearch) ; /* internal use, not to be bound */
static int isearch( int f, int n) ;
static int checknext( char chr, char *patrn, int dir) ; static int checknext( char chr, char *patrn, int dir) ;
static int scanmore( char *patrn, int dir) ; static int scanmore( char *patrn, int dir) ;
static int match_pat( char *patrn) ; static int match_pat( char *patrn) ;
@ -73,8 +66,6 @@ static int uneat( void) ;
static void reeat( int c) ; static void reeat( int c) ;
#if ISRCH
static int echo_char(int c, int col); static int echo_char(int c, int col);
/* A couple of "own" variables for re-eat */ /* A couple of "own" variables for re-eat */
@ -89,12 +80,10 @@ static int cmd_offset; /* Current offset into command buff */
static int cmd_reexecute = -1; /* > 0 if re-executing command */ static int cmd_reexecute = -1; /* > 0 if re-executing command */
/* /* Subroutine to do incremental reverse search. It actually uses the
* Subroutine to do incremental reverse search. It actually uses the
* same code as the normal incremental search, as both can go both ways. * same code as the normal incremental search, as both can go both ways.
*/ */
int risearch(int f, int n) BINDABLE( risearch) {
{
struct line *curline; /* Current line on entry */ struct line *curline; /* Current line on entry */
int curoff; /* Current offset on entry */ int curoff; /* Current offset on entry */
@ -124,11 +113,10 @@ int risearch(int f, int n)
return TRUE; return TRUE;
} }
/*
* Again, but for the forward direction /* Again, but for the forward direction
*/ */
int fisearch(int f, int n) BINDABLE( fisearch) {
{
struct line *curline; /* Current line on entry */ struct line *curline; /* Current line on entry */
int curoff; /* Current offset on entry */ int curoff; /* Current offset on entry */
@ -156,8 +144,8 @@ int fisearch(int f, int n)
return TRUE; return TRUE;
} }
/*
* Subroutine to do an incremental search. In general, this works similarly /* Subroutine to do an incremental search. In general, this works similarly
* to the older micro-emacs search function, except that the search happens * to the older micro-emacs search function, except that the search happens
* as each character is typed, with the screen and cursor updated with each * as each character is typed, with the screen and cursor updated with each
* new search character. * new search character.
@ -182,8 +170,7 @@ int fisearch(int f, int n)
* exists (or until the search is aborted). * exists (or until the search is aborted).
*/ */
static int isearch(int f, int n) static BINDABLE( isearch) {
{
int status; /* Search status */ int status; /* Search status */
int col; /* prompt column */ int col; /* prompt column */
unsigned cpos ; /* character number in search string */ unsigned cpos ; /* character number in search string */
@ -541,8 +528,6 @@ static void reeat(int c)
saved_get_char = term.t_getchar; /* Save the char get routine */ saved_get_char = term.t_getchar; /* Save the char get routine */
term.t_getchar = uneat; /* Replace it with ours */ term.t_getchar = uneat; /* Replace it with ours */
} }
#else
int isearch(int f, int n)
{ /* end of isearch.c */
}
#endif

View File

@ -1,11 +1,11 @@
/* isearch.h -- incremental search */
#ifndef __ISEARCH_H__ #ifndef __ISEARCH_H__
#define __ISEARCH_H__ #define __ISEARCH_H__
#define ISRCH 1 /* Incremental searches like ITS EMACS */ # include "names.h" /* BINDABLE */
#if ISRCH BINDABLE( risearch) ;
int risearch( int f, int n) ; BINDABLE( fisearch) ;
int fisearch( int f, int n) ;
#endif
#endif #endif
/* end of isearch */

12
line.c
View File

@ -249,12 +249,11 @@ void lchange(int flag)
* *
* int f, n; default flag and numeric argument * int f, n; default flag and numeric argument
*/ */
int insspace(int f, int n) BINDABLE( insspace) {
{
assert( !(curbp->b_mode & MDVIEW)) ; assert( !(curbp->b_mode & MDVIEW)) ;
linsert(n, ' '); linsert( n, ' ') ;
backchar(f, n); backchar( f, n) ;
return TRUE; return TRUE ;
} }
/* /*
@ -821,8 +820,7 @@ BINDABLE( yank) {
* VIEW (read-only) mode * VIEW (read-only) mode
*/ */
boolean rdonly( void) { boolean rdonly( void) {
mloutfmt( "%B(Key illegal in VIEW mode)") ; return mloutfail( "(Key illegal in VIEW mode)") ;
return FALSE ;
} }
/* end of line.c */ /* end of line.c */

View File

@ -12,4 +12,9 @@ void mloutstr( const char *str) {
mloutfmt( (*str) ? "%s" : "", str) ; mloutfmt( (*str) ? "%s" : "", str) ;
} }
boolean mloutfail( const char *msg) {
mloutfmt( "%B%s", msg) ;
return FALSE ;
}
/* end of mlout.c */ /* end of mlout.c */

View File

@ -3,9 +3,12 @@
#ifndef __MLOUT_H__ #ifndef __MLOUT_H__
#define __MLOUT_H__ #define __MLOUT_H__
#include "retcode.h"
extern void (*mloutfmt)( const char *, ...) ; extern void (*mloutfmt)( const char *, ...) ;
void mloutstr( const char *str) ; void mloutstr( const char *str) ;
boolean mloutfail( const char *msg) ; /* output with BELL and return FALSE */
#endif /* __MLOUT_H__ */ #endif /* __MLOUT_H__ */

192
names.c
View File

@ -33,51 +33,51 @@
const name_bind names[] = { const name_bind names[] = {
{" abort-command", ctrlg, CTRL | 'G'} , {" abort-command", ctrlg, CTL_ | 'G'} ,
{" add-global-mode", setgmode, META | 'M'} , {" add-global-mode", setgmode, META | 'M'} ,
{" add-mode", setemode, CTLX | 'M'} , {" add-mode", setemode, CTLX | 'M'} ,
{" apropos", apro, META | 'A'} , {" apropos", apro, META | 'A'} ,
{" backward-character", (fnp_t) backchar, CTRL | 'B'} , {" backward-character", (fnp_t) backchar, CTL_ | 'B'} ,
{" begin-macro", ctlxlp, CTLX | '('} , {" begin-macro", (fnp_t) ctlxlp, CTLX | '('} ,
{" beginning-of-file", (fnp_t) gotobob, META | '<'} , {" beginning-of-file", (fnp_t) gotobob, META | '<'} ,
{" beginning-of-line", (fnp_t) gotobol, CTRL | 'A'} , {" beginning-of-line", (fnp_t) gotobol, CTL_ | 'A'} ,
{" bind-to-key", bindtokey, META | 'K'} , {" bind-to-key", bindtokey, META | 'K'} ,
{" buffer-position", showcpos, CTLX | '='} , {" buffer-position", showcpos, CTLX | '='} ,
{"!case-region-lower", lowerregion, CTLX | CTRL | 'L'} , {"!case-region-lower", lowerregion, CTLX | CTL_ | 'L'} ,
{"!case-region-upper", upperregion, CTLX | CTRL | 'U'} , {"!case-region-upper", upperregion, CTLX | CTL_ | 'U'} ,
{"!case-word-capitalize", capword, META | 'C'} , {"!case-word-capitalize", capword, META | 'C'} ,
{"!case-word-lower", lowerword, META | 'L'} , {"!case-word-lower", lowerword, META | 'L'} ,
{"!case-word-upper", upperword, META | 'U'} , {"!case-word-upper", upperword, META | 'U'} ,
{" change-file-name", filename, CTLX | 'N'} , {" change-file-name", filename, CTLX | 'N'} ,
{" change-screen-size", newsize, META | CTRL | 'D'} , /* M^S */ {" change-screen-size", newsize, META | CTL_ | 'D'} , /* M^S */
{" change-screen-width", newwidth, META | CTRL | 'T'} , {" change-screen-width", newwidth, META | CTL_ | 'T'} ,
{" clear-and-redraw", redraw, CTRL | 'L'} , {" clear-and-redraw", (fnp_t) redraw, CTL_ | 'L'} ,
{" clear-message-line", clrmes, 0} , {" clear-message-line", (fnp_t) clrmes, 0} ,
{" copy-region", copyregion, META | 'W'} , {" copy-region", copyregion, META | 'W'} ,
{" count-words", wordcount, META | CTRL | 'C'} , {" count-words", wordcount, META | CTL_ | 'C'} ,
{" ctlx-prefix", cex, CTRL | 'X'} , {" ctlx-prefix", (fnp_t) cex, CTL_ | 'X'} ,
{"!delete-blank-lines", deblank, CTLX | CTRL | 'O'} , {"!delete-blank-lines", deblank, CTLX | CTL_ | 'O'} ,
{" delete-buffer", killbuffer, CTLX | 'K'} , {" delete-buffer", killbuffer, CTLX | 'K'} ,
{" delete-global-mode", delgmode, META | CTRL | 'M'} , {" delete-global-mode", delgmode, META | CTL_ | 'M'} ,
{" delete-mode", delmode, CTLX | CTRL | 'M'} , {" delete-mode", delmode, CTLX | CTL_ | 'M'} ,
{"!delete-next-character", forwdel, CTRL | 'D'} , {"!delete-next-character", forwdel, CTL_ | 'D'} ,
{"!delete-next-word", delfword, META | 'D'} , {"!delete-next-word", delfword, META | 'D'} ,
{" delete-other-windows", onlywind, CTLX | '1'} , {" delete-other-windows", onlywind, CTLX | '1'} ,
{"!delete-previous-character", backdel, CTRL | 'H'} , /* ^? */ {"!delete-previous-character", backdel, CTL_ | 'H'} , /* ^? */
{"!delete-previous-word", delbword, META | CTRL | 'H'} , /* M^? */ {"!delete-previous-word", delbword, META | CTL_ | 'H'} , /* M^? */
{" delete-window", delwind, CTLX | '0'} , {" delete-window", delwind, CTLX | '0'} ,
{" describe-bindings", desbind, 0} , {" describe-bindings", desbind, 0} ,
{" describe-key", deskey, CTLX | '?'} , {" describe-key", deskey, CTLX | '?'} ,
{"!detab-line", detab, CTLX | CTRL | 'D'} , /* X^A */ {"!detab-line", detab, CTLX | CTL_ | 'D'} , /* X^A */
{" end-macro", ctlxrp, CTLX | ')'} , {" end-macro", (fnp_t) ctlxrp, CTLX | ')'} ,
{" end-of-file", (fnp_t) gotoeob, META | '>'} , {" end-of-file", (fnp_t) gotoeob, META | '>'} ,
{" end-of-line", (fnp_t) gotoeol, CTRL | 'E'} , {" end-of-line", (fnp_t) gotoeol, CTL_ | 'E'} ,
{"!entab-line", entab, CTLX | CTRL | 'E'} , {"!entab-line", entab, CTLX | CTL_ | 'E'} ,
{" exchange-point-and-mark", (fnp_t) swapmark, CTLX | CTRL | 'X'} , {" exchange-point-and-mark", (fnp_t) swapmark, CTLX | CTL_ | 'X'} ,
{" execute-buffer", execbuf, 0} , {" execute-buffer", execbuf, 0} ,
{" execute-command-line", execcmd, 0} , {" execute-command-line", execcmd, 0} ,
{" execute-file", execfile, 0} , {" execute-file", execfile, 0} ,
{" execute-macro", ctlxe, CTLX | 'E'} , {" execute-macro", (fnp_t) ctlxe, CTLX | 'E'} ,
{" execute-macro-1", cbuf1, 0} , {" execute-macro-1", cbuf1, 0} ,
{" execute-macro-10", cbuf10, 0} , {" execute-macro-10", cbuf10, 0} ,
{" execute-macro-11", cbuf11, 0} , {" execute-macro-11", cbuf11, 0} ,
@ -119,116 +119,106 @@ const name_bind names[] = {
{" execute-macro-8", cbuf8, 0} , {" execute-macro-8", cbuf8, 0} ,
{" execute-macro-9", cbuf9, 0} , {" execute-macro-9", cbuf9, 0} ,
{" execute-named-command", namedcmd, META | 'X'} , {" execute-named-command", namedcmd, META | 'X'} ,
#if PROC {" execute-procedure", execproc, META | CTL_ | 'E'} ,
{" execute-procedure", execproc, META | CTRL | 'E'} ,
#endif
{" execute-program", execprg, CTLX | '$'} , {" execute-program", execprg, CTLX | '$'} ,
{" exit-emacs", quit, CTLX | CTRL | 'C'} , {" exit-emacs", quit, CTLX | CTL_ | 'C'} ,
{"!fill-paragraph", fillpara, META | 'Q'} , {"!fill-paragraph", fillpara, META | 'Q'} ,
{"!filter-buffer", filter_buffer, CTLX | '#'} , {"!filter-buffer", filter_buffer, CTLX | '#'} ,
{" find-file", filefind, CTLX | CTRL | 'F'} , {" find-file", filefind, CTLX | CTL_ | 'F'} ,
{" forward-character", (fnp_t) forwchar, CTRL | 'F'} , {" forward-character", (fnp_t) forwchar, CTL_ | 'F'} ,
{" goto-line", gotoline, META | 'G'} , {" goto-line", gotoline, META | 'G'} ,
#if CFENCE #if CFENCE
{" goto-matching-fence", getfence, META | CTRL | 'F'} , {" goto-matching-fence", getfence, META | CTL_ | 'F'} ,
#endif #endif
{" grow-window", enlargewind, CTLX | 'Z'} , /* X^ */ {" grow-window", enlargewind, CTLX | 'Z'} , /* X^ */
{"!handle-tab", insert_tab, CTRL | 'I'} , {"!handle-tab", insert_tab, CTL_ | 'I'} ,
{" help", help, META | '?'} , {" help", help, META | '?'} ,
{" hunt-backward", backhunt, 0} , {" hunt-backward", backhunt, 0} ,
{" hunt-forward", forwhunt, META | 'S'} , {" hunt-forward", forwhunt, META | 'S'} ,
{" i-shell", spawncli, CTLX | 'C'} , {" i-shell", spawncli, CTLX | 'C'} ,
#if ISRCH
{" incremental-search", fisearch, CTLX | 'S'} , {" incremental-search", fisearch, CTLX | 'S'} ,
#endif {"!insert-file", insfile, CTLX | CTL_ | 'I'} ,
{"!insert-file", insfile, CTLX | CTRL | 'I'} , {"!insert-space", insspace, CTL_ | 'C'} ,
{"!insert-space", insspace, CTRL | 'C'} ,
{"!insert-string", istring, 0} , {"!insert-string", istring, 0} ,
#if PKCODE #if PKCODE
{"!justify-paragraph", justpara, META | 'J'} , {"!justify-paragraph", justpara, META | 'J'} ,
#endif #endif
{"!kill-paragraph", killpara, META | CTRL | 'W'} , {"!kill-paragraph", killpara, META | CTL_ | 'W'} ,
{"!kill-region", killregion, CTRL | 'W'} , {"!kill-region", killregion, CTL_ | 'W'} ,
{"!kill-to-end-of-line", killtext, CTRL | 'K'} , {"!kill-to-end-of-line", killtext, CTL_ | 'K'} ,
{" list-buffers", listbuffers, CTLX | CTRL | 'B'} , {" list-buffers", listbuffers, CTLX | CTL_ | 'B'} ,
{" meta-prefix", metafn, CTRL | '['} , {" meta-prefix", (fnp_t) metafn, CTL_ | '['} ,
{" move-window-down", mvdnwind, CTLX | CTRL | 'N'} , {" move-window-down", mvdnwind, CTLX | CTL_ | 'N'} ,
{" move-window-up", mvupwind, CTLX | CTRL | 'P'} , {" move-window-up", mvupwind, CTLX | CTL_ | 'P'} ,
{" name-buffer", namebuffer, META | CTRL | 'N'} , {" name-buffer", namebuffer, META | CTL_ | 'N'} ,
{"!newline", insert_newline, CTRL | 'M'} , {"!newline", insert_newline, CTL_ | 'M'} ,
{"!newline-and-indent", indent, CTRL | 'J'} , {"!newline-and-indent", indent, CTL_ | 'J'} ,
{" next-buffer", nextbuffer, CTLX | 'X'} , {" next-buffer", nextbuffer, CTLX | 'X'} ,
{" next-line", (fnp_t) forwline, CTRL | 'N'} , {" next-line", (fnp_t) forwline, CTL_ | 'N'} ,
{" next-page", (fnp_t) forwpage, CTRL | 'V'} , {" next-page", (fnp_t) forwpage, CTL_ | 'V'} ,
{" next-paragraph", gotoeop, META | 'N'} , {" next-paragraph", gotoeop, META | 'N'} ,
{" next-window", nextwind, CTLX | 'O'} , {" next-window", nextwind, CTLX | 'O'} ,
{" next-word", forwword, META | 'F'} , {" next-word", forwword, META | 'F'} ,
{" nop", nullproc, SPEC | META | 'C'}, /* hook */ {" nop", (fnp_t) nullproc, META | SPEC | 'C'}, /* hook */
{"!open-line", openline, CTRL | 'O'} , {"!open-line", openline, CTL_ | 'O'} ,
{"!overwrite-string", ovstring, 0} , {"!overwrite-string", ovstring, 0} ,
{" pipe-command", pipecmd, CTLX | '@'} , {" pipe-command", pipecmd, CTLX | '@'} ,
{" previous-line", (fnp_t) backline, CTRL | 'P'} , {" previous-line", (fnp_t) backline, CTL_ | 'P'} ,
{" previous-page", (fnp_t) backpage, CTRL | 'Z'} , /* MV */ {" previous-page", (fnp_t) backpage, CTL_ | 'Z'} , /* MV */
{" previous-paragraph", gotobop, META | 'P'} , {" previous-paragraph", gotobop, META | 'P'} ,
{" previous-window", prevwind, CTLX | 'P'} , {" previous-window", prevwind, CTLX | 'P'} ,
{" previous-word", backword, META | 'B'} , {" previous-word", backword, META | 'B'} ,
{"!query-replace-string", qreplace, META | CTRL | 'R'} , {"!query-replace-string", qreplace, META | CTL_ | 'R'} ,
{" quick-exit", quickexit, META | 'Z'} , {" quick-exit", quickexit, META | 'Z'} ,
{"!quote-character", quote, CTRL | 'Q'} , /* also XQ */ {"!quote-character", quote, CTL_ | 'Q'} ,
{"!read-file", fileread, CTLX | CTRL | 'R'} , {"!read-file", fileread, CTLX | CTL_ | 'R'} ,
{" redraw-display", reposition, META | CTRL | 'L'} , /* M! */ {" redraw-display", (fnp_t) reposition, META | CTL_ | 'L'} ,
{"!replace-string", sreplace, META | 'R'} , {"!replace-string", sreplace, META | 'R'} ,
{" resize-window", resize, CTLX | 'W'} , {" resize-window", resize, CTLX | 'W'} ,
{" restore-window", restwnd, 0} , {" restore-window", restwnd, 0} ,
#if ISRCH
{" reverse-incremental-search", risearch, CTLX | 'R'} , {" reverse-incremental-search", risearch, CTLX | 'R'} ,
#endif {" run", execproc, 0} , /* alias of execute-procedure */
#if PROC {"!save-file", filesave, CTLX | CTL_ | 'S'} , /* also X^D */
{" run", execproc, 0} , // alias of execute-procedure
#endif
{"!save-file", filesave, CTLX | CTRL | 'S'} , /* also X^D */
{" save-window", savewnd, 0} , {" save-window", savewnd, 0} ,
{" scroll-next-down", scrnextdw, META | CTRL | 'V'} , {" scroll-next-down", scrnextdw, META | CTL_ | 'V'} ,
{" scroll-next-up", scrnextup, META | CTRL | 'Z'} , {" scroll-next-up", scrnextup, META | CTL_ | 'Z'} ,
{" search-forward", forwsearch, CTRL | 'S'} , {" search-forward", forwsearch, CTL_ | 'S'} ,
{" search-reverse", backsearch, CTRL | 'R'} , {" search-reverse", backsearch, CTL_ | 'R'} ,
{" select-buffer", usebuffer, CTLX | 'B'} , {" select-buffer", usebuffer, CTLX | 'B'} ,
{" set", setvar, CTLX | 'A'} , {" set", setvar, CTLX | 'A'} ,
{" set-fill-column", setfillcol, CTLX | 'F'} , {" set-fill-column", setfillcol, CTLX | 'F'} ,
{" set-mark", (fnp_t) setmark, META | ' '} , /* M. */ {" set-mark", (fnp_t) setmark, META | ' '} , /* M. */
{" shell-command", spawn, CTLX | '!'} , {" shell-command", spawn, CTLX | '!'} ,
{" shrink-window", shrinkwind, CTLX | CTRL | 'Z'} , {" shrink-window", shrinkwind, CTLX | CTL_ | 'Z'} ,
{" split-current-window", splitwind, CTLX | '2'} , {" split-current-window", splitwind, CTLX | '2'} ,
{" store-macro", storemac, 0} , {" store-macro", storemac, 0} ,
#if PROC
{" store-procedure", storeproc, 0} , {" store-procedure", storeproc, 0} ,
#endif
#if BSD | SVR4 #if BSD | SVR4
{" suspend-emacs", bktoshell, CTLX | 'D'} , /* BSD MS */ {" suspend-emacs", bktoshell, CTLX | 'D'} , /* BSD MS */
#endif #endif
{"!transpose-characters", (fnp_t) twiddle, CTRL | 'T'} , {"!transpose-characters", (fnp_t) twiddle, CTL_ | 'T'} ,
{"!trim-line", trim, CTLX | CTRL | 'T'} , {"!trim-line", trim, CTLX | CTL_ | 'T'} ,
{" unbind-key", unbindkey, META | CTRL | 'K'} , {" unbind-key", unbindkey, META | CTL_ | 'K'} ,
{" universal-argument", unarg, CTRL | 'U'} , {" universal-argument", (fnp_t) unarg, CTL_ | 'U'} ,
{" unmark-buffer", unmark, META | '~'} , {" unmark-buffer", unmark, META | '~'} ,
{" update-screen", upscreen, 0} , {" update-screen", upscreen, 0} ,
{" view-file", viewfile, CTLX | CTRL | 'V'} , {" view-file", viewfile, CTLX | CTL_ | 'V'} ,
{"!wrap-word", wrapword, SPEC | META | 'W'} , /* hook */ {"!wrap-word", wrapword, META | SPEC | 'W'} , /* hook */
{" write-file", filewrite, CTLX | CTRL | 'W'} , {" write-file", filewrite, CTLX | CTL_ | 'W'} ,
{" write-message", writemsg, 0} , {" write-message", writemsg, 0} ,
{"!yank", yank, CTRL | 'Y'} , {"!yank", yank, CTL_ | 'Y'} ,
{" ", NULL, 0}, {" ", NULL, 0},
/* extra key mapping */ /* extra key mapping */
// { NULL, newsize, META | CTRL | 'S'}, // { NULL, newsize, META | CTL_ | 'S'},
{ NULL, backdel, CTRL | '?'}, { NULL, backdel, CTL_ | '?'},
{ NULL, delbword, META | CTRL | '?'}, { NULL, delbword, META | CTL_ | '?'},
{ NULL, detab, CTLX | CTRL | 'A'}, { NULL, detab, CTLX | CTL_ | 'A'},
{ NULL, enlargewind, CTLX | '^'}, { NULL, enlargewind, CTLX | '^'},
{ NULL, (fnp_t) backpage, META | 'V'}, { NULL, (fnp_t) backpage, META | 'V'},
{ NULL, quote, CTLX | 'Q'}, { NULL, quote, CTLX | 'Q'},
{ NULL, reposition, META | '!'}, { NULL, (fnp_t) reposition, META | '!'},
//detab { NULL, filesave, CTLX | CTRL | 'D'}, //detab { NULL, filesave, CTLX | CTL_ | 'D'},
{ NULL, (fnp_t) setmark, META | '.'}, { NULL, (fnp_t) setmark, META | '.'},
// { NULL, bktoshell, META | 'S'}, // { NULL, bktoshell, META | 'S'},
@ -246,14 +236,14 @@ const name_bind names[] = {
{ NULL, help, SPEC | 'P'}, /* F1 */ { NULL, help, SPEC | 'P'}, /* F1 */
/* hooks */ /* hooks */
{ NULL, nullproc, SPEC | META | 'R'}, /* hook */ { NULL, (fnp_t) nullproc, META | SPEC | 'R'}, /* hook */
{ NULL, nullproc, SPEC | META | 'X'}, /* hook */ { NULL, (fnp_t) nullproc, META | SPEC | 'X'}, /* hook */
{ NULL, NULL, 0} { NULL, NULL, 0}
} ; } ;
static int lastnmidx = 0 ; /* index of last name entry */
static int lastnmidx = 0 ; /* index of last name entry */
kbind_p keytab ; kbind_p keytab ;
static int ktsize = 140 ; /* last check: need at least 133 + 1 */ static int ktsize = 140 ; /* last check: need at least 133 + 1 */
@ -282,6 +272,9 @@ boolean init_bindings( void) {
/* Add key definition */ /* Add key definition */
if( nbp->n_keycode) { if( nbp->n_keycode) {
kbind_p ktp = setkeybinding( nbp->n_keycode, nbp) ; kbind_p ktp = setkeybinding( nbp->n_keycode, nbp) ;
if( ktp->k_code == 0) /* Table full, no memory left */
return FALSE ;
/* check it was indeed an insertion at end of table not a /* check it was indeed an insertion at end of table not a
* key code re-definition */ * key code re-definition */
assert( (++ktp)->k_code == 0) ; assert( (++ktp)->k_code == 0) ;
@ -293,14 +286,20 @@ boolean init_bindings( void) {
/* Process extra key bindings if any */ /* Process extra key bindings if any */
for( nbp++ ; nbp->n_func != NULL ; nbp++) { for( nbp++ ; nbp->n_func != NULL ; nbp++) {
/* Check entry */ /* Check entry: a keycode and no name */
assert( nbp->n_keycode && (nbp->n_name == NULL)) ; assert( nbp->n_keycode && (nbp->n_name == NULL)) ;
/* Look for corresponding function and add extra key binding */ /* Look for corresponding function and add extra key binding */
nbind_p fnbp ; nbind_p fnbp ;
for( fnbp = names ; fnbp->n_func != NULL ; fnbp++) for( fnbp = names ; fnbp->n_func != NULL ; fnbp++)
if( fnbp->n_func == nbp->n_func) { if( fnbp->n_func == nbp->n_func) {
setkeybinding( nbp->n_keycode, fnbp) ; kbind_p ktp = setkeybinding( nbp->n_keycode, fnbp) ;
if( ktp->k_code == 0) /* Table full, no memory left */
return FALSE ;
/* check it was indeed an insertion at end of table not a
* key code re-definition */
assert( (++ktp)->k_code == 0) ;
break ; break ;
} }
@ -370,8 +369,8 @@ boolean delkeybinding( unsigned key) {
return FALSE ; return FALSE ;
} }
/*
* This function looks a key binding up in the binding table /* This function looks a key binding up in the binding table
* *
* int c; key to find what is bound to it * int c; key to find what is bound to it
*/ */
@ -416,23 +415,26 @@ nbind_p fncmatch( char *name) {
} }
/* user function that does NOTHING */ /* user function that does NOTHING (bound to hooks) */
BINDABLE( nullproc) { TBINDABLE( nullproc) {
return TRUE ; return TRUE ;
} }
/* dummy function for binding to meta prefix */ /* dummy function for binding to meta prefix */
BINDABLE( metafn) { TBINDABLE( metafn) {
return TRUE ; return TRUE ;
} }
/* dummy function for binding to control-x prefix */ /* dummy function for binding to control-x prefix */
BINDABLE( cex) { TBINDABLE( cex) {
return TRUE ; return TRUE ;
} }
/* dummy function for binding to universal-argument */ /* dummy function for binding to universal-argument */
BINDABLE( unarg) { TBINDABLE( unarg) {
return TRUE ; return TRUE ;
} }

19
names.h
View File

@ -1,12 +1,10 @@
/* names.h -- mapping of functions to names and keys */ /* names.h -- mapping of functions to names and keys */
#ifndef _NAMES_H_ #ifndef _NAMES_H_
#define _NAMES_H_ # define _NAMES_H_
#include "retcode.h" #include "retcode.h"
#define CTL_ 0x01000000 /* Control flag, or'ed in */
#define CTRL 0x01000000 /* Control flag, or'ed in */
#define META 0x02000000 /* Meta flag, or'ed in */ #define META 0x02000000 /* Meta flag, or'ed in */
#define CTLX 0x04000000 /* ^X flag, or'ed in */ #define CTLX 0x04000000 /* ^X flag, or'ed in */
#define SPEC 0x08000000 /* special key (function keys) */ #define SPEC 0x08000000 /* special key (function keys) */
@ -14,7 +12,9 @@
/* Bindable uEMACS function pointer type and definition template */ /* Bindable uEMACS function pointer type and definition template */
#define BINDABLE( fname) int fname( int f, int n) #define BINDABLE( fname) int fname( boolean f, int n)
#define BBINDABLE( fname) boolean fname( boolean f, int n)
#define TBINDABLE BBINDABLE
typedef BINDABLE( (*fnp_t)) ; typedef BINDABLE( (*fnp_t)) ;
@ -53,11 +53,10 @@ nbind_p fncmatch( char *name) ; /* look up by name */
/* bindable functions mapped to prefix keys and hooks */ /* bindable functions mapped to prefix keys and hooks */
BINDABLE( nullproc) ; TBINDABLE( nullproc) ;
BINDABLE( metafn) ; TBINDABLE( metafn) ;
BINDABLE( cex) ; TBINDABLE( cex) ;
BINDABLE( unarg) ; TBINDABLE( unarg) ;
#endif #endif
/* end of names.h */ /* end of names.h */

View File

@ -144,15 +144,13 @@ int getcline(void)
return numlines + 1; return numlines + 1;
} }
/* /* Return current column. Stop at first non-blank given TRUE argument.
* Return current column. Stop at first non-blank given TRUE argument.
*/ */
int getccol(int bflg) int getccol( int bflg) {
{ int i, col ;
int i, col;
line_p dlp = curwp->w_dotp ; line_p dlp = curwp->w_dotp ;
int byte_offset = curwp->w_doto; int byte_offset = curwp->w_doto ;
int len = llength(dlp); int len = llength( dlp) ;
col = i = 0; col = i = 0;
while (i < byte_offset) { while (i < byte_offset) {
@ -160,17 +158,20 @@ int getccol(int bflg)
i += utf8_to_unicode(dlp->l_text, i, len, &c); i += utf8_to_unicode(dlp->l_text, i, len, &c);
if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */ if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */
break; break ;
if (c == '\t') if (c == '\t')
col += tabwidth - col % tabwidth ; col += tabwidth - col % tabwidth ;
else if (c < 0x20 || c == 0x7F) /* displayed as ^c */ else if (c < 0x20 || c == 0x7F) /* displayed as ^c */
col += 2 ; col += 2 ;
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */ else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
col += 3 ; col += 3 ;
else else {
col += 1 ; int w = utf8_width( c) ; /* incomplete wc_width */
col += (w < 0) ? 2 : w ;
}
} }
return col;
return col ;
} }
/* /*
@ -714,60 +715,40 @@ BINDABLE( killtext) {
return ldelete(chunk, TRUE); return ldelete(chunk, TRUE);
} }
/*
* prompt and set an editor mode /* prompt and set an editor mode
* *
* int f, n; default and argument * int f, n; default and argument
*/ */
int setemode(int f, int n) BINDABLE( setemode) {
{ return adjustmode( TRUE, FALSE) ;
#if PKCODE
return adjustmode(TRUE, FALSE);
#else
adjustmode(TRUE, FALSE);
#endif
} }
/*
* prompt and delete an editor mode /* prompt and delete an editor mode
* *
* int f, n; default and argument * int f, n; default and argument
*/ */
int delmode(int f, int n) BINDABLE( delmode) {
{ return adjustmode( FALSE, FALSE) ;
#if PKCODE
return adjustmode(FALSE, FALSE);
#else
adjustmode(FALSE, FALSE);
#endif
} }
/*
* prompt and set a global editor mode /* prompt and set a global editor mode
* *
* int f, n; default and argument * int f, n; default and argument
*/ */
int setgmode(int f, int n) BINDABLE( setgmode) {
{ return adjustmode( TRUE, TRUE) ;
#if PKCODE
return adjustmode(TRUE, TRUE);
#else
adjustmode(TRUE, TRUE);
#endif
} }
/*
* prompt and delete a global editor mode /* prompt and delete a global editor mode
* *
* int f, n; default and argument * int f, n; default and argument
*/ */
int delgmode(int f, int n) BINDABLE( delgmode) {
{ return adjustmode( FALSE, TRUE) ;
#if PKCODE
return adjustmode(FALSE, TRUE);
#else
adjustmode(FALSE, TRUE);
#endif
} }
/* /*
@ -858,11 +839,10 @@ static int adjustmode( int kind, int global) {
static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) { static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) {
int status ; /* status return code */
char *tstring ; /* string to add */ char *tstring ; /* string to add */
/* ask for string to insert */ /* ask for string to insert */
status = newmlargt( &tstring, prompt, 0) ; /* grab as big a token as screen allow */ int status = newmlargt( &tstring, prompt, 0) ;
if( tstring == NULL) if( tstring == NULL)
return status ; return status ;

View File

@ -9,7 +9,7 @@
*/ */
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stddef.h>
#include "buffer.h" #include "buffer.h"
#include "estruct.h" #include "estruct.h"
@ -139,10 +139,9 @@ int getregion( region_p rp) {
line_p flp, blp ; line_p flp, blp ;
long fsize, bsize ; long fsize, bsize ;
if (curwp->w_markp == NULL) { if (curwp->w_markp == NULL)
mloutstr( "No mark set in this window") ; return mloutfail( "No mark set in this window") ;
return FALSE;
}
if (curwp->w_dotp == curwp->w_markp) { if (curwp->w_dotp == curwp->w_markp) {
rp->r_linep = curwp->w_dotp; rp->r_linep = curwp->w_dotp;
if (curwp->w_doto < curwp->w_marko) { if (curwp->w_doto < curwp->w_marko) {
@ -182,8 +181,8 @@ int getregion( region_p rp) {
} }
} }
} }
mloutstr( "Bug: lost mark") ;
return FALSE; return mloutfail( "Bug: lost mark") ;
} }
/* end of region.c */ /* end of region.c */

View File

@ -1,9 +1,7 @@
/* search.c -- implements search.h */ /* search.c -- implements search.h */
#include "search.h" #include "search.h"
/* search.c /* The functions in this file implement commands that search in the forward
*
* The functions in this file implement commands that search in the forward
* and backward directions. There are no special characters in the search * and backward directions. There are no special characters in the search
* strings. Probably should have a regular expression search, or something * strings. Probably should have a regular expression search, or something
* like that. * like that.
@ -177,15 +175,14 @@ static int biteq(int bc, char *cclmap);
static char *clearbits(void); static char *clearbits(void);
static void setbit(int bc, char *cclmap); static void setbit(int bc, char *cclmap);
/*
* forwsearch -- Search forward. Get a search string from the user, and /* forwsearch -- Search forward. Get a search string from the user, and
* search for the string. If found, reset the "." to be just after * search for the string. If found, reset the "." to be just after
* the match string, and (perhaps) repaint the display. * the match string, and (perhaps) repaint the display.
* *
* int f, n; default flag / numeric argument * int f, n; default flag / numeric argument
*/ */
int forwsearch(int f, int n) BINDABLE( forwsearch) {
{
int status = TRUE; int status = TRUE;
/* If n is negative, search backwards. /* If n is negative, search backwards.
@ -223,15 +220,14 @@ int forwsearch(int f, int n)
return status; return status;
} }
/*
* forwhunt -- Search forward for a previously acquired search string. /* forwhunt -- Search forward for a previously acquired search string.
* If found, reset the "." to be just after the match string, * If found, reset the "." to be just after the match string,
* and (perhaps) repaint the display. * and (perhaps) repaint the display.
* *
* int f, n; default flag / numeric argument * int f, n; default flag / numeric argument
*/ */
int forwhunt(int f, int n) BINDABLE( forwhunt) {
{
int status = TRUE; int status = TRUE;
if (n < 0) /* search backwards */ if (n < 0) /* search backwards */
@ -276,16 +272,15 @@ int forwhunt(int f, int n)
return status; return status;
} }
/*
* backsearch -- Reverse search. Get a search string from the user, and /* backsearch -- Reverse search. Get a search string from the user, and
* search, starting at "." and proceeding toward the front of the buffer. * search, starting at "." and proceeding toward the front of the buffer.
* If found "." is left pointing at the first character of the pattern * If found "." is left pointing at the first character of the pattern
* (the last character that was matched). * (the last character that was matched).
* *
* int f, n; default flag / numeric argument * int f, n; default flag / numeric argument
*/ */
int backsearch(int f, int n) BINDABLE( backsearch) {
{
int status = TRUE; int status = TRUE;
/* If n is negative, search forwards. /* If n is negative, search forwards.
@ -324,16 +319,15 @@ int backsearch(int f, int n)
return status; return status;
} }
/*
* backhunt -- Reverse search for a previously acquired search string, /* backhunt -- Reverse search for a previously acquired search string,
* starting at "." and proceeding toward the front of the buffer. * starting at "." and proceeding toward the front of the buffer.
* If found "." is left pointing at the first character of the pattern * If found "." is left pointing at the first character of the pattern
* (the last character that was matched). * (the last character that was matched).
* *
* int f, n; default flag / numeric argument * int f, n; default flag / numeric argument
*/ */
int backhunt(int f, int n) BINDABLE( backhunt) {
{
int status = TRUE; int status = TRUE;
if (n < 0) if (n < 0)
@ -788,26 +782,24 @@ void rvstrcpy(char *rvstr, char *str)
*rvstr = '\0'; *rvstr = '\0';
} }
/*
* sreplace -- Search and replace. /* sreplace -- Search and replace.
* *
* int f; default flag * int f; default flag
* int n; # of repetitions wanted * int n; # of repetitions wanted
*/ */
int sreplace(int f, int n) BINDABLE( sreplace) {
{ return replaces( FALSE, f, n) ;
return replaces(FALSE, f, n);
} }
/*
* qreplace -- search and replace with query. /* qreplace -- search and replace with query.
* *
* int f; default flag * int f; default flag
* int n; # of repetitions wanted * int n; # of repetitions wanted
*/ */
int qreplace(int f, int n) BINDABLE( qreplace) {
{ return replaces( TRUE, f, n) ;
return replaces(TRUE, f, n);
} }
/* /*

39
spawn.c
View File

@ -1,9 +1,7 @@
/* spawn.c -- implements spawn.h */ /* spawn.c -- implements spawn.h */
#include "spawn.h" #include "spawn.h"
/* spawn.c /* Various operating system access commands.
*
* Various operating system access commands.
* *
* Modified by Petri Kutvonen * Modified by Petri Kutvonen
*/ */
@ -34,13 +32,11 @@
#endif #endif
/* /* Create a subjob with a copy of the command intrepreter in it. When the
* Create a subjob with a copy of the command intrepreter in it. When the
* command interpreter exits, mark the screen as garbage so that you do a full * command interpreter exits, mark the screen as garbage so that you do a full
* repaint. Bound to "^X C". * repaint. Bound to "^X C".
*/ */
int spawncli(int f, int n) BINDABLE( spawncli) {
{
#if USG | BSD #if USG | BSD
char *cp; char *cp;
#endif #endif
@ -81,9 +77,8 @@ int spawncli(int f, int n)
} }
#if BSD | SVR4 #if BSD | SVR4
/* suspend MicroEMACS and wait to wake up */
int bktoshell(int f, int n) BINDABLE( bktoshell) {
{ /* suspend MicroEMACS and wait to wake up */
vttidy(); vttidy();
/****************************** /******************************
int pid; int pid;
@ -103,12 +98,12 @@ void rtfrmshell(void)
} }
#endif #endif
/*
* Run a one-liner in a subjob. When the command returns, wait for a single /* Run a one-liner in a subjob. When the command returns, wait for a single
* character to be typed, then mark the screen as garbage so a full repaint is * character to be typed, then mark the screen as garbage so a full repaint is
* done. Bound to "C-X !". * done. Bound to "C-X !".
*/ */
int spawn( int f, int n) { BINDABLE( spawn) {
int s ; int s ;
char *line ; char *line ;
@ -141,13 +136,13 @@ int spawn( int f, int n) {
#endif #endif
} }
/*
* Run an external program with arguments. When it returns, wait for a single /* Run an external program with arguments. When it returns, wait for a single
* character to be typed, then mark the screen as garbage so a full repaint is * character to be typed, then mark the screen as garbage so a full repaint is
* done. Bound to "C-X $". * done. Bound to "C-X $".
*/ */
int execprg( int f, int n) { BINDABLE( execprg) {
int s ; int s ;
char *line ; char *line ;
@ -176,11 +171,11 @@ int execprg( int f, int n) {
#endif #endif
} }
/*
* Pipe a one line command into a window /* Pipe a one line command into a window
* Bound to ^X @ * Bound to ^X @
*/ */
int pipecmd( int f, int n) { BINDABLE( pipecmd) {
int s ; /* return status from CLI */ int s ; /* return status from CLI */
struct window *wp ; /* pointer to new window */ struct window *wp ; /* pointer to new window */
buffer_p bp ; /* pointer to buffer to zot */ buffer_p bp ; /* pointer to buffer to zot */
@ -271,11 +266,11 @@ int pipecmd( int f, int n) {
return TRUE; return TRUE;
} }
/*
* filter a buffer through an external DOS program /* filter a buffer through an external DOS program
* Bound to ^X # * Bound to ^X #
*/ */
int filter_buffer( int f, int n) { BINDABLE( filter_buffer) {
int s ; /* return status from CLI */ int s ; /* return status from CLI */
buffer_p bp ; /* pointer to buffer to zot */ buffer_p bp ; /* pointer to buffer to zot */
char *mlarg ; char *mlarg ;

25
util.c
View File

@ -1,17 +1,20 @@
/* util.c -- implements util.h */
#include "util.h" #include "util.h"
/* Safe zeroing, no complaining about overlap */ /* Safe zeroing, no complaining about overlap */
void mystrscpy(char *dst, const char *src, int size) void mystrscpy( char *dst, const char *src, int size) {
{ if( size <= 0)
if (!size) return ;
return;
while (--size) { while( --size) {
char c = *src++; char c = *src++ ;
if (!c) if( !c)
break; break ;
*dst++ = c;
*dst++ = c ;
} }
*dst = 0;
*dst = 0 ;
} }
/* end of util.c */

6
util.h
View File

@ -1,7 +1,9 @@
/* util.h -- utility functions */
#ifndef UTIL_H_ #ifndef UTIL_H_
#define UTIL_H_ # define UTIL_H_
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
void mystrscpy(char *dst, const char *src, int size); void mystrscpy( char *dst, const char *src, int size) ;
#endif /* UTIL_H_ */ #endif /* UTIL_H_ */
/* end of util.h */

317
window.c
View File

@ -1,77 +1,65 @@
/* window.c -- inplements window.h */ /* window.c -- inplements window.h */
#include "window.h" #include "window.h"
/* window.c /* Window management. Some of the functions are internal, and some are
* attached to keys that the user actually types.
* Window management. Some of the functions are internal, and some are
* attached to keys that the user actually types.
*
*/ */
#include <assert.h> #include <assert.h>
#include <stdio.h>
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "display.h" #include "display.h" /* upmode() */
#include "estruct.h" #include "estruct.h"
#include "execute.h" #include "execute.h"
#include "line.h" #include "line.h"
#include "mlout.h"
#include "terminal.h" #include "terminal.h"
#include "wrapper.h" #include "wrapper.h"
window_p curwp ; /* Current window */
window_p wheadp ; /* Head of list of windows */
struct window *curwp ; /* Current window */ static window_p savwindow = NULL ; /* saved window pointer */
struct window *wheadp ; /* Head of list of windows */
static struct window *swindow = NULL ; /* saved window pointer */
/* /* Reposition dot in the current window to line "n". If the argument is
* Reposition dot in the current window to line "n". If the argument is positive, it is that line. If it is negative it is that line from the
* positive, it is that line. If it is negative it is that line from the bottom. If it is 0 the window is centered (this is what the standard
* bottom. If it is 0 the window is centered (this is what the standard redisplay code does). With no argument it defaults to 0. Bound to M-!.
* redisplay code does). With no argument it defaults to 0. Bound to M-!.
*/ */
int reposition(int f, int n) TBINDABLE( reposition) {
{ curwp->w_force = (f == FALSE) ? 0 : n ; /* default to 0 to center screen */
if (f == FALSE) /* default to 0 to center screen */ curwp->w_flag |= WFFORCE ;
n = 0; return TRUE ;
curwp->w_force = n;
curwp->w_flag |= WFFORCE;
return TRUE;
} }
/*
* Refresh the screen. With no argument, it just does the refresh. With an /* Refresh the screen. With no argument, it just does the refresh. With
* argument it recenters "." in the current window. Bound to "C-L". an argument it recenters "." in the current window. Bound to "C-L".
*/ */
int redraw(int f, int n) TBINDABLE( redraw) {
{ if( f == FALSE)
if (f == FALSE) sgarbf = TRUE ;
sgarbf = TRUE;
else { else {
curwp->w_force = 0; /* Center dot. */ curwp->w_force = 0 ; /* Center dot. */
curwp->w_flag |= WFFORCE; curwp->w_flag |= WFFORCE ;
} }
return TRUE; return TRUE ;
} }
/*
* The command make the next window (next => down the screen) the current /* The command make the next window (next => down the screen) the current
* window. There are no real errors, although the command does nothing if window. There are no real errors, although the command does nothing if
* there is only 1 window on the screen. Bound to "C-X C-N". there is only 1 window on the screen. Bound to "C-X C-N".
*
* with an argument this command finds the <n>th window from the top with an argument this command finds the <n>th window from the top
*
* int f, n; default flag and numeric argument int f, n; default flag and numeric argument
*
*/ */
int nextwind(int f, int n) BINDABLE( nextwind) {
{ window_p wp;
struct window *wp;
int nwindows; /* total number of windows */ int nwindows; /* total number of windows */
if (f) { if (f) {
@ -94,10 +82,8 @@ int nextwind(int f, int n)
wp = wheadp; wp = wheadp;
while (--n) while (--n)
wp = wp->w_wndp; wp = wp->w_wndp;
} else { } else
mlwrite("Window number out of range"); return mloutfail( "Window number out of range") ;
return FALSE;
}
} else if ((wp = curwp->w_wndp) == NULL) } else if ((wp = curwp->w_wndp) == NULL)
wp = wheadp; wp = wheadp;
curwp = wp; curwp = wp;
@ -107,15 +93,14 @@ int nextwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* This command makes the previous window (previous => up the screen) the /* This command makes the previous window (previous => up the screen) the
* current window. There arn't any errors, although the command does not do a current window. There arn't any errors, although the command does not
* lot if there is 1 window. do a lot if there is 1 window.
*/ */
int prevwind(int f, int n) BINDABLE( prevwind) {
{ window_p wp1;
struct window *wp1; window_p wp2;
struct window *wp2;
/* if we have an argument, we mean the nth window from the bottom */ /* if we have an argument, we mean the nth window from the bottom */
if (f) if (f)
@ -137,28 +122,26 @@ int prevwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* This command moves the current window down by "arg" lines. Recompute the /* This command moves the current window down by "arg" lines. Recompute the
* top line in the window. The move up and move down code is almost completely * top line in the window. The move up and move down code is almost completely
* the same; most of the work has to do with reframing the window, and picking * the same; most of the work has to do with reframing the window, and picking
* a new dot. We share the code by having "move down" just be an interface to * a new dot. We share the code by having "move down" just be an interface to
* "move up". Magic. Bound to "C-X C-N". * "move up". Magic. Bound to "C-X C-N".
*/ */
int mvdnwind(int f, int n) BINDABLE( mvdnwind) {
{ return mvupwind( f, -n) ;
return mvupwind(f, -n);
} }
/*
* Move the current window up by "arg" lines. Recompute the new top line of /* Move the current window up by "arg" lines. Recompute the new top line of
* the window. Look to see if "." is still on the screen. If it is, you win. * the window. Look to see if "." is still on the screen. If it is, you win.
* If it isn't, then move "." to center it in the new framing of the window * If it isn't, then move "." to center it in the new framing of the window
* (this command does not really move "."; it moves the frame). Bound to * (this command does not really move "."; it moves the frame). Bound to
* "C-X C-P". * "C-X C-P".
*/ */
int mvupwind(int f, int n) BINDABLE( mvupwind) {
{ line_p lp;
struct line *lp;
int i; int i;
lp = curwp->w_linep; lp = curwp->w_linep;
@ -193,17 +176,16 @@ int mvupwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* This command makes the current window the only window on the screen. Bound /* This command makes the current window the only window on the screen. Bound
* to "C-X 1". Try to set the framing so that "." does not have to move on the * to "C-X 1". Try to set the framing so that "." does not have to move on the
* display. Some care has to be taken to keep the values of dot and mark in * display. Some care has to be taken to keep the values of dot and mark in
* the buffer structures right if the distruction of a window makes a buffer * the buffer structures right if the distruction of a window makes a buffer
* become undisplayed. * become undisplayed.
*/ */
int onlywind(int f, int n) BINDABLE( onlywind) {
{ window_p wp;
struct window *wp; line_p lp;
struct line *lp;
int i; int i;
while (wheadp != curwp) { while (wheadp != curwp) {
@ -241,23 +223,20 @@ int onlywind(int f, int n)
return TRUE; return TRUE;
} }
/*
* Delete the current window, placing its space in the window above, /* Delete the current window, placing its space in the window above,
* or, if it is the top window, the window below. Bound to C-X 0. * or, if it is the top window, the window below. Bound to C-X 0.
* *
* int f, n; arguments are ignored for this command * int f, n; arguments are ignored for this command
*/ */
int delwind(int f, int n) BINDABLE( delwind) {
{ window_p wp; /* window to recieve deleted space */
struct window *wp; /* window to recieve deleted space */ window_p lwp; /* ptr window before curwp */
struct window *lwp; /* ptr window before curwp */
int target; /* target line to search for */ int target; /* target line to search for */
/* if there is only one window, don't delete it */ /* if there is only one window, don't delete it */
if (wheadp->w_wndp == NULL) { if( wheadp->w_wndp == NULL)
mlwrite("Can not delete this window"); return mloutfail( "Can not delete this window") ;
return FALSE;
}
/* find window before curwp in linked list */ /* find window before curwp in linked list */
wp = wheadp; wp = wheadp;
@ -316,8 +295,8 @@ int delwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* Split the current window. A window smaller than 3 lines cannot be /* Split the current window. A window smaller than 3 lines cannot be
* split. An argument of 1 forces the cursor into the upper window, an * split. An argument of 1 forces the cursor into the upper window, an
* argument of two forces the cursor to the lower window. The only * argument of two forces the cursor to the lower window. The only
* other error that is possible is a "malloc" failure allocating the * other error that is possible is a "malloc" failure allocating the
@ -325,21 +304,21 @@ int delwind(int f, int n)
* *
* int f, n; default flag and numeric argument * int f, n; default flag and numeric argument
*/ */
int splitwind(int f, int n) BINDABLE( splitwind) {
{ window_p wp;
struct window *wp; line_p lp;
struct line *lp;
int ntru; int ntru;
int ntrl; int ntrl;
int ntrd; int ntrd;
struct window *wp1; window_p wp1;
struct window *wp2; window_p wp2;
if (curwp->w_ntrows < 3) { if( curwp->w_ntrows < 3) {
mlwrite("Cannot split a %d line window", curwp->w_ntrows); mloutfmt( "Cannot split a %d line window", curwp->w_ntrows) ;
return FALSE; return FALSE ;
} }
wp = xmalloc(sizeof(struct window));
wp = xmalloc( sizeof *wp) ;
++curbp->b_nwnd; /* Displayed twice. */ ++curbp->b_nwnd; /* Displayed twice. */
wp->w_bufp = curbp; wp->w_bufp = curbp;
wp->w_dotp = curwp->w_dotp; wp->w_dotp = curwp->w_dotp;
@ -398,33 +377,30 @@ int splitwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* Enlarge the current window. Find the window that loses space. Make sure it /* Enlarge the current window. Find the window that loses space. Make sure it
* is big enough. If so, hack the window descriptions, and ask redisplay to do * is big enough. If so, hack the window descriptions, and ask redisplay to do
* all the hard work. You don't just set "force reframe" because dot would * all the hard work. You don't just set "force reframe" because dot would
* move. Bound to "C-X Z". * move. Bound to "C-X Z".
*/ */
int enlargewind(int f, int n) BINDABLE( enlargewind) {
{ window_p adjwp;
struct window *adjwp; line_p lp;
struct line *lp;
int i; int i;
if (n < 0) if (n < 0)
return shrinkwind(f, -n); return shrinkwind(f, -n);
if (wheadp->w_wndp == NULL) { if( wheadp->w_wndp == NULL)
mlwrite("Only one window"); return mloutfail( "Only one window") ;
return FALSE;
}
if ((adjwp = curwp->w_wndp) == NULL) { if ((adjwp = curwp->w_wndp) == NULL) {
adjwp = wheadp; adjwp = wheadp;
while (adjwp->w_wndp != curwp) while (adjwp->w_wndp != curwp)
adjwp = adjwp->w_wndp; adjwp = adjwp->w_wndp;
} }
if (adjwp->w_ntrows <= n) { if( adjwp->w_ntrows <= n)
mlwrite("Impossible change"); return mloutfail( "Impossible change") ;
return FALSE;
}
if (curwp->w_wndp == adjwp) { /* Shrink below. */ if (curwp->w_wndp == adjwp) { /* Shrink below. */
lp = adjwp->w_linep; lp = adjwp->w_linep;
for (i = 0; i < n && lp != adjwp->w_bufp->b_linep; ++i) for (i = 0; i < n && lp != adjwp->w_bufp->b_linep; ++i)
@ -450,32 +426,29 @@ int enlargewind(int f, int n)
return TRUE; return TRUE;
} }
/*
* Shrink the current window. Find the window that gains space. Hack at the /* Shrink the current window. Find the window that gains space. Hack at the
* window descriptions. Ask the redisplay to do all the hard work. Bound to * window descriptions. Ask the redisplay to do all the hard work. Bound to
* "C-X C-Z". * "C-X C-Z".
*/ */
int shrinkwind(int f, int n) BINDABLE( shrinkwind) {
{ window_p adjwp;
struct window *adjwp; line_p lp;
struct line *lp;
int i; int i;
if (n < 0) if (n < 0)
return enlargewind(f, -n); return enlargewind(f, -n);
if (wheadp->w_wndp == NULL) { if( wheadp->w_wndp == NULL)
mlwrite("Only one window"); return mloutfail( "Only one window") ;
return FALSE;
}
if ((adjwp = curwp->w_wndp) == NULL) { if ((adjwp = curwp->w_wndp) == NULL) {
adjwp = wheadp; adjwp = wheadp;
while (adjwp->w_wndp != curwp) while (adjwp->w_wndp != curwp)
adjwp = adjwp->w_wndp; adjwp = adjwp->w_wndp;
} }
if (curwp->w_ntrows <= n) { if( curwp->w_ntrows <= n)
mlwrite("Impossible change"); return mloutfail( "Impossible change") ;
return FALSE;
}
if (curwp->w_wndp == adjwp) { /* Grow below. */ if (curwp->w_wndp == adjwp) { /* Grow below. */
lp = adjwp->w_linep; lp = adjwp->w_linep;
for (i = 0; i < n && lback(lp) != adjwp->w_bufp->b_linep; for (i = 0; i < n && lback(lp) != adjwp->w_bufp->b_linep;
@ -502,13 +475,12 @@ int shrinkwind(int f, int n)
return TRUE; return TRUE;
} }
/*
* Resize the current window to the requested size /* Resize the current window to the requested size
* *
* int f, n; default flag and numeric argument * int f, n; default flag and numeric argument
*/ */
int resize(int f, int n) BINDABLE( resize) {
{
int clines; /* current # of lines in window */ int clines; /* current # of lines in window */
/* must have a non-default argument, else ignore call */ /* must have a non-default argument, else ignore call */
@ -525,14 +497,14 @@ int resize(int f, int n)
return enlargewind(TRUE, n - clines); return enlargewind(TRUE, n - clines);
} }
/*
* Pick a window for a pop-up. Split the screen if there is only one window. /* Pick a window for a pop-up. Split the screen if there is only one window.
* Pick the uppermost window that isn't the current window. An LRU algorithm * Pick the uppermost window that isn't the current window. An LRU algorithm
* might be better. Return a pointer, or NULL on error. * might be better. Return a pointer, or NULL on error.
*/ */
struct window *wpopup(void) window_p wpopup(void)
{ {
struct window *wp; window_p wp;
if (wheadp->w_wndp == NULL /* Only 1 window */ if (wheadp->w_wndp == NULL /* Only 1 window */
&& splitwind(FALSE, 0) == FALSE) /* and it won't split */ && splitwind(FALSE, 0) == FALSE) /* and it won't split */
@ -543,59 +515,57 @@ struct window *wpopup(void)
return wp; return wp;
} }
int scrnextup(int f, int n)
{ /* scroll the next window up (back) a page */ /* scroll the next window up (back) a page */
BINDABLE( scrnextup) {
nextwind(FALSE, 1); nextwind(FALSE, 1);
backpage(f, n); backpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
return TRUE; return TRUE;
} }
int scrnextdw(int f, int n)
{ /* scroll the next window down (forward) a page */ /* scroll the next window down (forward) a page */
BINDABLE( scrnextdw) {
nextwind(FALSE, 1); nextwind(FALSE, 1);
forwpage(f, n); forwpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
return TRUE; return TRUE;
} }
int savewnd(int f, int n)
{ /* save ptr to current window */ /* save ptr to current window */
swindow = curwp; BINDABLE( savewnd) {
return TRUE; savwindow = curwp ;
return TRUE ;
} }
int restwnd(int f, int n)
{ /* restore the saved screen */
struct window *wp;
/* find the window */ /* restore the saved screen */
wp = wheadp; BINDABLE( restwnd) {
while (wp != NULL) { /* check the saved window still exists */
if (wp == swindow) { for( window_p wp = wheadp ; wp != NULL ; wp = wp->w_wndp) {
curwp = wp; if( wp == savwindow) {
curbp = wp->w_bufp; curwp = wp ;
upmode(); curbp = wp->w_bufp ;
return TRUE; upmode() ;
return TRUE ;
} }
wp = wp->w_wndp;
} }
mlwrite("(No such window exists)"); return mloutfail( "(No such window exists)") ;
return FALSE;
} }
/*
* resize the screen, re-writing the screen /* resize the screen, re-writing the screen
* *
* int f; default flag * int f; default flag
* int n; numeric argument * int n; numeric argument
*/ */
int newsize(int f, int n) BINDABLE( newsize) {
{ window_p wp; /* current window being examined */
struct window *wp; /* current window being examined */ window_p nextwp; /* next window to scan */
struct window *nextwp; /* next window to scan */ window_p lastwp; /* last window scanned */
struct window *lastwp; /* last window scanned */
int lastline; /* screen line of last line of current window */ int lastline; /* screen line of last line of current window */
/* if the command defaults, assume the largest */ /* if the command defaults, assume the largest */
@ -603,10 +573,8 @@ int newsize(int f, int n)
n = term.t_mrow ; n = term.t_mrow ;
/* make sure it's in range */ /* make sure it's in range */
if (n < 3 || n > term.t_mrow) { if( n < 3 || n > term.t_mrow)
mlwrite("%%Screen size out of range"); return mloutfail( "%%Screen size out of range") ;
return FALSE;
}
if (term.t_nrow == n - 1) if (term.t_nrow == n - 1)
return TRUE; return TRUE;
@ -674,25 +642,22 @@ int newsize(int f, int n)
return TRUE; return TRUE;
} }
/*
* resize the screen, re-writing the screen /* resize the screen, re-writing the screen
* *
* int f; default flag * int f; default flag
* int n; numeric argument * int n; numeric argument
*/ */
int newwidth(int f, int n) BINDABLE( newwidth) {
{ window_p wp;
struct window *wp;
/* if the command defaults, assume the largest */ /* if the command defaults, assume the largest */
if (f == FALSE) if (f == FALSE)
n = term.t_mcol; n = term.t_mcol;
/* make sure it's in range */ /* make sure it's in range */
if (n < 10 || n > term.t_mcol) { if (n < 10 || n > term.t_mcol)
mlwrite("%%Screen width out of range"); return mloutfail( "%%Screen width out of range") ;
return FALSE;
}
/* otherwise, just re-width it (no big deal) */ /* otherwise, just re-width it (no big deal) */
term.t_ncol = n; term.t_ncol = n;
@ -713,7 +678,7 @@ int newwidth(int f, int n)
int getwpos(void) int getwpos(void)
{ /* get screen offset of current line in current window */ { /* get screen offset of current line in current window */
int sline; /* screen line from top of window */ int sline; /* screen line from top of window */
struct line *lp; /* scannile line pointer */ line_p lp; /* scannile line pointer */
/* search down the line we want */ /* search down the line we want */
lp = curwp->w_linep; lp = curwp->w_linep;
@ -731,3 +696,5 @@ void cknewwindow(void)
{ {
execute(META | SPEC | 'X', FALSE, 1); execute(META | SPEC | 'X', FALSE, 1);
} }
/* end of window.c */

View File

@ -1,34 +1,35 @@
/* window.h -- window functionality */
#ifndef _WINDOW_H_ #ifndef _WINDOW_H_
#define _WINDOW_H_ #define _WINDOW_H_
#include "defines.h" /* COLOR, SCROLLCODE */ #include "defines.h" /* COLOR, SCROLLCODE */
#include "buffer.h" /* buffer, line */ #include "buffer.h" /* buffer_p, line_p */
#include "names.h" /* BINDABLE() */
/* /* There is a window structure allocated for every active display window.
* There is a window structure allocated for every active display window. The The windows are kept in a big list, in top to bottom screen order, with
* windows are kept in a big list, in top to bottom screen order, with the the listhead at "wheadp". Each window contains its own values of dot
* listhead at "wheadp". Each window contains its own values of dot and mark. and mark. The flag field contains some bits that are set by commands to
* The flag field contains some bits that are set by commands to guide guide redisplay. Although this is a bit of a compromise in terms of
* redisplay. Although this is a bit of a compromise in terms of decoupling, decoupling, the full blown redisplay is just too expensive to run for
* the full blown redisplay is just too expensive to run for every input every input character.
* character.
*/ */
typedef struct window { typedef struct window {
struct window *w_wndp; /* Next window */ struct window *w_wndp; /* Next window */
struct buffer *w_bufp; /* Buffer displayed in window */ buffer_p w_bufp ; /* Buffer displayed in window */
line_p w_linep ; /* Top line in the window */ line_p w_linep ; /* Top line in the window */
line_p w_dotp ; /* Line containing "." */ line_p w_dotp ; /* Line containing "." */
line_p w_markp ; /* Line containing "mark" */ line_p w_markp ; /* Line containing "mark" */
int w_doto ; /* Byte offset for "." */ int w_doto ; /* Byte offset for "." */
int w_marko; /* Byte offset for "mark" */ int w_marko ; /* Byte offset for "mark" */
int w_toprow ; /* Origin 0 top row of window */ int w_toprow ; /* Origin 0 top row of window */
int w_ntrows ; /* # of rows of text in window */ int w_ntrows ; /* # of rows of text in window */
char w_force; /* If NZ, forcing row. */ char w_force ; /* If NZ, forcing row. */
char w_flag; /* Flags. */ char w_flag ; /* Flags. */
#if COLOR # if COLOR
char w_fcolor; /* current forground color */ char w_fcolor ; /* current forground color */
char w_bcolor; /* current background color */ char w_bcolor ; /* current background color */
#endif # endif
} *window_p ; } *window_p ;
extern window_p curwp ; /* Current window */ extern window_p curwp ; /* Current window */
@ -44,31 +45,34 @@ extern window_p wheadp ; /* Head of list of windows */
#define WFMODE 0x10 /* Update mode line. */ #define WFMODE 0x10 /* Update mode line. */
#define WFCOLR 0x20 /* Needs a color change */ #define WFCOLR 0x20 /* Needs a color change */
#if SCROLLCODE # if SCROLLCODE
#define WFKILLS 0x40 /* something was deleted */ # define WFKILLS 0x40 /* something was deleted */
#define WFINS 0x80 /* something was inserted */ # define WFINS 0x80 /* something was inserted */
#endif # endif
/* Bindable functions */
BINDABLE( delwind) ;
BINDABLE( enlargewind) ;
BINDABLE( mvdnwind) ;
BINDABLE( mvupwind) ;
BINDABLE( newsize) ;
BINDABLE( newwidth) ;
BINDABLE( nextwind) ;
BINDABLE( onlywind) ;
BINDABLE( prevwind) ;
TBINDABLE( redraw) ;
TBINDABLE( reposition) ;
BINDABLE( resize) ;
BINDABLE( restwnd) ;
BINDABLE( savewnd) ;
BINDABLE( scrnextdw) ;
BINDABLE( scrnextup) ;
BINDABLE( shrinkwind) ;
BINDABLE( splitwind) ;
int reposition( int f, int n);
int redraw( int f, int n) ;
int nextwind( int f, int n) ;
int prevwind( int f, int n) ;
int mvdnwind( int f, int n) ;
int mvupwind( int f, int n) ;
int onlywind( int f, int n) ;
int delwind( int f, int n) ;
int splitwind( int f, int n) ;
int enlargewind( int f, int n) ;
int shrinkwind( int f, int n) ;
int resize( int f, int n) ;
int scrnextup( int f, int n) ;
int scrnextdw( int f, int n) ;
int savewnd( int f, int n) ;
int restwnd( int f, int n) ;
int newsize( int f, int n) ;
int newwidth( int f, int n) ;
int getwpos( void) ; int getwpos( void) ;
void cknewwindow( void) ; void cknewwindow( void) ;
window_p wpopup( void) ; /* Pop up window creation. */ window_p wpopup( void) ; /* Pop up window creation. */
#endif #endif
/* end of window.h */

160
word.c
View File

@ -1,13 +1,11 @@
/* word.c -- implements word.h */ /* word.c -- implements word.h */
#include "word.h" #include "word.h"
/* word.c /* The routines in this file implement commands that work word or a
* paragraph at a time. There are all sorts of word mode commands. If I
* The routines in this file implement commands that work word or a do any sentence mode commands, they are likely to be put in this file.
* paragraph at a time. There are all sorts of word mode commands. If I
* do any sentence mode commands, they are likely to be put in this file. Modified by Petri Kutvonen
*
* Modified by Petri Kutvonen
*/ */
#include <assert.h> #include <assert.h>
@ -31,18 +29,18 @@ static int justflag = FALSE ; /* justify, don't fill */
static int inword( void) ; static int inword( void) ;
/* Word wrap on n-spaces. Back-over whatever precedes the point on the current /* Word wrap on n-spaces. Back-over whatever precedes the point on the
* line and stop on the first word-break or the beginning of the line. If we current line and stop on the first word-break or the beginning of the
* reach the beginning of the line, jump back to the end of the word and start line. If we reach the beginning of the line, jump back to the end of
* a new line. Otherwise, break the line at the word-break, eat it, and jump the word and start a new line. Otherwise, break the line at the
* back to the end of the word. word-break, eat it, and jump back to the end of the word.
* Returns TRUE on success, FALSE on errors.
* Returns TRUE on success, FALSE on errors.
* @f: default flag.
* @n: numeric argument. @f: default flag.
@n: numeric argument.
*/ */
int wrapword(int f, int n) BINDABLE( wrapword) {
{
int cnt; /* size of word wrapped to next line */ int cnt; /* size of word wrapped to next line */
int c; /* charector temporary */ int c; /* charector temporary */
@ -81,11 +79,12 @@ int wrapword(int f, int n)
return TRUE; return TRUE;
} }
/* Move the cursor backward by "n" words. All of the details of motion are
* performed by the "backchar" and "forwchar" routines. Error if you try to /* Move the cursor backward by "n" words. All of the details of motion are
* move beyond the buffers. performed by the "backchar" and "forwchar" routines. Error if you try
to move beyond the buffers.
*/ */
int backword( int f, int n) { BINDABLE( backword) {
if( n < 0) if( n < 0)
return forwword( f, -n) ; return forwword( f, -n) ;
@ -106,10 +105,12 @@ int backword( int f, int n) {
return forwchar( FALSE, 1) ; return forwchar( FALSE, 1) ;
} }
/* Move the cursor forward by the specified number of words. All of the motion
* is done by "forwchar". Error if you try and move beyond the buffer's end. /* Move the cursor forward by the specified number of words. All of the
motion is done by "forwchar". Error if you try and move beyond the
buffer's end.
*/ */
int forwword( int f, int n) { BINDABLE( forwword) {
if( n < 0) if( n < 0)
return backword( f, -n) ; return backword( f, -n) ;
@ -172,40 +173,41 @@ static boolean capcapword( int n, boolean first_f, boolean rest_f) {
return TRUE ; return TRUE ;
} }
/* Move the cursor forward by the specified number of words. As you move,
* convert any characters to upper case. Error if you try and move beyond the /* Move the cursor forward by the specified number of words. As you move,
* end of the buffer. Bound to "M-U". convert any characters to upper case. Error if you try and move beyond
the end of the buffer. Bound to "M-U".
*/ */
int upperword( int f, int n) { BINDABLE( upperword) {
return capcapword( n, TRUE, TRUE) ; return capcapword( n, TRUE, TRUE) ;
} }
/* Move the cursor forward by the specified number of words. As you move /* Move the cursor forward by the specified number of words. As you move
* convert characters to lower case. Error if you try and move over the end of convert characters to lower case. Error if you try and move over the
* the buffer. Bound to "M-L". end of the buffer. Bound to "M-L".
*/ */
int lowerword( int f, int n) { BINDABLE( lowerword) {
return capcapword( n, FALSE, FALSE) ; return capcapword( n, FALSE, FALSE) ;
} }
/* Move the cursor forward by the specified number of words. As you move
* convert the first character of the word to upper case, and subsequent /* Move the cursor forward by the specified number of words. As you move
* characters to lower case. Error if you try and move past the end of the convert the first character of the word to upper case, and subsequent
* buffer. Bound to "M-C". characters to lower case. Error if you try and move past the end of the
buffer. Bound to "M-C".
*/ */
int capword( int f, int n) { BINDABLE( capword) {
return capcapword( n, TRUE, FALSE) ; return capcapword( n, TRUE, FALSE) ;
} }
/*
* Kill forward by "n" words. Remember the location of dot. Move forward by /* Kill forward by "n" words. Remember the location of dot. Move forward
* the right number of words. Put dot back where it was and issue the kill by the right number of words. Put dot back where it was and issue the
* command for the right number of characters. With a zero argument, just kill command for the right number of characters. With a zero argument,
* kill one word and no whitespace. Bound to "M-D". just kill one word and no whitespace. Bound to "M-D".
*/ */
int delfword(int f, int n) BINDABLE( delfword) {
{
line_p dotp; /* original cursor line */ line_p dotp; /* original cursor line */
int doto; /* and row */ int doto; /* and row */
int c; /* temp char */ int c; /* temp char */
@ -285,13 +287,13 @@ int delfword(int f, int n)
return ldelete(size, TRUE); return ldelete(size, TRUE);
} }
/*
* Kill backwards by "n" words. Move backwards by the desired number of words, /* Kill backwards by "n" words. Move backwards by the desired number of
* counting the characters. When dot is finally moved to its resting place, words, counting the characters. When dot is finally moved to its
* fire off the kill command. Bound to "M-Rubout" and to "M-Backspace". resting place, fire off the kill command. Bound to "M-Rubout" and to
"M-Backspace".
*/ */
int delbword(int f, int n) BINDABLE( delbword) {
{
assert( !(curbp->b_mode & MDVIEW)) ; assert( !(curbp->b_mode & MDVIEW)) ;
/* ignore the command if there is a nonpositive argument */ /* ignore the command if there is a nonpositive argument */
@ -352,17 +354,13 @@ static int parafillnjustify( int f, int n, int justify_f) {
assert( !(curbp->b_mode & MDVIEW)) ; assert( !(curbp->b_mode & MDVIEW)) ;
if (fillcol == 0) { /* no fill column set */ if( fillcol == 0) /* no fill column set */
mloutstr( "No fill column set") ; return mloutfail( "No fill column set") ;
return FALSE;
}
if( justify_f) { if( justify_f) {
leftmarg = getccol( FALSE) ; leftmarg = getccol( FALSE) ;
if (leftmarg + 10 > fillcol) { if( leftmarg + 10 > fillcol)
mloutstr( "Column too narrow") ; return mloutfail( "Column too narrow") ;
return FALSE;
}
justflag = justify_f ; justflag = justify_f ;
} }
@ -472,33 +470,33 @@ static int parafillnjustify( int f, int n, int justify_f) {
return TRUE; return TRUE;
} }
/*
* Fill the current paragraph according to the current /* Fill the current paragraph according to the current
* fill column * fill column
* *
* f and n - deFault flag and Numeric argument * f and n - deFault flag and Numeric argument
*/ */
int fillpara( int f, int n) { BINDABLE( fillpara) {
return parafillnjustify( f, n, FALSE) ; return parafillnjustify( f, n, FALSE) ;
} }
/* Fill the current paragraph according to the current /* Fill the current paragraph according to the current
* fill column and cursor position * fill column and cursor position
* *
* int f, n; deFault flag and Numeric argument * int f, n; deFault flag and Numeric argument
*/ */
int justpara( int f, int n) { BINDABLE( justpara) {
return parafillnjustify( f, n, TRUE) ; return parafillnjustify( f, n, TRUE) ;
} }
/*
* delete n paragraphs starting with the current one /* delete n paragraphs starting with the current one
* *
* int f default flag * int f default flag
* int n # of paras to delete * int n # of paras to delete
*/ */
int killpara(int f, int n) BINDABLE( killpara) {
{
while (n--) { /* for each paragraph to delete */ while (n--) { /* for each paragraph to delete */
/* mark out the end and beginning of the para to delete */ /* mark out the end and beginning of the para to delete */
@ -525,15 +523,13 @@ int killpara(int f, int n)
} }
/* /* wordcount: count the # of words in the marked region,
* wordcount: count the # of words in the marked region,
* along with average word sizes, # of chars, etc, * along with average word sizes, # of chars, etc,
* and report on them. * and report on them.
* *
* int f, n; ignored numeric arguments * int f, n; ignored numeric arguments
*/ */
int wordcount(int f, int n) BINDABLE( wordcount) {
{
line_p lp; /* current line to scan */ line_p lp; /* current line to scan */
int offset; /* current char to scan */ int offset; /* current char to scan */
long size; /* size of region left to count */ long size; /* size of region left to count */
@ -591,15 +587,14 @@ int wordcount(int f, int n)
return TRUE; return TRUE;
} }
/*
* go back to the beginning of the current paragraph /* go back to the beginning of the current paragraph
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE> * here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
* combination to delimit the beginning of a paragraph * combination to delimit the beginning of a paragraph
* *
* int f, n; default Flag & Numeric argument * int f, n; default Flag & Numeric argument
*/ */
int gotobop(int f, int n) BINDABLE( gotobop) {
{
if (n < 0) /* the other way... */ if (n < 0) /* the other way... */
return gotoeop(f, -n); return gotoeop(f, -n);
@ -629,15 +624,14 @@ int gotobop(int f, int n)
return TRUE; return TRUE;
} }
/*
* Go forward to the end of the current paragraph /* Go forward to the end of the current paragraph here we look for a
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE> <NL><NL> or <NL><TAB> or <NL><SPACE> combination to delimit the
* combination to delimit the beginning of a paragraph beginning of a paragraph
*
* int f, n; default Flag & Numeric argument int f, n; default Flag & Numeric argument
*/ */
int gotoeop(int f, int n) BINDABLE( gotoeop) {
{
if (n < 0) /* the other way... */ if (n < 0) /* the other way... */
return gotobop(f, -n); return gotobop(f, -n);