mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 23:36:23 -05:00
review line dependencies.
This commit is contained in:
parent
287c55cbac
commit
4f9598b5da
2
Makefile
2
Makefile
@ -155,7 +155,7 @@ input.o: input.c input.h edef.h estruct.h line.h utf8.h bind.h bindable.h \
|
||||
display.h exec.h names.h wrapper.h
|
||||
isearch.o: isearch.c isearch.h basic.h display.h estruct.h line.h utf8.h \
|
||||
edef.h input.h search.h
|
||||
line.o: line.c line.h utf8.h basic.h display.h estruct.h edef.h random.h
|
||||
line.o: line.c line.h utf8.h display.h estruct.h edef.h
|
||||
lock.o: lock.c lock.h estruct.h line.h utf8.h display.h edef.h input.h
|
||||
main.o: main.c basic.h bind.h edef.h estruct.h line.h utf8.h bindable.h \
|
||||
buffer.h display.h eval.h execute.h file.h input.h lock.h random.h \
|
||||
|
63
basic.c
63
basic.c
@ -69,38 +69,6 @@ int gotobol(int f, int n)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the cursor backwards by "n" characters. If "n" is less than zero call
|
||||
* "forwchar" to actually do the move. Otherwise compute the new cursor
|
||||
* location. Error if you try and move out of the buffer. Set the flag if the
|
||||
* line pointer for dot changes.
|
||||
*/
|
||||
int backchar(int f, int n)
|
||||
{
|
||||
struct line *lp;
|
||||
|
||||
if (n < 0)
|
||||
return forwchar(f, -n);
|
||||
while (n--) {
|
||||
if (curwp->w_doto == 0) {
|
||||
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
|
||||
return FALSE;
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = llength(lp);
|
||||
curwp->w_flag |= WFMOVE;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto--;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the cursor to the end of the current line. Trivial. No errors.
|
||||
*/
|
||||
@ -110,37 +78,6 @@ int gotoeol(int f, int n)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the cursor forwards by "n" characters. If "n" is less than zero call
|
||||
* "backchar" to actually do the move. Otherwise compute the new cursor
|
||||
* location, and move ".". Error if you try and move off the end of the
|
||||
* buffer. Set the flag if the line pointer for dot changes.
|
||||
*/
|
||||
int forwchar(int f, int n)
|
||||
{
|
||||
if (n < 0)
|
||||
return backchar(f, -n);
|
||||
while (n--) {
|
||||
int len = llength(curwp->w_dotp);
|
||||
if (curwp->w_doto == len) {
|
||||
if (curwp->w_dotp == curbp->b_linep)
|
||||
return FALSE;
|
||||
curwp->w_dotp = lforw(curwp->w_dotp);
|
||||
curwp->w_doto = 0;
|
||||
curwp->w_flag |= WFMOVE;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto++;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto < len);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move to a particular line.
|
||||
*
|
||||
|
2
basic.h
2
basic.h
@ -2,9 +2,7 @@
|
||||
#define _BASIC_H_
|
||||
|
||||
int gotobol( int f, int n) ;
|
||||
int backchar( int f, int n) ;
|
||||
int gotoeol( int f, int n) ;
|
||||
int forwchar( int f, int n) ;
|
||||
int gotoline( int f, int n) ;
|
||||
int gotobob( int f, int n) ;
|
||||
int gotoeob( int f, int n) ;
|
||||
|
25
eval.c
25
eval.c
@ -229,6 +229,31 @@ static struct {
|
||||
/* User variables */
|
||||
static struct user_variable uv[MAXVARS + 1];
|
||||
|
||||
|
||||
/*
|
||||
* putctext:
|
||||
* replace the current line with the passed in text
|
||||
*
|
||||
* char *iline; contents of new line
|
||||
*/
|
||||
static int putctext( char *iline)
|
||||
{
|
||||
int status;
|
||||
|
||||
/* delete the current line */
|
||||
curwp->w_doto = 0; /* starting at the beginning of the line */
|
||||
if ((status = killtext(TRUE, 1)) != TRUE)
|
||||
return status;
|
||||
|
||||
/* insert the new line */
|
||||
if ((status = linstr(iline)) != TRUE)
|
||||
return status;
|
||||
status = lnewline();
|
||||
backline(TRUE, 1);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the user variable list. */
|
||||
void varinit(void)
|
||||
{
|
||||
|
88
line.c
88
line.c
@ -17,17 +17,78 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "basic.h"
|
||||
#include "display.h"
|
||||
#include "estruct.h"
|
||||
#include "edef.h"
|
||||
#include "random.h"
|
||||
#include "utf8.h"
|
||||
|
||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||
|
||||
static int ldelnewline( void) ;
|
||||
|
||||
/*
|
||||
* Move the cursor backwards by "n" characters. If "n" is less than zero call
|
||||
* "forwchar" to actually do the move. Otherwise compute the new cursor
|
||||
* location. Error if you try and move out of the buffer. Set the flag if the
|
||||
* line pointer for dot changes.
|
||||
*/
|
||||
int backchar(int f, int n)
|
||||
{
|
||||
struct line *lp;
|
||||
|
||||
if (n < 0)
|
||||
return forwchar(f, -n);
|
||||
while (n--) {
|
||||
if (curwp->w_doto == 0) {
|
||||
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
|
||||
return FALSE;
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = llength(lp);
|
||||
curwp->w_flag |= WFMOVE;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto--;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the cursor forwards by "n" characters. If "n" is less than zero call
|
||||
* "backchar" to actually do the move. Otherwise compute the new cursor
|
||||
* location, and move ".". Error if you try and move off the end of the
|
||||
* buffer. Set the flag if the line pointer for dot changes.
|
||||
*/
|
||||
int forwchar(int f, int n)
|
||||
{
|
||||
if (n < 0)
|
||||
return backchar(f, -n);
|
||||
while (n--) {
|
||||
int len = llength(curwp->w_dotp);
|
||||
if (curwp->w_doto == len) {
|
||||
if (curwp->w_dotp == curbp->b_linep)
|
||||
return FALSE;
|
||||
curwp->w_dotp = lforw(curwp->w_dotp);
|
||||
curwp->w_doto = 0;
|
||||
curwp->w_flag |= WFMOVE;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto++;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto < len);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine allocates a block of memory large enough to hold a struct line
|
||||
* containing "used" characters. The block is always rounded up a bit. Return
|
||||
@ -485,29 +546,6 @@ char *getctext(void)
|
||||
return rline;
|
||||
}
|
||||
|
||||
/*
|
||||
* putctext:
|
||||
* replace the current line with the passed in text
|
||||
*
|
||||
* char *iline; contents of new line
|
||||
*/
|
||||
int putctext(char *iline)
|
||||
{
|
||||
int status;
|
||||
|
||||
/* delete the current line */
|
||||
curwp->w_doto = 0; /* starting at the beginning of the line */
|
||||
if ((status = killtext(TRUE, 1)) != TRUE)
|
||||
return status;
|
||||
|
||||
/* insert the new line */
|
||||
if ((status = linstr(iline)) != TRUE)
|
||||
return status;
|
||||
status = lnewline();
|
||||
backline(TRUE, 1);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a newline. Join the current line with the next line. If the next line
|
||||
* is the magic header line always return TRUE; merging the last line with the
|
||||
|
4
line.h
4
line.h
@ -25,6 +25,9 @@ struct line {
|
||||
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
|
||||
#define llength(lp) ((lp)->l_used)
|
||||
|
||||
int backchar( int f, int n) ;
|
||||
int forwchar( int f, int n) ;
|
||||
|
||||
void lfree( struct line *lp) ;
|
||||
void lchange( int flag) ;
|
||||
int insspace( int f, int n) ;
|
||||
@ -36,7 +39,6 @@ int ldelete( long n, int kflag) ;
|
||||
int ldelchar( long n, int kflag) ;
|
||||
int lgetchar( unicode_t *) ;
|
||||
char *getctext( void) ;
|
||||
int putctext( char *iline) ;
|
||||
void kdelete( void) ;
|
||||
int kinsert( int c) ;
|
||||
int yank( int f, int n) ;
|
||||
|
Loading…
Reference in New Issue
Block a user