mirror of https://github.com/rfivet/uemacs.git
Revise bindable functions usage of struct to named types.
This commit is contained in:
parent
7730a4e730
commit
d890880a52
|
@ -78,7 +78,7 @@ static int insbrace( int n, int c) {
|
||||||
|
|
||||||
count = 1 ;
|
count = 1 ;
|
||||||
do {
|
do {
|
||||||
if( boundry( curwp->w_dotp, curwp->w_doto, REVERSE)) {
|
if( boundary( curwp->w_dotp, curwp->w_doto, REVERSE)) {
|
||||||
/* at beginning of buffer, no match to be found */
|
/* at beginning of buffer, no match to be found */
|
||||||
curwp->w_dotp = oldlp ;
|
curwp->w_dotp = oldlp ;
|
||||||
curwp->w_doto = oldoff ;
|
curwp->w_doto = oldoff ;
|
||||||
|
@ -166,7 +166,7 @@ static void fmatch( int ch) {
|
||||||
do {
|
do {
|
||||||
/* At beginning of window or buffer, no match to be found */
|
/* At beginning of window or buffer, no match to be found */
|
||||||
if( curwp->w_dotp == toplp
|
if( curwp->w_dotp == toplp
|
||||||
|| boundry( curwp->w_dotp, curwp->w_doto, REVERSE))
|
|| boundary( curwp->w_dotp, curwp->w_doto, REVERSE))
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
backchar( FALSE, 1) ;
|
backchar( FALSE, 1) ;
|
||||||
|
@ -261,7 +261,7 @@ BINDABLE( getfence) {
|
||||||
/* scan until we find a match, or reach the end of file */
|
/* scan until we find a match, or reach the end of file */
|
||||||
count = 1 ;
|
count = 1 ;
|
||||||
do {
|
do {
|
||||||
if( boundry( curwp->w_dotp, curwp->w_doto, sdir)) {
|
if( boundary( curwp->w_dotp, curwp->w_doto, sdir)) {
|
||||||
/* at buffer limit, no match to be found */
|
/* at buffer limit, no match to be found */
|
||||||
/* restore the current position */
|
/* restore the current position */
|
||||||
curwp->w_dotp = oldlp ;
|
curwp->w_dotp = oldlp ;
|
||||||
|
|
130
file.c
130
file.c
|
@ -1,5 +1,4 @@
|
||||||
/* file.c -- implements file.h */
|
/* file.c -- implements file.h */
|
||||||
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
/* file.c
|
/* file.c
|
||||||
|
@ -65,21 +64,17 @@ boolean resterr( void) {
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Read a file into the current buffer. This is really easy; all you do is
|
||||||
* Read a file into the current
|
* find the name of the file, and call the standard "read a file into the
|
||||||
* buffer. This is really easy; all you do is
|
* current buffer" code. Bound to C-X C-R read-file.
|
||||||
* find the name of the file, and call the standard
|
|
||||||
* "read a file into the current buffer" code.
|
|
||||||
* Bound to "C-X C-R".
|
|
||||||
*/
|
*/
|
||||||
int fileread( int f, int n) {
|
BINDABLE( fileread) {
|
||||||
int status ;
|
|
||||||
char *fname ;
|
char *fname ;
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "Read file: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "read-file: ", sizeof( fname_t)) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
status = readin( fname, TRUE) ;
|
status = readin( fname, TRUE) ;
|
||||||
free( fname) ;
|
free( fname) ;
|
||||||
|
@ -88,25 +83,19 @@ int fileread( int f, int n) {
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Insert a file into the current buffer. This is really easy; all you do
|
||||||
* Insert a file into the current
|
* is find the name of the file, and call the standard "insert a file into
|
||||||
* buffer. This is really easy; all you do is
|
* the current buffer" code. Bound to C-X C-I insert-file.
|
||||||
* find the name of the file, and call the standard
|
|
||||||
* "insert a file into the current buffer" code.
|
|
||||||
* Bound to "C-X C-I".
|
|
||||||
*/
|
*/
|
||||||
int insfile( int f, int n) {
|
BINDABLE( insfile) {
|
||||||
int status ;
|
|
||||||
char *fname ;
|
char *fname ;
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "Insert file: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "insert-file: ", sizeof( fname_t)) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
status = ifile( fname) ;
|
status = ifile( fname) ;
|
||||||
free( fname) ;
|
free( fname) ;
|
||||||
|
@ -118,23 +107,18 @@ int insfile( int f, int n) {
|
||||||
return reposition( TRUE, -1) ; /* Redraw with dot at bottom of window */
|
return reposition( TRUE, -1) ; /* Redraw with dot at bottom of window */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Select a file for editing. Look around to see if you can find the file
|
||||||
* Select a file for editing.
|
* in another buffer; if you can find it just switch to the buffer. If you
|
||||||
* Look around to see if you can find the
|
* cannot find the file, create a new buffer, read in the text, and switch
|
||||||
* file in another buffer; if you can find it
|
* to the new buffer. Bound to C-X C-F find-file.
|
||||||
* just switch to the buffer. If you cannot find
|
|
||||||
* the file, create a new buffer, read in the
|
|
||||||
* text, and switch to the new buffer.
|
|
||||||
* Bound to C-X C-F.
|
|
||||||
*/
|
*/
|
||||||
int filefind( int f, int n) {
|
BINDABLE( filefind) {
|
||||||
char *fname ; /* file user wishes to find */
|
char *fname ; /* file user wishes to find */
|
||||||
int status ; /* status return */
|
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "find-file: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "find-file: ", sizeof( fname_t)) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
status = getfile( fname, TRUE) ;
|
status = getfile( fname, TRUE) ;
|
||||||
free( fname) ;
|
free( fname) ;
|
||||||
|
@ -152,16 +136,15 @@ static void upd_mode( void) {
|
||||||
wp->w_flag |= WFMODE ;
|
wp->w_flag |= WFMODE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int viewfile( int f, int n) { /* visit a file in VIEW mode */
|
BINDABLE( viewfile) { /* visit a file in VIEW mode */
|
||||||
char *fname ; /* file user wishes to find */
|
char *fname ; /* file user wishes to find */
|
||||||
int status ; /* status return */
|
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "View file: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "view-file: ", sizeof( fname_t)) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
status = getfile(fname, FALSE) ;
|
status = getfile( fname, FALSE) ;
|
||||||
free( fname) ;
|
free( fname) ;
|
||||||
|
|
||||||
if( status == TRUE) { /* if we succeed, put it in view mode */
|
if( status == TRUE) { /* if we succeed, put it in view mode */
|
||||||
|
@ -180,7 +163,7 @@ int viewfile( int f, int n) { /* visit a file in VIEW mode */
|
||||||
* boolean lockfl; check the file for locks?
|
* boolean lockfl; check the file for locks?
|
||||||
*/
|
*/
|
||||||
int getfile( const char *fname, boolean lockfl) {
|
int getfile( const char *fname, boolean lockfl) {
|
||||||
struct buffer *bp;
|
buffer_p bp;
|
||||||
int s;
|
int s;
|
||||||
bname_t bname ; /* buffer name to put file */
|
bname_t bname ; /* buffer name to put file */
|
||||||
|
|
||||||
|
@ -264,7 +247,7 @@ int getfile( const char *fname, boolean lockfl) {
|
||||||
int readin(const char *fname, boolean lockfl)
|
int readin(const char *fname, boolean lockfl)
|
||||||
{
|
{
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
struct buffer *bp;
|
buffer_p bp;
|
||||||
int status ;
|
int status ;
|
||||||
fio_code s ;
|
fio_code s ;
|
||||||
|
|
||||||
|
@ -437,23 +420,17 @@ void unqname(char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Ask for a file name, and write the content of the current buffer to that
|
||||||
* Ask for a file name, and write the
|
* file. Update the remembered file name and clear the buffer changed
|
||||||
* contents of the current buffer to that file.
|
* flag. Bound to C-X C-W write-file.
|
||||||
* Update the remembered file name and clear the
|
|
||||||
* buffer changed flag. This handling of file names
|
|
||||||
* is different from the earlier versions, and
|
|
||||||
* is more compatible with Gosling EMACS than
|
|
||||||
* with ITS EMACS. Bound to "C-X C-W".
|
|
||||||
*/
|
*/
|
||||||
int filewrite( int f, int n) {
|
BINDABLE( filewrite) {
|
||||||
int status ;
|
|
||||||
char *fname ;
|
char *fname ;
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "Write file: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "write-file: ", sizeof( fname_t)) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
if( strlen( fname) > sizeof( fname_t) - 1)
|
if( strlen( fname) > sizeof( fname_t) - 1)
|
||||||
status = FALSE ;
|
status = FALSE ;
|
||||||
|
@ -469,32 +446,27 @@ int filewrite( int f, int n) {
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Save the content of the current buffer in its associated file. Do
|
||||||
* Save the contents of the current
|
* nothing if nothing has changed (this may be a bug, not a feature).
|
||||||
* buffer in its associated file. Do nothing
|
* Error if there is no remembered file name for the buffer. Bound to "C-X
|
||||||
* if nothing has changed (this may be a bug, not a
|
* C-S save-file". May get called by "M-Z quick-exit".
|
||||||
* feature). Error if there is no remembered file
|
|
||||||
* name for the buffer. Bound to "C-X C-S". May
|
|
||||||
* get called by "C-Z".
|
|
||||||
*/
|
*/
|
||||||
int filesave( int f, int n) {
|
BINDABLE( filesave) {
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
|
if( (curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
|
||||||
return TRUE;
|
return TRUE ;
|
||||||
if (curbp->b_fname[0] == 0) { /* Must have a name. */
|
|
||||||
mloutstr( "No file name") ;
|
if( curbp->b_fname[0] == 0) { /* Must have a name. */
|
||||||
return FALSE;
|
mloutfmt( "%BNo file name") ;
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complain about truncated files */
|
/* complain about truncated files */
|
||||||
if ((curbp->b_flag & BFTRUNC) != 0) {
|
if( (curbp->b_flag & BFTRUNC) != 0
|
||||||
if (mlyesno("Truncated file ... write it out") == FALSE) {
|
&& mlyesno("Truncated file ... write it out") == FALSE) {
|
||||||
mloutstr( "(Aborted)") ;
|
mloutfmt( "%B(Aborted)") ;
|
||||||
return FALSE;
|
return FALSE ;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return writeout( curbp->b_fname) ;
|
return writeout( curbp->b_fname) ;
|
||||||
|
@ -544,23 +516,19 @@ int writeout( const char *fn) {
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* The command allows the user to modify the file name associated with the
|
||||||
* The command allows the user
|
current buffer. It is like the "f" command in UNIX "ed". The operation
|
||||||
* to modify the file name associated with
|
is simple; just zap the name in the buffer structure, and mark the
|
||||||
* the current buffer. It is like the "f" command
|
windows as needing an update. You can type a blank line at the prompt
|
||||||
* in UNIX "ed". The operation is simple; just zap
|
if you wish. Bound to C-X N change-file-name.
|
||||||
* the name in the buffer structure, and mark the windows
|
|
||||||
* as needing an update. You can type a blank line at the
|
|
||||||
* prompt if you wish.
|
|
||||||
*/
|
*/
|
||||||
int filename( int f, int n) {
|
BINDABLE( filename) {
|
||||||
int status ;
|
|
||||||
char *fname ;
|
char *fname ;
|
||||||
|
|
||||||
if( restflag) /* don't allow this command if restricted */
|
if( restflag) /* don't allow this command if restricted */
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
status = newmlarg( &fname, "Name: ", sizeof( fname_t)) ;
|
int status = newmlarg( &fname, "Name: ", sizeof( fname_t)) ;
|
||||||
if( status == ABORT)
|
if( status == ABORT)
|
||||||
return status ;
|
return status ;
|
||||||
else if( status == FALSE)
|
else if( status == FALSE)
|
||||||
|
@ -653,3 +621,5 @@ static int ifile( const char *fname) {
|
||||||
|
|
||||||
return (s == FIOERR) ? FALSE : TRUE ;
|
return (s == FIOERR) ? FALSE : TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* end of file.c */
|
||||||
|
|
22
file.h
22
file.h
|
@ -1,23 +1,29 @@
|
||||||
|
/* file.h -- file centric commands */
|
||||||
|
|
||||||
#ifndef _FILE_H_
|
#ifndef _FILE_H_
|
||||||
#define _FILE_H_
|
#define _FILE_H_
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "retcode.h"
|
#include "names.h"
|
||||||
|
|
||||||
extern boolean restflag ; /* restricted use? */
|
extern boolean restflag ; /* restricted use? */
|
||||||
boolean resterr( void) ; /* restricted error message */
|
boolean resterr( void) ; /* restricted error message */
|
||||||
|
|
||||||
int fileread( int f, int n) ;
|
/* Bindable functions */
|
||||||
int insfile( int f, int n) ;
|
BINDABLE( filefind) ;
|
||||||
int filefind( int f, int n) ;
|
BINDABLE( fileread) ;
|
||||||
int viewfile( int f, int n) ;
|
BINDABLE( filename) ;
|
||||||
|
BINDABLE( filesave) ;
|
||||||
|
BINDABLE( filewrite) ;
|
||||||
|
BINDABLE( insfile) ;
|
||||||
|
BINDABLE( viewfile) ;
|
||||||
|
|
||||||
int getfile( const char *fname, boolean lockfl) ;
|
int getfile( const char *fname, boolean lockfl) ;
|
||||||
int readin( const char *fname, boolean lockfl) ;
|
int readin( const char *fname, boolean lockfl) ;
|
||||||
void makename( bname_t bname, const char *fname) ;
|
void makename( bname_t bname, const char *fname) ;
|
||||||
void unqname( char *name) ;
|
void unqname( char *name) ;
|
||||||
int filewrite( int f, int n) ;
|
|
||||||
int filesave( int f, int n) ;
|
|
||||||
int writeout( const char *fn) ;
|
int writeout( const char *fn) ;
|
||||||
int filename( int f, int n) ;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of file.h */
|
||||||
|
|
169
line.c
169
line.c
|
@ -1,6 +1,7 @@
|
||||||
/* line.c
|
/* line.c -- implements line.h */
|
||||||
*
|
#include "line.h"
|
||||||
* The functions in this file are a general set of line management utilities.
|
|
||||||
|
/* The functions in this file are a general set of line management utilities.
|
||||||
* They are the only routines that touch the text. They also touch the buffer
|
* They are the only routines that touch the text. They also touch the buffer
|
||||||
* and window structures, to make sure that the necessary updating gets done.
|
* and window structures, to make sure that the necessary updating gets done.
|
||||||
* There are routines in this file that handle the kill buffer too. It isn't
|
* There are routines in this file that handle the kill buffer too. It isn't
|
||||||
|
@ -13,12 +14,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "line.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h> /* NULL, offsetof() */
|
||||||
#include <stdio.h>
|
#include <stdlib.h> /* malloc(), free() */
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
@ -41,13 +39,13 @@ static int ldelnewline( void) ;
|
||||||
|
|
||||||
#define KBLOCK 250 /* sizeof kill buffer chunks */
|
#define KBLOCK 250 /* sizeof kill buffer chunks */
|
||||||
|
|
||||||
struct kill {
|
typedef struct kill {
|
||||||
struct kill *d_next; /* Link to next chunk, NULL if last. */
|
struct kill *d_next; /* Link to next chunk, NULL if last. */
|
||||||
char d_chunk[KBLOCK]; /* Deleted text. */
|
char d_chunk[KBLOCK]; /* Deleted text. */
|
||||||
};
|
} *kill_p ;
|
||||||
|
|
||||||
static struct kill *kbufp = NULL ; /* current kill buffer chunk pointer */
|
static kill_p kbufp = NULL ; /* current kill buffer chunk pointer */
|
||||||
static struct kill *kbufh = NULL ; /* kill buffer header pointer */
|
static kill_p kbufh = NULL ; /* kill buffer header pointer */
|
||||||
static int kused = KBLOCK ; /* # of bytes used in kill buffer */
|
static int kused = KBLOCK ; /* # of bytes used in kill buffer */
|
||||||
static int klen ; /* length of kill buffer content */
|
static int klen ; /* length of kill buffer content */
|
||||||
static char *value = NULL ; /* temp buffer for value */
|
static char *value = NULL ; /* temp buffer for value */
|
||||||
|
@ -56,7 +54,7 @@ static char *value = NULL ; /* temp buffer for value */
|
||||||
* return some of the contents of the kill buffer
|
* return some of the contents of the kill buffer
|
||||||
*/
|
*/
|
||||||
char *getkill( void) {
|
char *getkill( void) {
|
||||||
struct kill *kp ;
|
kill_p kp ;
|
||||||
char *cp ;
|
char *cp ;
|
||||||
|
|
||||||
if (kbufh == NULL)
|
if (kbufh == NULL)
|
||||||
|
@ -160,12 +158,14 @@ boolean forwchar( int f, int n) {
|
||||||
*/
|
*/
|
||||||
line_p lalloc( int used) {
|
line_p lalloc( int used) {
|
||||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||||
line_p lp ;
|
|
||||||
int size ;
|
|
||||||
|
|
||||||
/* size = used + BLOCK_SIZE - used % BLOCK_SIZE ; */
|
/* rounding down use masking instead or modulo when BLOCK_SIZE is power of 2 */
|
||||||
size = (used + BLOCK_SIZE) & ~(BLOCK_SIZE - 1) ; /* as BLOCK_SIZE is power of 2 */
|
#if (BLOCK_SIZE & -BLOCK_SIZE) == BLOCK_SIZE
|
||||||
lp = (line_p) malloc( offsetof( struct line, l_text) + size) ;
|
int size = (used + BLOCK_SIZE) & ~(BLOCK_SIZE - 1) ;
|
||||||
|
#else
|
||||||
|
int size = used + BLOCK_SIZE - used % BLOCK_SIZE ;
|
||||||
|
#endif
|
||||||
|
line_p lp = (line_p) malloc( offsetof( struct line, l_text) + size) ;
|
||||||
if( lp == NULL)
|
if( lp == NULL)
|
||||||
mloutstr( "(OUT OF MEMORY)") ;
|
mloutstr( "(OUT OF MEMORY)") ;
|
||||||
else {
|
else {
|
||||||
|
@ -183,7 +183,7 @@ line_p lalloc( int used) {
|
||||||
* conditions described in the above comments don't hold here.
|
* conditions described in the above comments don't hold here.
|
||||||
*/
|
*/
|
||||||
void lfree( line_p lp) {
|
void lfree( line_p lp) {
|
||||||
struct buffer *bp;
|
buffer_p bp;
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
|
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
|
@ -295,18 +295,13 @@ int linstr( char *instr) {
|
||||||
boolean linsert_byte( int n, int c) {
|
boolean linsert_byte( int n, int c) {
|
||||||
char *cp1;
|
char *cp1;
|
||||||
char *cp2;
|
char *cp2;
|
||||||
struct line *lp1;
|
line_p lp1, lp2, lp3 ;
|
||||||
struct line *lp2;
|
|
||||||
struct line *lp3;
|
|
||||||
int doto;
|
int doto;
|
||||||
int i;
|
int i;
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
|
|
||||||
assert( (curbp->b_mode & MDVIEW) == 0) ;
|
assert( (curbp->b_mode & MDVIEW) == 0) ;
|
||||||
#if 0
|
|
||||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
return rdonly(); /* we are in read only mode */
|
|
||||||
#endif
|
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
lp1 = curwp->w_dotp; /* Current line */
|
lp1 = curwp->w_dotp; /* Current line */
|
||||||
if (lp1 == curbp->b_linep) { /* At the end: special */
|
if (lp1 == curbp->b_linep) { /* At the end: special */
|
||||||
|
@ -314,8 +309,11 @@ boolean linsert_byte( int n, int c) {
|
||||||
mloutstr( "bug: linsert") ;
|
mloutstr( "bug: linsert") ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */
|
|
||||||
return FALSE;
|
lp2 = lalloc( n) ; /* Allocate new line */
|
||||||
|
if( lp2 == NULL)
|
||||||
|
return FALSE ;
|
||||||
|
|
||||||
lp3 = lp1->l_bp; /* Previous line */
|
lp3 = lp1->l_bp; /* Previous line */
|
||||||
lp3->l_fp = lp2; /* Link in */
|
lp3->l_fp = lp2; /* Link in */
|
||||||
lp2->l_fp = lp1;
|
lp2->l_fp = lp1;
|
||||||
|
@ -329,8 +327,10 @@ boolean linsert_byte( int n, int c) {
|
||||||
}
|
}
|
||||||
doto = curwp->w_doto; /* Save for later. */
|
doto = curwp->w_doto; /* Save for later. */
|
||||||
if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */
|
if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */
|
||||||
if ((lp2 = lalloc(lp1->l_used + n)) == NULL)
|
lp2 = lalloc( lp1->l_used + n) ;
|
||||||
return FALSE;
|
if( lp2 == NULL)
|
||||||
|
return FALSE ;
|
||||||
|
|
||||||
cp1 = &lp1->l_text[0];
|
cp1 = &lp1->l_text[0];
|
||||||
cp2 = &lp2->l_text[0];
|
cp2 = &lp2->l_text[0];
|
||||||
while (cp1 != &lp1->l_text[doto])
|
while (cp1 != &lp1->l_text[doto])
|
||||||
|
@ -374,8 +374,6 @@ boolean linsert_byte( int n, int c) {
|
||||||
|
|
||||||
int linsert( int n, unicode_t c) {
|
int linsert( int n, unicode_t c) {
|
||||||
assert( n >= 0) ;
|
assert( n >= 0) ;
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if( n > 0) {
|
if( n > 0) {
|
||||||
|
@ -398,16 +396,14 @@ int linsert( int n, unicode_t c) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Overwrite a character into the current line at the current position
|
||||||
* Overwrite a character into the current line at the current position
|
|
||||||
*
|
*
|
||||||
* int c; character to overwrite on current position
|
* int c ; character to overwrite on current position
|
||||||
*/
|
*/
|
||||||
static int lowrite( int c) {
|
static int lowrite( int c) {
|
||||||
if( curwp->w_doto < curwp->w_dotp->l_used
|
if( curwp->w_doto < curwp->w_dotp->l_used
|
||||||
&& (
|
&& ( lgetc( curwp->w_dotp, curwp->w_doto) != '\t'
|
||||||
lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
|| (curwp->w_doto % tabwidth) == (tabwidth - 1)
|
||||||
((curwp->w_doto) % tabwidth) == (tabwidth - 1)
|
|
||||||
))
|
))
|
||||||
ldelchar( 1, FALSE) ;
|
ldelchar( 1, FALSE) ;
|
||||||
|
|
||||||
|
@ -420,15 +416,12 @@ static int lowrite( int c) {
|
||||||
int lover( char *ostr) {
|
int lover( char *ostr) {
|
||||||
int status = TRUE ;
|
int status = TRUE ;
|
||||||
|
|
||||||
if (ostr != NULL) {
|
if( ostr != NULL) {
|
||||||
char tmpc ;
|
char tmpc ;
|
||||||
|
|
||||||
while( (tmpc = *ostr++)) {
|
while( (tmpc = *ostr++)) {
|
||||||
status =
|
status = (tmpc == '\n' ? lnewline() : lowrite( tmpc)) ;
|
||||||
(tmpc == '\n' ? lnewline() : lowrite(tmpc));
|
if( status != TRUE) { /* Insertion error? */
|
||||||
|
|
||||||
/* Insertion error? */
|
|
||||||
if( status != TRUE) {
|
|
||||||
mloutstr( "%Out of memory while overwriting") ;
|
mloutstr( "%Out of memory while overwriting") ;
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
@ -446,17 +439,13 @@ int lover( char *ostr) {
|
||||||
* update of dot and mark is a bit easier then in the above case, because the
|
* update of dot and mark is a bit easier then in the above case, because the
|
||||||
* split forces more updating.
|
* split forces more updating.
|
||||||
*/
|
*/
|
||||||
int lnewline(void)
|
int lnewline( void) {
|
||||||
{
|
|
||||||
char *cp1;
|
char *cp1;
|
||||||
char *cp2;
|
char *cp2;
|
||||||
struct line *lp1;
|
line_p lp1, lp2 ;
|
||||||
struct line *lp2;
|
|
||||||
int doto;
|
int doto;
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
|
@ -466,8 +455,10 @@ int lnewline(void)
|
||||||
#endif
|
#endif
|
||||||
lp1 = curwp->w_dotp; /* Get the address and */
|
lp1 = curwp->w_dotp; /* Get the address and */
|
||||||
doto = curwp->w_doto; /* offset of "." */
|
doto = curwp->w_doto; /* offset of "." */
|
||||||
if ((lp2 = lalloc(doto)) == NULL) /* New first half line */
|
lp2 = lalloc( doto) ; /* New first half line */
|
||||||
return FALSE;
|
if( lp2 == NULL)
|
||||||
|
return FALSE ;
|
||||||
|
|
||||||
cp1 = &lp1->l_text[0]; /* Shuffle text around */
|
cp1 = &lp1->l_text[0]; /* Shuffle text around */
|
||||||
cp2 = &lp2->l_text[0];
|
cp2 = &lp2->l_text[0];
|
||||||
while (cp1 != &lp1->l_text[doto])
|
while (cp1 != &lp1->l_text[doto])
|
||||||
|
@ -519,12 +510,14 @@ int lgetchar( unicode_t *c) {
|
||||||
*/
|
*/
|
||||||
boolean ldelchar( long n, boolean kflag) {
|
boolean ldelchar( long n, boolean kflag) {
|
||||||
/* testing for read only mode is done by ldelete() */
|
/* testing for read only mode is done by ldelete() */
|
||||||
while (n-- > 0) {
|
while( n-- > 0) {
|
||||||
unicode_t c;
|
unicode_t c;
|
||||||
if (!ldelete(lgetchar(&c), kflag))
|
|
||||||
return FALSE;
|
if( !ldelete( lgetchar( &c), kflag))
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -539,13 +532,11 @@ boolean ldelchar( long n, boolean kflag) {
|
||||||
boolean ldelete( long n, boolean kflag) {
|
boolean ldelete( long n, boolean kflag) {
|
||||||
char *cp1;
|
char *cp1;
|
||||||
char *cp2;
|
char *cp2;
|
||||||
struct line *dotp;
|
line_p dotp;
|
||||||
int doto;
|
int doto;
|
||||||
int chunk;
|
int chunk;
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
while( n > 0) {
|
while( n > 0) {
|
||||||
|
@ -641,20 +632,14 @@ char *getctext( void) {
|
||||||
* about in memory. Return FALSE on error and TRUE if all looks ok. Called by
|
* about in memory. Return FALSE on error and TRUE if all looks ok. Called by
|
||||||
* "ldelete" only.
|
* "ldelete" only.
|
||||||
*/
|
*/
|
||||||
static int ldelnewline(void)
|
static int ldelnewline( void) {
|
||||||
{
|
|
||||||
char *cp1;
|
char *cp1;
|
||||||
char *cp2;
|
char *cp2;
|
||||||
struct line *lp1;
|
line_p lp1, lp2, lp3 ;
|
||||||
struct line *lp2;
|
|
||||||
struct line *lp3;
|
|
||||||
struct window *wp;
|
struct window *wp;
|
||||||
|
|
||||||
assert( (curbp->b_mode & MDVIEW) == 0) ;
|
assert( (curbp->b_mode & MDVIEW) == 0) ;
|
||||||
#if 0
|
|
||||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
return rdonly(); /* we are in read only mode */
|
|
||||||
#endif
|
|
||||||
lp1 = curwp->w_dotp;
|
lp1 = curwp->w_dotp;
|
||||||
lp2 = lp1->l_fp;
|
lp2 = lp1->l_fp;
|
||||||
if (lp2 == curbp->b_linep) { /* At the buffer end. */
|
if (lp2 == curbp->b_linep) { /* At the buffer end. */
|
||||||
|
@ -687,8 +672,11 @@ static int ldelnewline(void)
|
||||||
free((char *) lp2);
|
free((char *) lp2);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL)
|
|
||||||
return FALSE;
|
lp3 = lalloc( lp1->l_used + lp2->l_used) ;
|
||||||
|
if( lp3 == NULL)
|
||||||
|
return FALSE ;
|
||||||
|
|
||||||
cp1 = &lp1->l_text[0];
|
cp1 = &lp1->l_text[0];
|
||||||
cp2 = &lp3->l_text[0];
|
cp2 = &lp3->l_text[0];
|
||||||
while (cp1 != &lp1->l_text[lp1->l_used])
|
while (cp1 != &lp1->l_text[lp1->l_used])
|
||||||
|
@ -730,7 +718,7 @@ static int ldelnewline(void)
|
||||||
*/
|
*/
|
||||||
void kdelete(void)
|
void kdelete(void)
|
||||||
{
|
{
|
||||||
struct kill *kp; /* ptr to scan kill buffer chunk list */
|
kill_p kp; /* ptr to scan kill buffer chunk list */
|
||||||
|
|
||||||
if (kbufh != NULL) {
|
if (kbufh != NULL) {
|
||||||
|
|
||||||
|
@ -759,30 +747,30 @@ void kdelete(void)
|
||||||
*
|
*
|
||||||
* int c; character to insert in the kill buffer
|
* int c; character to insert in the kill buffer
|
||||||
*/
|
*/
|
||||||
int kinsert(int c)
|
int kinsert( int c) {
|
||||||
{
|
|
||||||
struct kill *nchunk; /* ptr to newly malloced chunk */
|
|
||||||
|
|
||||||
/* check to see if we need a new chunk */
|
/* check to see if we need a new chunk */
|
||||||
if (kused >= KBLOCK) {
|
if( kused >= KBLOCK) {
|
||||||
if ((nchunk = (struct kill *)malloc(sizeof(struct kill))) == NULL)
|
kill_p nchunk = malloc( sizeof *nchunk) ;
|
||||||
return FALSE;
|
if( nchunk == NULL)
|
||||||
|
return FALSE ;
|
||||||
|
|
||||||
if( kbufh == NULL) { /* set head ptr if first time */
|
if( kbufh == NULL) { /* set head ptr if first time */
|
||||||
kbufh = nchunk;
|
kbufh = nchunk ;
|
||||||
klen = 0 ;
|
klen = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kbufp != NULL) /* point the current to this new one */
|
if( kbufp != NULL) /* point the current to this new one */
|
||||||
kbufp->d_next = nchunk;
|
kbufp->d_next = nchunk ;
|
||||||
kbufp = nchunk;
|
|
||||||
kbufp->d_next = NULL;
|
kbufp = nchunk ;
|
||||||
kused = 0;
|
kbufp->d_next = NULL ;
|
||||||
|
kused = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now insert the character */
|
/* and now insert the character */
|
||||||
kbufp->d_chunk[kused++] = c;
|
kbufp->d_chunk[ kused++] = c ;
|
||||||
klen += 1 ;
|
klen += 1 ;
|
||||||
return TRUE;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -790,15 +778,12 @@ int kinsert(int c)
|
||||||
* is done by the standard insert routines. All you do is run the loop, and
|
* is done by the standard insert routines. All you do is run the loop, and
|
||||||
* check for errors. Bound to "C-Y".
|
* check for errors. Bound to "C-Y".
|
||||||
*/
|
*/
|
||||||
int yank(int f, int n)
|
BINDABLE( yank) {
|
||||||
{
|
|
||||||
int c;
|
int c;
|
||||||
int i;
|
int i;
|
||||||
char *sp; /* pointer into string to insert */
|
char *sp; /* pointer into string to insert */
|
||||||
struct kill *kp; /* pointer into kill buffer */
|
kill_p kp; /* pointer into kill buffer */
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
|
@ -839,3 +824,5 @@ boolean rdonly( void) {
|
||||||
mloutfmt( "%B(Key illegal in VIEW mode)") ;
|
mloutfmt( "%B(Key illegal in VIEW mode)") ;
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* end of line.c */
|
||||||
|
|
18
line.h
18
line.h
|
@ -1,7 +1,9 @@
|
||||||
#ifndef LINE_H_
|
/* line.h -- line centric interface */
|
||||||
#define LINE_H_
|
|
||||||
|
|
||||||
#include "retcode.h"
|
#ifndef _LINE_H_
|
||||||
|
#define _LINE_H_
|
||||||
|
|
||||||
|
#include "names.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -34,8 +36,8 @@ char *getkill( void) ;
|
||||||
/* Bindable functions */
|
/* Bindable functions */
|
||||||
boolean backchar( int f, int n) ;
|
boolean backchar( int f, int n) ;
|
||||||
boolean forwchar( int f, int n) ;
|
boolean forwchar( int f, int n) ;
|
||||||
int insspace( int f, int n) ;
|
BINDABLE( insspace) ;
|
||||||
int yank( int f, int n) ;
|
BINDABLE( yank) ;
|
||||||
|
|
||||||
void lfree( line_p lp) ;
|
void lfree( line_p lp) ;
|
||||||
void lchange( int flag) ;
|
void lchange( int flag) ;
|
||||||
|
@ -46,7 +48,7 @@ int lover( char *ostr) ;
|
||||||
int lnewline( void) ;
|
int lnewline( void) ;
|
||||||
boolean ldelete( long n, boolean kflag) ;
|
boolean ldelete( long n, boolean kflag) ;
|
||||||
boolean ldelchar( long n, boolean kflag) ;
|
boolean ldelchar( long n, boolean kflag) ;
|
||||||
int lgetchar( unicode_t *) ;
|
int lgetchar( unicode_t *cref) ;
|
||||||
char *getctext( void) ;
|
char *getctext( void) ;
|
||||||
void kdelete( void) ;
|
void kdelete( void) ;
|
||||||
int kinsert( int c) ;
|
int kinsert( int c) ;
|
||||||
|
@ -54,4 +56,6 @@ line_p lalloc( int minsize) ; /* Allocate a line of at least minsize chars. */
|
||||||
|
|
||||||
boolean rdonly( void) ; /* Read Only error message */
|
boolean rdonly( void) ; /* Read Only error message */
|
||||||
|
|
||||||
#endif /* LINE_H_ */
|
#endif /* _LINE_H_ */
|
||||||
|
|
||||||
|
/* end of line.h */
|
||||||
|
|
16
names.c
16
names.c
|
@ -54,9 +54,7 @@ const name_bind names[] = {
|
||||||
{" clear-and-redraw", redraw, CTRL | 'L'} ,
|
{" clear-and-redraw", redraw, CTRL | 'L'} ,
|
||||||
{" clear-message-line", clrmes, 0} ,
|
{" clear-message-line", clrmes, 0} ,
|
||||||
{" copy-region", copyregion, META | 'W'} ,
|
{" copy-region", copyregion, META | 'W'} ,
|
||||||
#if WORDPRO
|
|
||||||
{" count-words", wordcount, META | CTRL | 'C'} ,
|
{" count-words", wordcount, META | CTRL | 'C'} ,
|
||||||
#endif
|
|
||||||
{" ctlx-prefix", cex, CTRL | 'X'} ,
|
{" ctlx-prefix", cex, CTRL | 'X'} ,
|
||||||
{"!delete-blank-lines", deblank, CTLX | CTRL | 'O'} ,
|
{"!delete-blank-lines", deblank, CTLX | CTRL | 'O'} ,
|
||||||
{" delete-buffer", killbuffer, CTLX | 'K'} ,
|
{" delete-buffer", killbuffer, CTLX | 'K'} ,
|
||||||
|
@ -70,15 +68,11 @@ const name_bind names[] = {
|
||||||
{" 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 | '?'} ,
|
||||||
#if AEDIT
|
|
||||||
{"!detab-line", detab, CTLX | CTRL | 'D'} , /* X^A */
|
{"!detab-line", detab, CTLX | CTRL | 'D'} , /* X^A */
|
||||||
#endif
|
|
||||||
{" end-macro", ctlxrp, CTLX | ')'} ,
|
{" end-macro", 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, CTRL | 'E'} ,
|
||||||
#if AEDIT
|
|
||||||
{"!entab-line", entab, CTLX | CTRL | 'E'} ,
|
{"!entab-line", entab, CTLX | CTRL | 'E'} ,
|
||||||
#endif
|
|
||||||
{" exchange-point-and-mark", (fnp_t) swapmark, CTLX | CTRL | 'X'} ,
|
{" exchange-point-and-mark", (fnp_t) swapmark, CTLX | CTRL | 'X'} ,
|
||||||
{" execute-buffer", execbuf, 0} ,
|
{" execute-buffer", execbuf, 0} ,
|
||||||
{" execute-command-line", execcmd, 0} ,
|
{" execute-command-line", execcmd, 0} ,
|
||||||
|
@ -130,9 +124,7 @@ const name_bind names[] = {
|
||||||
#endif
|
#endif
|
||||||
{" execute-program", execprg, CTLX | '$'} ,
|
{" execute-program", execprg, CTLX | '$'} ,
|
||||||
{" exit-emacs", quit, CTLX | CTRL | 'C'} ,
|
{" exit-emacs", quit, CTLX | CTRL | 'C'} ,
|
||||||
#if WORDPRO
|
|
||||||
{"!fill-paragraph", fillpara, META | 'Q'} ,
|
{"!fill-paragraph", fillpara, META | 'Q'} ,
|
||||||
#endif
|
|
||||||
{"!filter-buffer", filter_buffer, CTLX | '#'} ,
|
{"!filter-buffer", filter_buffer, CTLX | '#'} ,
|
||||||
{" find-file", filefind, CTLX | CTRL | 'F'} ,
|
{" find-file", filefind, CTLX | CTRL | 'F'} ,
|
||||||
{" forward-character", (fnp_t) forwchar, CTRL | 'F'} ,
|
{" forward-character", (fnp_t) forwchar, CTRL | 'F'} ,
|
||||||
|
@ -152,12 +144,10 @@ const name_bind names[] = {
|
||||||
{"!insert-file", insfile, CTLX | CTRL | 'I'} ,
|
{"!insert-file", insfile, CTLX | CTRL | 'I'} ,
|
||||||
{"!insert-space", insspace, CTRL | 'C'} ,
|
{"!insert-space", insspace, CTRL | 'C'} ,
|
||||||
{"!insert-string", istring, 0} ,
|
{"!insert-string", istring, 0} ,
|
||||||
#if WORDPRO
|
|
||||||
#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 | CTRL | 'W'} ,
|
||||||
#endif
|
|
||||||
{"!kill-region", killregion, CTRL | 'W'} ,
|
{"!kill-region", killregion, CTRL | 'W'} ,
|
||||||
{"!kill-to-end-of-line", killtext, CTRL | 'K'} ,
|
{"!kill-to-end-of-line", killtext, CTRL | 'K'} ,
|
||||||
{" list-buffers", listbuffers, CTLX | CTRL | 'B'} ,
|
{" list-buffers", listbuffers, CTLX | CTRL | 'B'} ,
|
||||||
|
@ -170,9 +160,7 @@ const name_bind names[] = {
|
||||||
{" next-buffer", nextbuffer, CTLX | 'X'} ,
|
{" next-buffer", nextbuffer, CTLX | 'X'} ,
|
||||||
{" next-line", (fnp_t) forwline, CTRL | 'N'} ,
|
{" next-line", (fnp_t) forwline, CTRL | 'N'} ,
|
||||||
{" next-page", (fnp_t) forwpage, CTRL | 'V'} ,
|
{" next-page", (fnp_t) forwpage, CTRL | 'V'} ,
|
||||||
#if WORDPRO
|
|
||||||
{" next-paragraph", gotoeop, META | 'N'} ,
|
{" next-paragraph", gotoeop, META | 'N'} ,
|
||||||
#endif
|
|
||||||
{" 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", nullproc, SPEC | META | 'C'}, /* hook */
|
||||||
|
@ -181,9 +169,7 @@ const name_bind names[] = {
|
||||||
{" pipe-command", pipecmd, CTLX | '@'} ,
|
{" pipe-command", pipecmd, CTLX | '@'} ,
|
||||||
{" previous-line", (fnp_t) backline, CTRL | 'P'} ,
|
{" previous-line", (fnp_t) backline, CTRL | 'P'} ,
|
||||||
{" previous-page", (fnp_t) backpage, CTRL | 'Z'} , /* MV */
|
{" previous-page", (fnp_t) backpage, CTRL | 'Z'} , /* MV */
|
||||||
#if WORDPRO
|
|
||||||
{" previous-paragraph", gotobop, META | 'P'} ,
|
{" previous-paragraph", gotobop, META | 'P'} ,
|
||||||
#endif
|
|
||||||
{" 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 | CTRL | 'R'} ,
|
||||||
|
@ -221,9 +207,7 @@ const name_bind names[] = {
|
||||||
{" 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, CTRL | 'T'} ,
|
||||||
#if AEDIT
|
|
||||||
{"!trim-line", trim, CTLX | CTRL | 'T'} ,
|
{"!trim-line", trim, CTLX | CTRL | 'T'} ,
|
||||||
#endif
|
|
||||||
{" unbind-key", unbindkey, META | CTRL | 'K'} ,
|
{" unbind-key", unbindkey, META | CTRL | 'K'} ,
|
||||||
{" universal-argument", unarg, CTRL | 'U'} ,
|
{" universal-argument", unarg, CTRL | 'U'} ,
|
||||||
{" unmark-buffer", unmark, META | '~'} ,
|
{" unmark-buffer", unmark, META | '~'} ,
|
||||||
|
|
258
random.c
258
random.c
|
@ -51,26 +51,22 @@ int lastflag ; /* Flags, last command */
|
||||||
static int adjustmode( int kind, int global) ;
|
static int adjustmode( int kind, int global) ;
|
||||||
static int cinsert( void) ;
|
static int cinsert( void) ;
|
||||||
|
|
||||||
/*
|
/* Set fill column to n. Bound to C-X F set-fill-column.
|
||||||
* Set fill column to n.
|
|
||||||
*/
|
*/
|
||||||
int setfillcol(int f, int n)
|
BINDABLE( setfillcol) {
|
||||||
{
|
fillcol = n ;
|
||||||
fillcol = n;
|
mlwrite( "(Fill column is %d)", n) ;
|
||||||
mlwrite("(Fill column is %d)", n);
|
return TRUE ;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Display the current position of the cursor, in origin 1 X-Y coordinates,
|
||||||
* Display the current position of the cursor, in origin 1 X-Y coordinates,
|
the character that is under the cursor (in hex), and the fraction of the
|
||||||
* the character that is under the cursor (in hex), and the fraction of the
|
text that is before the cursor. The displayed column is not the current
|
||||||
* text that is before the cursor. The displayed column is not the current
|
column, but the column that would be used on an infinite width display.
|
||||||
* column, but the column that would be used on an infinite width display.
|
Normally this is bound to C-X = buffer-position.
|
||||||
* Normally this is bound to "C-X =".
|
|
||||||
*/
|
*/
|
||||||
int showcpos(int f, int n)
|
BINDABLE( showcpos) {
|
||||||
{
|
line_p lp ; /* current line */
|
||||||
struct line *lp; /* current line */
|
|
||||||
long numchars; /* # of chars in file */
|
long numchars; /* # of chars in file */
|
||||||
int numlines; /* # of lines in file */
|
int numlines; /* # of lines in file */
|
||||||
long predchars; /* # chars preceding point */
|
long predchars; /* # chars preceding point */
|
||||||
|
@ -128,7 +124,7 @@ int showcpos(int f, int n)
|
||||||
|
|
||||||
int getcline(void)
|
int getcline(void)
|
||||||
{ /* get the current line number */
|
{ /* get the current line number */
|
||||||
struct line *lp; /* current line */
|
line_p lp ; /* current line */
|
||||||
int numlines; /* # of lines before point */
|
int numlines; /* # of lines before point */
|
||||||
|
|
||||||
/* starting at the beginning of the buffer */
|
/* starting at the beginning of the buffer */
|
||||||
|
@ -154,7 +150,7 @@ int getcline(void)
|
||||||
int getccol(int bflg)
|
int getccol(int bflg)
|
||||||
{
|
{
|
||||||
int i, col;
|
int i, col;
|
||||||
struct line *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);
|
||||||
|
|
||||||
|
@ -224,14 +220,11 @@ boolean setccol( int pos) {
|
||||||
*/
|
*/
|
||||||
boolean twiddle( int f, int n) {
|
boolean twiddle( int f, int n) {
|
||||||
unicode_t c ;
|
unicode_t c ;
|
||||||
int len ;
|
|
||||||
boolean eof_f = FALSE ;
|
boolean eof_f = FALSE ;
|
||||||
|
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
len = llength( curwp->w_dotp) ;
|
int len = llength( curwp->w_dotp) ;
|
||||||
if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */
|
if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
|
@ -255,44 +248,36 @@ boolean twiddle( int f, int n) {
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Quote the next character, and insert it into the buffer. All the
|
||||||
* Quote the next character, and insert it into the buffer. All the characters
|
characters are taken literally, with the exception of the newline, which
|
||||||
* are taken literally, with the exception of the newline, which always has
|
always has its line splitting meaning. The character is always read,
|
||||||
* its line splitting meaning. The character is always read, even if it is
|
even if it is inserted 0 times, for regularity. Bound to C-Q
|
||||||
* inserted 0 times, for regularity. Bound to "C-Q"
|
quote-character.
|
||||||
*/
|
*/
|
||||||
int quote(int f, int n)
|
BINDABLE( quote) {
|
||||||
{
|
int ret ;
|
||||||
// int c;
|
|
||||||
//
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
int c = tgetc();
|
int c = ectoc( get1key()) ;
|
||||||
if (n < 0)
|
if( n < 0)
|
||||||
return FALSE;
|
ret = FALSE ;
|
||||||
if (n == 0)
|
else if( n == 0)
|
||||||
return TRUE;
|
ret = TRUE ;
|
||||||
if (c == '\n') {
|
else if( c == '\n')
|
||||||
int s ;
|
do
|
||||||
|
ret = lnewline() ;
|
||||||
|
while( ret == TRUE && --n) ;
|
||||||
|
else
|
||||||
|
ret = linsert( n, c) ;
|
||||||
|
|
||||||
do {
|
return ret ;
|
||||||
s = lnewline();
|
|
||||||
} while (s == TRUE && --n);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return linsert(n, c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Insert tab/blank/space up to nth next tabulation according to hard/soft
|
||||||
* Set tab size if given non-default argument (n <> 1). Otherwise, insert a
|
tab current state and tab width. Bound to C-I handle-tab.
|
||||||
* tab into file. If given argument, n, of zero, change to true tabs.
|
|
||||||
* If n > 1, simulate tab stop every n-characters using spaces. This has to be
|
|
||||||
* done in this slightly funny way because the tab (in ASCII) has been turned
|
|
||||||
* into "C-I" (in 10 bit code) already. Bound to "C-I".
|
|
||||||
*/
|
*/
|
||||||
int insert_tab( int f, int n) {
|
BINDABLE( insert_tab) {
|
||||||
int status ;
|
int status ;
|
||||||
|
|
||||||
if( n < 0)
|
if( n < 0)
|
||||||
|
@ -309,27 +294,20 @@ int insert_tab( int f, int n) {
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if AEDIT
|
|
||||||
/*
|
/*
|
||||||
* change tabs to spaces
|
* change tabs to spaces
|
||||||
*
|
*
|
||||||
* int f, n; default flag and numeric repeat count
|
* int f, n; default flag and numeric repeat count
|
||||||
*/
|
*/
|
||||||
int detab(int f, int n)
|
BINDABLE( detab) {
|
||||||
{
|
|
||||||
int inc; /* increment to next line [sgn(n)] */
|
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (f == FALSE)
|
if( f == FALSE)
|
||||||
n = 1;
|
n = 1 ;
|
||||||
|
|
||||||
/* loop thru detabbing n lines */
|
/* loop thru detabbing n lines */
|
||||||
inc = ((n > 0) ? 1 : -1);
|
int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */
|
||||||
while (n) {
|
for( ; n ; n -= inc) {
|
||||||
curwp->w_doto = 0; /* start at the beginning */
|
curwp->w_doto = 0; /* start at the beginning */
|
||||||
|
|
||||||
/* detab the entire current line */
|
/* detab the entire current line */
|
||||||
|
@ -349,9 +327,8 @@ int detab(int f, int n)
|
||||||
/* advance/or back to the next line */
|
/* advance/or back to the next line */
|
||||||
if( forwline( TRUE, inc) == FALSE)
|
if( forwline( TRUE, inc) == FALSE)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
n -= inc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curwp->w_doto = 0; /* to the begining of the line */
|
curwp->w_doto = 0; /* to the begining of the line */
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
lchange(WFEDIT); /* yes, we have made at least an edit */
|
||||||
|
@ -359,27 +336,21 @@ int detab(int f, int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* change spaces to tabs where posible
|
* change spaces to tabs where possible
|
||||||
*
|
*
|
||||||
* int f, n; default flag and numeric repeat count
|
* int f, n; default flag and numeric repeat count
|
||||||
*/
|
*/
|
||||||
int entab(int f, int n)
|
BINDABLE( entab) {
|
||||||
{
|
|
||||||
#define nextab(a) (a + tabwidth - a % tabwidth)
|
#define nextab(a) (a + tabwidth - a % tabwidth)
|
||||||
|
|
||||||
int inc; /* increment to next line [sgn(n)] */
|
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (f == FALSE)
|
if( f == FALSE)
|
||||||
n = 1;
|
n = 1 ;
|
||||||
|
|
||||||
/* loop thru entabbing n lines */
|
/* loop thru entabbing n lines */
|
||||||
inc = ((n > 0) ? 1 : -1);
|
int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */
|
||||||
while (n) {
|
for( ; n ; n -= inc) {
|
||||||
int fspace ; /* pointer to first space if in a run */
|
int fspace ; /* pointer to first space if in a run */
|
||||||
int ccol ; /* current cursor column */
|
int ccol ; /* current cursor column */
|
||||||
|
|
||||||
|
@ -426,9 +397,8 @@ int entab(int f, int n)
|
||||||
/* advance/or back to the next line */
|
/* advance/or back to the next line */
|
||||||
if( forwline( TRUE, inc) == FALSE)
|
if( forwline( TRUE, inc) == FALSE)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
n -= inc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curwp->w_doto = 0; /* to the begining of the line */
|
curwp->w_doto = 0; /* to the begining of the line */
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
lchange(WFEDIT); /* yes, we have made at least an edit */
|
||||||
|
@ -440,21 +410,15 @@ int entab(int f, int n)
|
||||||
*
|
*
|
||||||
* int f, n; default flag and numeric repeat count
|
* int f, n; default flag and numeric repeat count
|
||||||
*/
|
*/
|
||||||
int trim(int f, int n)
|
BINDABLE( trim) {
|
||||||
{
|
|
||||||
int inc; /* increment to next line [sgn(n)] */
|
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (f == FALSE)
|
if( f == FALSE)
|
||||||
n = 1;
|
n = 1 ;
|
||||||
|
|
||||||
/* loop thru trimming n lines */
|
/* loop thru trimming n lines */
|
||||||
inc = ((n > 0) ? 1 : -1);
|
int inc = (n > 0) ? 1 : -1 ; /* increment to next line [sgn(n)] */
|
||||||
while (n) {
|
for( ; n ; n -= inc) {
|
||||||
line_p lp ; /* current line pointer */
|
line_p lp ; /* current line pointer */
|
||||||
int offset ; /* original line offset position */
|
int offset ; /* original line offset position */
|
||||||
int length ; /* current length */
|
int length ; /* current length */
|
||||||
|
@ -468,60 +432,46 @@ int trim(int f, int n)
|
||||||
if( c != ' ' && c != '\t')
|
if( c != ' ' && c != '\t')
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
lp->l_used = length;
|
lp->l_used = length;
|
||||||
|
|
||||||
/* advance/or back to the next line */
|
/* advance/or back to the next line */
|
||||||
if( forwline( TRUE, inc) == FALSE)
|
if( forwline( TRUE, inc) == FALSE)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
n -= inc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
return (n == 0) ? TRUE : FALSE ;
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open up some blank space. The basic plan is to insert a bunch of newlines,
|
* Open up some blank space. The basic plan is to insert a bunch of newlines,
|
||||||
* and then back up over them. Everything is done by the subcommand
|
* and then back up over them. Everything is done by the subcommand
|
||||||
* procerssors. They even handle the looping. Normally this is bound to "C-O".
|
* procerssors. They even handle the looping. Normally this is bound to "C-O".
|
||||||
*/
|
*/
|
||||||
int openline(int f, int n)
|
BINDABLE( openline) {
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int s;
|
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (n < 0)
|
int ret = (n < 0) ? FALSE : TRUE ;
|
||||||
return FALSE;
|
for( int i = n ; ret == TRUE && i ; i--) /* Insert newlines. */
|
||||||
if (n == 0)
|
ret = lnewline() ;
|
||||||
return TRUE;
|
|
||||||
i = n; /* Insert newlines. */
|
if( ret == TRUE) /* Then back up overtop */
|
||||||
do {
|
ret = backchar( f, n) ; /* of them all. */
|
||||||
s = lnewline();
|
|
||||||
} while (s == TRUE && --i);
|
return ret ;
|
||||||
if (s == TRUE) /* Then back up overtop */
|
|
||||||
s = backchar(f, n); /* of them all. */
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a newline. Bound to "C-M". If we are in CMODE, do automatic
|
* Insert a newline. Bound to "C-M". If we are in CMODE, do automatic
|
||||||
* indentation as specified.
|
* indentation as specified.
|
||||||
*/
|
*/
|
||||||
int insert_newline(int f, int n)
|
BINDABLE( insert_newline) {
|
||||||
{
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if (n < 0)
|
if( n < 0)
|
||||||
return FALSE;
|
return FALSE ;
|
||||||
|
|
||||||
/* if we are in C mode and this is a default <NL> */
|
/* if we are in C mode and this is a default <NL> */
|
||||||
if (n == 1 && (curbp->b_mode & MDCMOD) &&
|
if (n == 1 && (curbp->b_mode & MDCMOD) &&
|
||||||
|
@ -569,7 +519,7 @@ static int cinsert(void)
|
||||||
nicol = 0 ;
|
nicol = 0 ;
|
||||||
for( i = 0 ; i < tptr ; i += 1) {
|
for( i = 0 ; i < tptr ; i += 1) {
|
||||||
int ch ;
|
int ch ;
|
||||||
|
|
||||||
ch = cptr[ i] ;
|
ch = cptr[ i] ;
|
||||||
if( ch == ' ')
|
if( ch == ' ')
|
||||||
nicol += 1 ;
|
nicol += 1 ;
|
||||||
|
@ -610,22 +560,17 @@ static int cinsert(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/* Delete blank lines around dot. What this command does depends if dot is
|
||||||
* Delete blank lines around dot. What this command does depends if dot is
|
* sitting on a blank line. If dot is sitting on a blank line, this
|
||||||
* sitting on a blank line. If dot is sitting on a blank line, this command
|
* command deletes all the blank lines above and below the current line.
|
||||||
* deletes all the blank lines above and below the current line. If it is
|
* If it is sitting on a non blank line then it deletes all of the blank
|
||||||
* sitting on a non blank line then it deletes all of the blank lines after
|
* lines after the line. Normally this command is bound to C-X C-O
|
||||||
* the line. Normally this command is bound to "C-X C-O". Any argument is
|
* delete-blank-lines. Any argument is ignored.
|
||||||
* ignored.
|
|
||||||
*/
|
*/
|
||||||
int deblank(int f, int n)
|
BINDABLE( deblank) {
|
||||||
{
|
line_p lp1, lp2 ;
|
||||||
struct line *lp1;
|
long nld ;
|
||||||
struct line *lp2;
|
|
||||||
long nld;
|
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
lp1 = curwp->w_dotp;
|
lp1 = curwp->w_dotp;
|
||||||
|
@ -642,28 +587,24 @@ int deblank(int f, int n)
|
||||||
return ldelete(nld, FALSE);
|
return ldelete(nld, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Insert a newline, then enough tabs and spaces to duplicate the
|
||||||
* Insert a newline, then enough tabs and spaces to duplicate the indentation
|
* indentation of the previous line. Assumes tabs are every tabwidth
|
||||||
* of the previous line. Assumes tabs are every tabwidth characters.
|
* characters. Figure out the indentation of the current line. Insert a
|
||||||
* Figure out the indentation of the current line. Insert a newline by calling
|
* newline by calling the standard routine. Insert the indentation by
|
||||||
* the standard routine. Insert the indentation by inserting the right number
|
* inserting the right number of tabs and spaces. Return TRUE if all ok.
|
||||||
* of tabs and spaces. Return TRUE if all ok. Return FALSE if one of the
|
* Return FALSE if one of the subcomands failed. Normally bound to C-J
|
||||||
* subcomands failed. Normally bound to "C-J".
|
* newline-and-indent.
|
||||||
*/
|
*/
|
||||||
int indent( int f, int n) {
|
BINDABLE( indent) {
|
||||||
int nicol ;
|
|
||||||
int i ;
|
int i ;
|
||||||
|
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if( n < 0)
|
if( n < 0)
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
/* number of columns to indent */
|
/* number of columns to indent */
|
||||||
nicol = 0 ;
|
int nicol = 0 ;
|
||||||
for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) {
|
for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) {
|
||||||
int c ;
|
int c ;
|
||||||
|
|
||||||
|
@ -693,10 +634,7 @@ int indent( int f, int n) {
|
||||||
* If any argument is present, it kills rather than deletes, to prevent loss
|
* If any argument is present, it kills rather than deletes, to prevent loss
|
||||||
* of text if typed with a big argument. Normally bound to "C-D".
|
* of text if typed with a big argument. Normally bound to "C-D".
|
||||||
*/
|
*/
|
||||||
int forwdel( int f, int n) {
|
BINDABLE( forwdel) {
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if( n == 0)
|
if( n == 0)
|
||||||
|
@ -719,10 +657,7 @@ int forwdel( int f, int n) {
|
||||||
* forward, this actually does a kill if presented with an argument. Bound to
|
* forward, this actually does a kill if presented with an argument. Bound to
|
||||||
* both "RUBOUT" and "C-H".
|
* both "RUBOUT" and "C-H".
|
||||||
*/
|
*/
|
||||||
int backdel( int f, int n) {
|
BINDABLE( backdel) {
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if( n == 0)
|
if( n == 0)
|
||||||
|
@ -747,13 +682,10 @@ int backdel( int f, int n) {
|
||||||
* number of newlines. If called with a negative argument it kills backwards
|
* number of newlines. If called with a negative argument it kills backwards
|
||||||
* that number of newlines. Normally bound to "C-K".
|
* that number of newlines. Normally bound to "C-K".
|
||||||
*/
|
*/
|
||||||
int killtext(int f, int n)
|
BINDABLE( killtext) {
|
||||||
{
|
line_p nextp ;
|
||||||
struct line *nextp;
|
|
||||||
long chunk;
|
long chunk;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */
|
if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */
|
||||||
|
@ -953,7 +885,7 @@ static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) {
|
||||||
*
|
*
|
||||||
* int f, n; ignored arguments
|
* int f, n; ignored arguments
|
||||||
*/
|
*/
|
||||||
int istring( int f, int n) {
|
BINDABLE( istring) {
|
||||||
return iovstring( f, n, "insert-string<META>: ", linstr) ;
|
return iovstring( f, n, "insert-string<META>: ", linstr) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,7 +895,7 @@ int istring( int f, int n) {
|
||||||
*
|
*
|
||||||
* int f, n; ignored arguments
|
* int f, n; ignored arguments
|
||||||
*/
|
*/
|
||||||
int ovstring( int f, int n) {
|
BINDABLE( ovstring) {
|
||||||
return iovstring( f, n, "overwrite-string<META>: ", lover) ;
|
return iovstring( f, n, "overwrite-string<META>: ", lover) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
67
random.h
67
random.h
|
@ -1,49 +1,48 @@
|
||||||
|
/* random.h -- various commands */
|
||||||
|
|
||||||
#ifndef _RANDOM_H_
|
#ifndef _RANDOM_H_
|
||||||
#define _RANDOM_H_
|
#define _RANDOM_H_
|
||||||
|
|
||||||
|
#include "names.h"
|
||||||
|
|
||||||
#include "retcode.h"
|
/* Command flags */
|
||||||
|
#define CFCPCN 0x0001 /* Flag that last command was C-P, C-N */
|
||||||
|
#define CFKILL 0x0002 /* Flag that last command was a kill */
|
||||||
|
|
||||||
|
extern int thisflag ; /* Flags, this command */
|
||||||
|
extern int lastflag ; /* Flags, last command */
|
||||||
|
|
||||||
#define AEDIT 1
|
extern int fillcol ; /* Fill column */
|
||||||
|
|
||||||
extern int fillcol ; /* Fill column */
|
|
||||||
extern boolean hardtab ; /* Use hard tab instead of soft tab */
|
extern boolean hardtab ; /* Use hard tab instead of soft tab */
|
||||||
|
|
||||||
|
|
||||||
/* Uninitialized global external declarations. */
|
|
||||||
|
|
||||||
#define CFCPCN 0x0001 /* Last command was C-P, C-N */
|
|
||||||
#define CFKILL 0x0002 /* Last command was a kill */
|
|
||||||
|
|
||||||
extern int thisflag ; /* Flags, this command */
|
|
||||||
extern int lastflag ; /* Flags, last command */
|
|
||||||
|
|
||||||
int setfillcol( int f, int n) ;
|
|
||||||
int showcpos( int f, int n) ;
|
|
||||||
int getcline( void) ;
|
int getcline( void) ;
|
||||||
int getccol( int bflg) ;
|
int getccol( int bflg) ;
|
||||||
boolean setccol( int pos) ;
|
boolean setccol( int pos) ;
|
||||||
|
|
||||||
|
/* Bindable functions */
|
||||||
|
BINDABLE( setfillcol) ;
|
||||||
|
BINDABLE( showcpos) ;
|
||||||
boolean twiddle( int f, int n) ;
|
boolean twiddle( int f, int n) ;
|
||||||
int quote( int f, int n) ;
|
BINDABLE( quote) ;
|
||||||
int insert_tab( int f, int n) ;
|
BINDABLE( insert_tab) ;
|
||||||
#if AEDIT
|
BINDABLE( detab) ;
|
||||||
int detab( int f, int n) ;
|
BINDABLE( entab) ;
|
||||||
int entab( int f, int n) ;
|
BINDABLE( trim) ;
|
||||||
int trim( int f, int n) ;
|
BINDABLE( openline) ;
|
||||||
#endif
|
BINDABLE( insert_newline) ;
|
||||||
int openline( int f, int n) ;
|
BINDABLE( deblank) ;
|
||||||
int insert_newline( int f, int n) ;
|
BINDABLE( indent) ;
|
||||||
int deblank( int f, int n) ;
|
BINDABLE( forwdel) ;
|
||||||
int indent( int f, int n) ;
|
BINDABLE( backdel) ;
|
||||||
int forwdel( int f, int n) ;
|
BINDABLE( killtext) ;
|
||||||
int backdel( int f, int n) ;
|
BINDABLE( setemode) ;
|
||||||
int killtext( int f, int n) ;
|
BINDABLE( delmode) ;
|
||||||
int setemode( int f, int n) ;
|
BINDABLE( setgmode) ;
|
||||||
int delmode( int f, int n) ;
|
BINDABLE( delgmode) ;
|
||||||
int setgmode( int f, int n) ;
|
BINDABLE( istring) ;
|
||||||
int delgmode( int f, int n) ;
|
BINDABLE( ovstring) ;
|
||||||
int istring( int f, int n) ;
|
|
||||||
int ovstring( int f, int n) ;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of random.h */
|
||||||
|
|
97
region.c
97
region.c
|
@ -20,19 +20,14 @@
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
/*
|
/* Kill the region. Ask "getregion" to figure out the bounds of the
|
||||||
* Kill the region. Ask "getregion"
|
* region. Move "." to the start, and kill the characters. Bound to
|
||||||
* to figure out the bounds of the region.
|
* "C-W".
|
||||||
* Move "." to the start, and kill the characters.
|
|
||||||
* Bound to "C-W".
|
|
||||||
*/
|
*/
|
||||||
int killregion(int f, int n)
|
BINDABLE( killregion) {
|
||||||
{
|
|
||||||
int s;
|
int s;
|
||||||
struct region region;
|
region_t region;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if ((s = getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
|
@ -45,18 +40,15 @@ int killregion(int f, int n)
|
||||||
return ldelete(region.r_size, TRUE);
|
return ldelete(region.r_size, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Copy all of the characters in the region to the kill buffer. Don't move
|
||||||
* Copy all of the characters in the
|
* dot at all. This is a bit like a kill region followed by a yank. Bound
|
||||||
* region to the kill buffer. Don't move dot
|
* to "M-W".
|
||||||
* at all. This is a bit like a kill region followed
|
|
||||||
* by a yank. Bound to "M-W".
|
|
||||||
*/
|
*/
|
||||||
int copyregion(int f, int n)
|
BINDABLE( copyregion) {
|
||||||
{
|
line_p linep;
|
||||||
struct line *linep;
|
|
||||||
int loffs;
|
int loffs;
|
||||||
int s;
|
int s;
|
||||||
struct region region;
|
region_t region;
|
||||||
|
|
||||||
if ((s = getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
return s;
|
return s;
|
||||||
|
@ -81,24 +73,18 @@ int copyregion(int f, int n)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Lower case region. Zap all of the upper case characters in the region
|
||||||
* Lower case region. Zap all of the upper
|
* to lower case. Use the region code to set the limits. Scan the buffer,
|
||||||
* case characters in the region to lower case. Use
|
* doing the changes. Call "lchange" to ensure that redisplay is done in
|
||||||
* the region code to set the limits. Scan the buffer,
|
* all buffers. Bound to "C-X C-L".
|
||||||
* doing the changes. Call "lchange" to ensure that
|
|
||||||
* redisplay is done in all buffers. Bound to
|
|
||||||
* "C-X C-L".
|
|
||||||
*/
|
*/
|
||||||
int lowerregion(int f, int n)
|
BINDABLE( lowerregion) {
|
||||||
{
|
line_p linep;
|
||||||
struct line *linep;
|
|
||||||
int loffs;
|
int loffs;
|
||||||
int c;
|
int c;
|
||||||
int s;
|
int s;
|
||||||
struct region region;
|
region_t region;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if ((s = getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
|
@ -120,24 +106,18 @@ int lowerregion(int f, int n)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Upper case region. Zap all of the lower case characters in the region
|
||||||
* Upper case region. Zap all of the lower
|
* to upper case. Use the region code to set the limits. Scan the buffer,
|
||||||
* case characters in the region to upper case. Use
|
* doing the changes. Call "lchange" to ensure that redisplay is done in
|
||||||
* the region code to set the limits. Scan the buffer,
|
* all buffers. Bound to "C-X C-L".
|
||||||
* doing the changes. Call "lchange" to ensure that
|
|
||||||
* redisplay is done in all buffers. Bound to
|
|
||||||
* "C-X C-L".
|
|
||||||
*/
|
*/
|
||||||
int upperregion(int f, int n)
|
BINDABLE( upperregion) {
|
||||||
{
|
line_p linep;
|
||||||
struct line *linep;
|
|
||||||
int loffs;
|
int loffs;
|
||||||
int c;
|
int c;
|
||||||
int s;
|
int s;
|
||||||
struct region region;
|
region_t region;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if ((s = getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
|
@ -159,23 +139,16 @@ int upperregion(int f, int n)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* This routine figures out the bounds of the region in the current window,
|
||||||
* This routine figures out the
|
* and fills in the fields of the "region_t" structure pointed to by "rp".
|
||||||
* bounds of the region in the current window, and
|
* Because the dot and mark are usually very close together, we scan
|
||||||
* fills in the fields of the "struct region" structure pointed
|
* outward from dot looking for mark. This should save time. Return a
|
||||||
* to by "rp". Because the dot and mark are usually very
|
* standard code. Callers of this routine should be prepared to get an
|
||||||
* close together, we scan outward from dot looking for
|
* "ABORT" status; we might make this have the conform thing later.
|
||||||
* mark. This should save time. Return a standard code.
|
|
||||||
* Callers of this routine should be prepared to get
|
|
||||||
* an "ABORT" status; we might make this have the
|
|
||||||
* conform thing later.
|
|
||||||
*/
|
*/
|
||||||
int getregion(struct region *rp)
|
int getregion( region_p rp) {
|
||||||
{
|
line_p flp, blp ;
|
||||||
struct line *flp;
|
long fsize, bsize ;
|
||||||
struct line *blp;
|
|
||||||
long fsize;
|
|
||||||
long bsize;
|
|
||||||
|
|
||||||
if (curwp->w_markp == NULL) {
|
if (curwp->w_markp == NULL) {
|
||||||
mloutstr( "No mark set in this window") ;
|
mloutstr( "No mark set in this window") ;
|
||||||
|
@ -223,3 +196,5 @@ int getregion(struct region *rp)
|
||||||
mloutstr( "Bug: lost mark") ;
|
mloutstr( "Bug: lost mark") ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* end of region.c */
|
||||||
|
|
27
region.h
27
region.h
|
@ -1,3 +1,4 @@
|
||||||
|
/* region.h -- a region starts at the mark and end at the dot */
|
||||||
#ifndef _REGION_H_
|
#ifndef _REGION_H_
|
||||||
#define _REGION_H_
|
#define _REGION_H_
|
||||||
|
|
||||||
|
@ -7,16 +8,22 @@
|
||||||
* The starting position of a region, and the size of the region in
|
* The starting position of a region, and the size of the region in
|
||||||
* characters, is kept in a region structure. Used by the region commands.
|
* characters, is kept in a region structure. Used by the region commands.
|
||||||
*/
|
*/
|
||||||
struct region {
|
typedef struct {
|
||||||
struct line *r_linep; /* Origin struct line address. */
|
line_p r_linep ; /* Origin struct line address. */
|
||||||
int r_offset; /* Origin struct line offset. */
|
int r_offset ; /* Origin struct line offset. */
|
||||||
long r_size; /* Length in characters. */
|
long r_size ; /* Length in characters. */
|
||||||
};
|
} region_t ;
|
||||||
|
|
||||||
int killregion( int f, int n) ;
|
typedef region_t *region_p ;
|
||||||
int copyregion( int f, int n) ;
|
|
||||||
int lowerregion( int f, int n) ;
|
/* Bindable functions */
|
||||||
int upperregion( int f, int n) ;
|
BINDABLE( killregion) ;
|
||||||
int getregion( struct region *rp) ;
|
BINDABLE( copyregion) ;
|
||||||
|
BINDABLE( lowerregion) ;
|
||||||
|
BINDABLE( upperregion) ;
|
||||||
|
|
||||||
|
int getregion( region_p rp) ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of region.h */
|
||||||
|
|
70
search.c
70
search.c
|
@ -87,7 +87,7 @@
|
||||||
unsigned int matchlen = 0 ;
|
unsigned int matchlen = 0 ;
|
||||||
static unsigned int mlenold = 0 ;
|
static unsigned int mlenold = 0 ;
|
||||||
char *patmatch = NULL ;
|
char *patmatch = NULL ;
|
||||||
static struct line *matchline = NULL;
|
static line_p matchline = NULL;
|
||||||
static int matchoff = 0;
|
static int matchoff = 0;
|
||||||
|
|
||||||
spat_t pat ; /* Search pattern */
|
spat_t pat ; /* Search pattern */
|
||||||
|
@ -165,10 +165,10 @@ static struct magic_replacement rmcpat[NPAT]; /* The replacement magic array. */
|
||||||
static int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ;
|
static int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *pcwoff);
|
static int amatch(struct magic *mcptr, int direct, line_p *pcwline, int *pcwoff);
|
||||||
static int readpattern(char *prompt, char *apat, int srch);
|
static int readpattern(char *prompt, char *apat, int srch);
|
||||||
static int replaces(int kind, int f, int n);
|
static int replaces(int kind, int f, int n);
|
||||||
static int nextch(struct line **pcurline, int *pcuroff, int dir);
|
static int nextch( line_p *pcurline, int *pcuroff, int dir);
|
||||||
static int mcstr(void);
|
static int mcstr(void);
|
||||||
static int rmcstr(void);
|
static int rmcstr(void);
|
||||||
static int mceq(int bc, struct magic *mt);
|
static int mceq(int bc, struct magic *mt);
|
||||||
|
@ -390,7 +390,7 @@ int backhunt(int f, int n)
|
||||||
*/
|
*/
|
||||||
static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
||||||
{
|
{
|
||||||
struct line *curline; /* current line during scan */
|
line_p curline; /* current line during scan */
|
||||||
int curoff; /* position within current line */
|
int curoff; /* position within current line */
|
||||||
|
|
||||||
/* If we are going in reverse, then the 'end' is actually
|
/* If we are going in reverse, then the 'end' is actually
|
||||||
|
@ -413,7 +413,7 @@ static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
||||||
|
|
||||||
/* Scan each character until we hit the head link record.
|
/* Scan each character until we hit the head link record.
|
||||||
*/
|
*/
|
||||||
while (!boundry(curline, curoff, direct)) {
|
while (!boundary(curline, curoff, direct)) {
|
||||||
/* Save the current position in case we need to
|
/* Save the current position in case we need to
|
||||||
* restore it on a match, and initialize matchlen to
|
* restore it on a match, and initialize matchlen to
|
||||||
* zero in case we are doing a search for replacement.
|
* zero in case we are doing a search for replacement.
|
||||||
|
@ -454,13 +454,13 @@ static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
||||||
*
|
*
|
||||||
* struct magic *mcptr; string to scan for
|
* struct magic *mcptr; string to scan for
|
||||||
* int direct; which way to go.
|
* int direct; which way to go.
|
||||||
* struct line **pcwline; current line during scan
|
* line_p *pcwline; current line during scan
|
||||||
* int *pcwoff; position within current line
|
* int *pcwoff; position within current line
|
||||||
*/
|
*/
|
||||||
static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *pcwoff)
|
static int amatch(struct magic *mcptr, int direct, line_p *pcwline, int *pcwoff)
|
||||||
{
|
{
|
||||||
int c; /* character at current position */
|
int c; /* character at current position */
|
||||||
struct line *curline; /* current line during scan */
|
line_p curline; /* current line during scan */
|
||||||
int curoff; /* position within current line */
|
int curoff; /* position within current line */
|
||||||
int nchars;
|
int nchars;
|
||||||
|
|
||||||
|
@ -600,9 +600,9 @@ int scanner(const char *patrn, int direct, int beg_or_end)
|
||||||
{
|
{
|
||||||
int c; /* character at current position */
|
int c; /* character at current position */
|
||||||
const char *patptr; /* pointer into pattern */
|
const char *patptr; /* pointer into pattern */
|
||||||
struct line *curline; /* current line during scan */
|
line_p curline; /* current line during scan */
|
||||||
int curoff; /* position within current line */
|
int curoff; /* position within current line */
|
||||||
struct line *scanline; /* current line during scanning */
|
line_p scanline; /* current line during scanning */
|
||||||
int scanoff; /* position in scanned line */
|
int scanoff; /* position in scanned line */
|
||||||
|
|
||||||
/* If we are going in reverse, then the 'end' is actually
|
/* If we are going in reverse, then the 'end' is actually
|
||||||
|
@ -617,7 +617,7 @@ int scanner(const char *patrn, int direct, int beg_or_end)
|
||||||
|
|
||||||
/* Scan each character until we hit the head link record.
|
/* Scan each character until we hit the head link record.
|
||||||
*/
|
*/
|
||||||
while (!boundry(curline, curoff, direct)) {
|
while (!boundary(curline, curoff, direct)) {
|
||||||
/* Save the current position in case we match
|
/* Save the current position in case we match
|
||||||
* the search string at this point.
|
* the search string at this point.
|
||||||
*/
|
*/
|
||||||
|
@ -749,7 +749,7 @@ static int readpattern(char *prompt, char *apat, int srch)
|
||||||
void savematch(void)
|
void savematch(void)
|
||||||
{
|
{
|
||||||
char *ptr; /* pointer to last match string */
|
char *ptr; /* pointer to last match string */
|
||||||
struct line *curline; /* line of last match */
|
line_p curline; /* line of last match */
|
||||||
int curoff; /* offset " " */
|
int curoff; /* offset " " */
|
||||||
|
|
||||||
/* Free any existing match string, then
|
/* Free any existing match string, then
|
||||||
|
@ -828,17 +828,15 @@ static int replaces(int kind, int f, int n)
|
||||||
int nlrepl; /* was a replace done on the last line? */
|
int nlrepl; /* was a replace done on the last line? */
|
||||||
char c; /* input char for query */
|
char c; /* input char for query */
|
||||||
spat_t tpat ; /* temporary to hold search pattern */
|
spat_t tpat ; /* temporary to hold search pattern */
|
||||||
struct line *origline; /* original "." position */
|
line_p origline; /* original "." position */
|
||||||
int origoff; /* and offset (for . query option) */
|
int origoff; /* and offset (for . query option) */
|
||||||
struct line *lastline; /* position of last replace and */
|
line_p lastline; /* position of last replace and */
|
||||||
int lastoff; /* offset (for 'u' query option) */
|
int lastoff; /* offset (for 'u' query option) */
|
||||||
|
|
||||||
///* rfi */
|
///* rfi */
|
||||||
lastline = NULL ;
|
lastline = NULL ;
|
||||||
lastoff = 0 ;
|
lastoff = 0 ;
|
||||||
|
|
||||||
// if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly(); /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
/* Check for negative repetitions.
|
/* Check for negative repetitions.
|
||||||
|
@ -1116,25 +1114,23 @@ int expandp(char *srcstr, char *deststr, int maxlength)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* boundry -- Return information depending on whether we may search no
|
|
||||||
* further. Beginning of file and end of file are the obvious
|
|
||||||
* cases, but we may want to add further optional boundry restrictions
|
|
||||||
* in future, a' la VMS EDT. At the moment, just return TRUE or
|
|
||||||
* FALSE depending on if a boundry is hit (ouch).
|
|
||||||
*/
|
|
||||||
int boundry(struct line *curline, int curoff, int dir)
|
|
||||||
{
|
|
||||||
int border;
|
|
||||||
|
|
||||||
if (dir == FORWARD) {
|
/* boundary -- Returns information depending on whether we may search no
|
||||||
border = (curoff == llength(curline)) &&
|
further. Beginning of file and end of file are the obvious cases, but
|
||||||
(lforw(curline) == curbp->b_linep);
|
we may want to add further optional boundary restrictions in future, a'
|
||||||
} else {
|
la VMS EDT. At the moment, just return TRUE or FALSE depending on if a
|
||||||
border = (curoff == 0) &&
|
boundary is hit (ouch).
|
||||||
(lback(curline) == curbp->b_linep);
|
*/
|
||||||
}
|
int boundary( line_p curline, int curoff, int dir) {
|
||||||
return border;
|
int border ;
|
||||||
|
|
||||||
|
if( dir == FORWARD)
|
||||||
|
border = (curoff == llength( curline)) &&
|
||||||
|
(lforw( curline) == curbp->b_linep) ;
|
||||||
|
else
|
||||||
|
border = (curoff == 0) && (lback( curline) == curbp->b_linep) ;
|
||||||
|
|
||||||
|
return border ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1145,9 +1141,9 @@ int boundry(struct line *curline, int curoff, int dir)
|
||||||
* the current character and move, reverse searches move and
|
* the current character and move, reverse searches move and
|
||||||
* look at the character.
|
* look at the character.
|
||||||
*/
|
*/
|
||||||
static int nextch(struct line **pcurline, int *pcuroff, int dir)
|
static int nextch( line_p *pcurline, int *pcuroff, int dir)
|
||||||
{
|
{
|
||||||
struct line *curline;
|
line_p curline;
|
||||||
int curoff;
|
int curoff;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
@ -1606,3 +1602,5 @@ static void setbit(int bc, char *cclmap)
|
||||||
*(cclmap + (bc >> 3)) |= BIT(bc & 7);
|
*(cclmap + (bc >> 3)) |= BIT(bc & 7);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of search.c */
|
||||||
|
|
20
search.h
20
search.h
|
@ -1,3 +1,5 @@
|
||||||
|
/* search.h -- */
|
||||||
|
|
||||||
#ifndef _SEARCH_H_
|
#ifndef _SEARCH_H_
|
||||||
#define _SEARCH_H_
|
#define _SEARCH_H_
|
||||||
|
|
||||||
|
@ -26,18 +28,20 @@ extern spat_t rpat ; /* replacement pattern */
|
||||||
|
|
||||||
int scanner( const char *patrn, int direct, int beg_or_end) ;
|
int scanner( const char *patrn, int direct, int beg_or_end) ;
|
||||||
|
|
||||||
int forwsearch( int f, int n) ;
|
/* Bindable functions */
|
||||||
int forwhunt( int f, int n) ;
|
BINDABLE( forwsearch) ;
|
||||||
int backsearch( int f, int n) ;
|
BINDABLE( forwhunt) ;
|
||||||
int backhunt( int f, int n) ;
|
BINDABLE( backsearch) ;
|
||||||
|
BINDABLE( backhunt) ;
|
||||||
|
BINDABLE( sreplace) ;
|
||||||
|
BINDABLE( qreplace) ;
|
||||||
|
|
||||||
int eq( unsigned char bc, unsigned char pc) ;
|
int eq( unsigned char bc, unsigned char pc) ;
|
||||||
void savematch( void) ;
|
void savematch( void) ;
|
||||||
void rvstrcpy( char *rvstr, char *str) ;
|
void rvstrcpy( char *rvstr, char *str) ;
|
||||||
int sreplace( int f, int n) ;
|
|
||||||
int qreplace( int f, int n) ;
|
|
||||||
int delins( int dlength, char *instr, int use_meta) ;
|
int delins( int dlength, char *instr, int use_meta) ;
|
||||||
int expandp( char *srcstr, char *deststr, int maxlength) ;
|
int expandp( char *srcstr, char *deststr, int maxlength) ;
|
||||||
int boundry( struct line *curline, int curoff, int dir) ;
|
int boundary( line_p curline, int curoff, int dir) ;
|
||||||
|
|
||||||
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) ;
|
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) ;
|
||||||
|
|
||||||
|
@ -47,3 +51,5 @@ void rmcclear( void) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of search.h */
|
||||||
|
|
6
spawn.c
6
spawn.c
|
@ -183,7 +183,7 @@ int execprg( int f, int n) {
|
||||||
int pipecmd( int f, int n) {
|
int pipecmd( int f, int n) {
|
||||||
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 */
|
||||||
struct buffer *bp ; /* pointer to buffer to zot */
|
buffer_p bp ; /* pointer to buffer to zot */
|
||||||
char *mlarg ;
|
char *mlarg ;
|
||||||
char *line ; /* command line send to shell */
|
char *line ; /* command line send to shell */
|
||||||
static char bname[] = "command" ;
|
static char bname[] = "command" ;
|
||||||
|
@ -277,7 +277,7 @@ int pipecmd( int f, int n) {
|
||||||
*/
|
*/
|
||||||
int filter_buffer( int f, int n) {
|
int filter_buffer( int f, int n) {
|
||||||
int s ; /* return status from CLI */
|
int s ; /* return status from CLI */
|
||||||
struct buffer *bp ; /* pointer to buffer to zot */
|
buffer_p bp ; /* pointer to buffer to zot */
|
||||||
char *mlarg ;
|
char *mlarg ;
|
||||||
char *line ; /* command line send to shell */
|
char *line ; /* command line send to shell */
|
||||||
fname_t tmpnam ; /* place to store real file name */
|
fname_t tmpnam ; /* place to store real file name */
|
||||||
|
@ -290,8 +290,6 @@ int filter_buffer( int f, int n) {
|
||||||
if( restflag)
|
if( restflag)
|
||||||
return resterr() ;
|
return resterr() ;
|
||||||
|
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
/* get the filter name and its args */
|
/* get the filter name and its args */
|
||||||
|
|
20
spawn.h
20
spawn.h
|
@ -1,7 +1,15 @@
|
||||||
int spawncli( int f, int n) ;
|
/* spawn.h -- various operating system access commands */
|
||||||
int bktoshell( int f, int n) ;
|
|
||||||
|
#include "names.h"
|
||||||
|
|
||||||
|
/* Bindable functions */
|
||||||
|
BINDABLE( spawncli) ;
|
||||||
|
BINDABLE( bktoshell) ;
|
||||||
|
BINDABLE( spawn) ;
|
||||||
|
BINDABLE( execprg) ;
|
||||||
|
BINDABLE( pipecmd) ;
|
||||||
|
BINDABLE( filter_buffer) ;
|
||||||
|
|
||||||
void rtfrmshell( void) ;
|
void rtfrmshell( void) ;
|
||||||
int spawn( int f, int n) ;
|
|
||||||
int execprg( int f, int n) ;
|
/* end of spawn.h */
|
||||||
int pipecmd( int f, int n) ;
|
|
||||||
int filter_buffer( int f, int n) ;
|
|
||||||
|
|
32
word.c
32
word.c
|
@ -11,7 +11,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memcpy */
|
#include <string.h> /* memcpy */
|
||||||
|
|
||||||
|
@ -152,9 +151,6 @@ static boolean uniflip( boolean toupper_f) { /* flip unicode case and forward */
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean capcapword( int n, boolean first_f, boolean rest_f) {
|
static boolean capcapword( int n, boolean first_f, boolean rest_f) {
|
||||||
// if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
|
||||||
// return rdonly() ; /* we are in read only mode */
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
if( n < 0)
|
if( n < 0)
|
||||||
|
@ -210,14 +206,9 @@ int capword( int f, int n) {
|
||||||
*/
|
*/
|
||||||
int delfword(int f, int n)
|
int delfword(int f, int n)
|
||||||
{
|
{
|
||||||
struct line *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 */
|
||||||
long size; /* # of chars to delete */
|
|
||||||
|
|
||||||
// /* don't allow this command if we are in read only mode */
|
|
||||||
// if (curbp->b_mode & MDVIEW)
|
|
||||||
// return rdonly();
|
|
||||||
|
|
||||||
assert( !(curbp->b_mode & MDVIEW)) ;
|
assert( !(curbp->b_mode & MDVIEW)) ;
|
||||||
|
|
||||||
|
@ -235,7 +226,7 @@ int delfword(int f, int n)
|
||||||
doto = curwp->w_doto;
|
doto = curwp->w_doto;
|
||||||
|
|
||||||
/* figure out how many characters to give the axe */
|
/* figure out how many characters to give the axe */
|
||||||
size = 0;
|
long size = 0 ;
|
||||||
|
|
||||||
/* get us into a word.... */
|
/* get us into a word.... */
|
||||||
while (inword() == FALSE) {
|
while (inword() == FALSE) {
|
||||||
|
@ -301,12 +292,6 @@ int delfword(int f, int n)
|
||||||
*/
|
*/
|
||||||
int delbword(int f, int n)
|
int delbword(int f, int n)
|
||||||
{
|
{
|
||||||
long size;
|
|
||||||
|
|
||||||
// /* don't allow this command if we are in read only mode */
|
|
||||||
// if (curbp->b_mode & MDVIEW)
|
|
||||||
// return rdonly();
|
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -320,7 +305,8 @@ int delbword(int f, int n)
|
||||||
|
|
||||||
if (backchar(FALSE, 1) == FALSE)
|
if (backchar(FALSE, 1) == FALSE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
size = 0;
|
|
||||||
|
long size = 0 ;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
while (inword() == FALSE) {
|
while (inword() == FALSE) {
|
||||||
if (backchar(FALSE, 1) == FALSE)
|
if (backchar(FALSE, 1) == FALSE)
|
||||||
|
@ -352,7 +338,6 @@ static int inword( void) {
|
||||||
return isletter( c) || ( c >= '0' && c <= '9') ;
|
return isletter( c) || ( c >= '0' && c <= '9') ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WORDPRO
|
|
||||||
static int parafillnjustify( int f, int n, int justify_f) {
|
static int parafillnjustify( int f, int n, int justify_f) {
|
||||||
unicode_t c; /* current char during scan */
|
unicode_t c; /* current char during scan */
|
||||||
unicode_t *wbuf ; /* buffer for current word */
|
unicode_t *wbuf ; /* buffer for current word */
|
||||||
|
@ -361,7 +346,7 @@ static int parafillnjustify( int f, int n, int justify_f) {
|
||||||
int clength; /* position on line during fill */
|
int clength; /* position on line during fill */
|
||||||
int eopflag; /* Are we at the End-Of-Paragraph? */
|
int eopflag; /* Are we at the End-Of-Paragraph? */
|
||||||
int firstflag = TRUE ; /* first word? (needs no space) */
|
int firstflag = TRUE ; /* first word? (needs no space) */
|
||||||
struct line *eopline; /* pointer to line just past EOP */
|
line_p eopline; /* pointer to line just past EOP */
|
||||||
int dotflag = 0 ; /* was the last char a period? */
|
int dotflag = 0 ; /* was the last char a period? */
|
||||||
int leftmarg = 0 ; /* left marginal */
|
int leftmarg = 0 ; /* left marginal */
|
||||||
|
|
||||||
|
@ -549,7 +534,7 @@ int killpara(int f, int n)
|
||||||
*/
|
*/
|
||||||
int wordcount(int f, int n)
|
int wordcount(int f, int n)
|
||||||
{
|
{
|
||||||
struct line *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 */
|
||||||
int ch; /* current character to scan */
|
int ch; /* current character to scan */
|
||||||
|
@ -560,10 +545,10 @@ int wordcount(int f, int n)
|
||||||
int nlines; /* total number of lines in region */
|
int nlines; /* total number of lines in region */
|
||||||
int avgch; /* average number of chars/word */
|
int avgch; /* average number of chars/word */
|
||||||
int status; /* status return code */
|
int status; /* status return code */
|
||||||
struct region region; /* region to look at */
|
region_t region ; /* region to look at */
|
||||||
|
|
||||||
/* make sure we have a region to count */
|
/* make sure we have a region to count */
|
||||||
if ((status = getregion(®ion)) != TRUE)
|
if( (status = getregion( ®ion)) != TRUE)
|
||||||
return status;
|
return status;
|
||||||
lp = region.r_linep;
|
lp = region.r_linep;
|
||||||
offset = region.r_offset;
|
offset = region.r_offset;
|
||||||
|
@ -684,6 +669,5 @@ int gotoeop(int f, int n)
|
||||||
curwp->w_flag |= WFMOVE; /* force screen update */
|
curwp->w_flag |= WFMOVE; /* force screen update */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of word.c */
|
/* end of word.c */
|
||||||
|
|
36
word.h
36
word.h
|
@ -1,23 +1,25 @@
|
||||||
|
/* word.h -- word processing functions */
|
||||||
#ifndef _WORD_H_
|
#ifndef _WORD_H_
|
||||||
#define _WORD_H_
|
#define _WORD_H_
|
||||||
|
|
||||||
#define WORDPRO 1
|
#include "names.h"
|
||||||
|
|
||||||
int wrapword( int f, int n) ;
|
/* Bindable functions */
|
||||||
int backword( int f, int n) ;
|
BINDABLE( wrapword) ;
|
||||||
int forwword( int f, int n) ;
|
BINDABLE( backword) ;
|
||||||
int upperword( int f, int n) ;
|
BINDABLE( forwword) ;
|
||||||
int lowerword( int f, int n) ;
|
BINDABLE( upperword) ;
|
||||||
int capword( int f, int n) ;
|
BINDABLE( lowerword) ;
|
||||||
int delfword( int f, int n) ;
|
BINDABLE( capword) ;
|
||||||
int delbword( int f, int n) ;
|
BINDABLE( delfword) ;
|
||||||
#if WORDPRO
|
BINDABLE( delbword) ;
|
||||||
int gotobop( int f, int n) ;
|
BINDABLE( gotobop) ;
|
||||||
int gotoeop( int f, int n) ;
|
BINDABLE( gotoeop) ;
|
||||||
int fillpara( int f, int n) ;
|
BINDABLE( fillpara) ;
|
||||||
int justpara( int f, int n) ;
|
BINDABLE( justpara) ;
|
||||||
int killpara( int f, int n) ;
|
BINDABLE( killpara) ;
|
||||||
int wordcount( int f, int n) ;
|
BINDABLE( wordcount) ;
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of word.h */
|
||||||
|
|
Loading…
Reference in New Issue