mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Centralize kill buffer code in line.c
This commit is contained in:
parent
1de3e139bb
commit
9ec9176c81
4
edef.h
4
edef.h
@ -62,9 +62,7 @@ extern int abortc; /* current abort command char */
|
|||||||
extern int quotec; /* quote char during mlreply() */
|
extern int quotec; /* quote char during mlreply() */
|
||||||
extern int tabmask;
|
extern int tabmask;
|
||||||
extern char *cname[]; /* names of colors */
|
extern char *cname[]; /* names of colors */
|
||||||
extern struct kill *kbufp; /* current kill buffer chunk pointer */
|
|
||||||
extern struct kill *kbufh; /* kill buffer header pointer */
|
|
||||||
extern int kused; /* # of bytes used in KB */
|
|
||||||
extern struct window *swindow; /* saved window pointer */
|
extern struct window *swindow; /* saved window pointer */
|
||||||
extern int *kbdptr; /* current position in keyboard buf */
|
extern int *kbdptr; /* current position in keyboard buf */
|
||||||
extern int *kbdend; /* ptr to end of the keyboard */
|
extern int *kbdend; /* ptr to end of the keyboard */
|
||||||
|
12
estruct.h
12
estruct.h
@ -245,7 +245,6 @@
|
|||||||
#define HUGE 1000 /* Huge number */
|
#define HUGE 1000 /* Huge number */
|
||||||
#define NLOCKS 100 /* max # of file locks active */
|
#define NLOCKS 100 /* max # of file locks active */
|
||||||
#define NCOLORS 8 /* number of supported colors */
|
#define NCOLORS 8 /* number of supported colors */
|
||||||
#define KBLOCK 250 /* sizeof kill buffer chunks */
|
|
||||||
|
|
||||||
#define CONTROL 0x10000000 /* Control flag, or'ed in */
|
#define CONTROL 0x10000000 /* Control flag, or'ed in */
|
||||||
#define META 0x20000000 /* Meta flag, or'ed in */
|
#define META 0x20000000 /* Meta flag, or'ed in */
|
||||||
@ -414,15 +413,4 @@ struct terminal {
|
|||||||
#define TTbacg (*term.t_setback)
|
#define TTbacg (*term.t_setback)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The editor holds deleted text chunks in the struct kill buffer. The
|
|
||||||
* kill buffer is logically a stream of ascii characters, however
|
|
||||||
* due to its unpredicatable size, it gets implemented as a linked
|
|
||||||
* list of chunks. (The d_ prefix is for "deleted" text, as k_
|
|
||||||
* was taken up by the keycode structure).
|
|
||||||
*/
|
|
||||||
struct kill {
|
|
||||||
struct kill *d_next; /* Link to next chunk, NULL if last. */
|
|
||||||
char d_chunk[KBLOCK]; /* Deleted text. */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
26
eval.c
26
eval.c
@ -438,8 +438,6 @@ char *gtusr(char *vname)
|
|||||||
return errorm;
|
return errorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char *getkill(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gtenv()
|
* gtenv()
|
||||||
*
|
*
|
||||||
@ -569,30 +567,6 @@ char *gtenv(char *vname)
|
|||||||
exit(-12); /* again, we should never get here */
|
exit(-12); /* again, we should never get here */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* return some of the contents of the kill buffer
|
|
||||||
*/
|
|
||||||
char *getkill(void)
|
|
||||||
{
|
|
||||||
int size; /* max number of chars to return */
|
|
||||||
static char value[NSTRING]; /* temp buffer for value */
|
|
||||||
|
|
||||||
if (kbufh == NULL)
|
|
||||||
/* no kill buffer....just a null string */
|
|
||||||
value[0] = 0;
|
|
||||||
else {
|
|
||||||
/* copy in the contents... */
|
|
||||||
if (kused < NSTRING)
|
|
||||||
size = kused;
|
|
||||||
else
|
|
||||||
size = NSTRING - 1;
|
|
||||||
strncpy(value, kbufh->d_chunk, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and return the constructed value */
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set a variable
|
* set a variable
|
||||||
*
|
*
|
||||||
|
1
eval.h
1
eval.h
@ -21,7 +21,6 @@ void varinit( void) ;
|
|||||||
char *gtfun( char *fname) ;
|
char *gtfun( char *fname) ;
|
||||||
char *gtusr( char *vname) ;
|
char *gtusr( char *vname) ;
|
||||||
char *gtenv( char *vname) ;
|
char *gtenv( char *vname) ;
|
||||||
char *getkill( void) ;
|
|
||||||
int setvar( int f, int n) ;
|
int setvar( int f, int n) ;
|
||||||
char *itoa( int i) ;
|
char *itoa( int i) ;
|
||||||
char *getval( char *token) ;
|
char *getval( char *token) ;
|
||||||
|
@ -76,9 +76,7 @@ char *cname[] = { /* names of colors */
|
|||||||
, "HIGH"
|
, "HIGH"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
struct kill *kbufp = NULL; /* current kill buffer chunk pointer */
|
|
||||||
struct kill *kbufh = NULL; /* kill buffer header pointer */
|
|
||||||
int kused = KBLOCK; /* # of bytes used in kill buffer */
|
|
||||||
struct window *swindow = NULL; /* saved window pointer */
|
struct window *swindow = NULL; /* saved window pointer */
|
||||||
int *kbdptr; /* current position in keyboard buf */
|
int *kbdptr; /* current position in keyboard buf */
|
||||||
int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */
|
int *kbdend = &kbdm[0]; /* ptr to end of the keyboard */
|
||||||
|
42
line.c
42
line.c
@ -27,6 +27,48 @@
|
|||||||
|
|
||||||
static int ldelnewline( void) ;
|
static int ldelnewline( void) ;
|
||||||
|
|
||||||
|
/* The editor holds deleted text chunks in the struct kill buffer. The
|
||||||
|
* kill buffer is logically a stream of ascii characters, however
|
||||||
|
* due to its unpredicatable size, it gets implemented as a linked
|
||||||
|
* list of chunks. (The d_ prefix is for "deleted" text, as k_
|
||||||
|
* was taken up by the keycode structure).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define KBLOCK 250 /* sizeof kill buffer chunks */
|
||||||
|
|
||||||
|
struct kill {
|
||||||
|
struct kill *d_next; /* Link to next chunk, NULL if last. */
|
||||||
|
char d_chunk[KBLOCK]; /* Deleted text. */
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct kill *kbufp = NULL ; /* current kill buffer chunk pointer */
|
||||||
|
static struct kill *kbufh = NULL ; /* kill buffer header pointer */
|
||||||
|
static int kused = KBLOCK ; /* # of bytes used in kill buffer */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return some of the contents of the kill buffer
|
||||||
|
*/
|
||||||
|
char *getkill( void)
|
||||||
|
{
|
||||||
|
int size; /* max number of chars to return */
|
||||||
|
static char value[NSTRING]; /* temp buffer for value */
|
||||||
|
|
||||||
|
if (kbufh == NULL)
|
||||||
|
/* no kill buffer....just a null string */
|
||||||
|
value[0] = 0;
|
||||||
|
else {
|
||||||
|
/* copy in the contents... */
|
||||||
|
if (kused < NSTRING)
|
||||||
|
size = kused;
|
||||||
|
else
|
||||||
|
size = NSTRING - 1;
|
||||||
|
strncpy(value, kbufh->d_chunk, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* and return the constructed value */
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the cursor backwards by "n" characters. If "n" is less than zero call
|
* Move the cursor backwards by "n" characters. If "n" is less than zero call
|
||||||
* "forwchar" to actually do the move. Otherwise compute the new cursor
|
* "forwchar" to actually do the move. Otherwise compute the new cursor
|
||||||
|
2
line.h
2
line.h
@ -25,6 +25,8 @@ struct line {
|
|||||||
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
|
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
|
||||||
#define llength(lp) ((lp)->l_used)
|
#define llength(lp) ((lp)->l_used)
|
||||||
|
|
||||||
|
char *getkill( void) ;
|
||||||
|
|
||||||
int backchar( int f, int n) ;
|
int backchar( int f, int n) ;
|
||||||
int forwchar( int f, int n) ;
|
int forwchar( int f, int n) ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user