mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-17 18:16:22 -05:00
Review cursor move commands in basic.
This commit is contained in:
parent
14e6240b9c
commit
7e71cf52a3
24
Makefile
24
Makefile
@ -129,8 +129,8 @@ depend: ${SRC}
|
|||||||
|
|
||||||
# DO NOT DELETE THIS LINE -- make depend uses it
|
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||||
|
|
||||||
basic.o: basic.c basic.h buffer.h line.h retcode.h utf8.h estruct.h \
|
basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \
|
||||||
input.h bind.h mlout.h random.h terminal.h defines.h window.h
|
terminal.h defines.h utf8.h window.h buffer.h line.h
|
||||||
bind.o: bind.c bind.h estruct.h bindable.h buffer.h line.h retcode.h \
|
bind.o: bind.c bind.h estruct.h bindable.h buffer.h line.h retcode.h \
|
||||||
utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h window.h \
|
utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h window.h \
|
||||||
defines.h
|
defines.h
|
||||||
@ -142,10 +142,10 @@ buffer.o: buffer.c buffer.h line.h retcode.h utf8.h defines.h estruct.h \
|
|||||||
display.o: display.c display.h estruct.h utf8.h buffer.h line.h retcode.h \
|
display.o: display.c display.h estruct.h utf8.h buffer.h line.h retcode.h \
|
||||||
input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \
|
input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \
|
||||||
window.h
|
window.h
|
||||||
ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \
|
ebind.o: ebind.c ebind.h basic.h retcode.h bind.h estruct.h bindable.h \
|
||||||
line.h retcode.h utf8.h eval.h exec.h file.h isearch.h random.h region.h \
|
buffer.h line.h utf8.h eval.h exec.h file.h isearch.h random.h region.h \
|
||||||
search.h spawn.h window.h defines.h word.h
|
search.h spawn.h window.h defines.h word.h
|
||||||
eval.o: eval.c eval.h basic.h bind.h buffer.h line.h retcode.h utf8.h \
|
eval.o: eval.c eval.h basic.h retcode.h bind.h buffer.h line.h utf8.h \
|
||||||
display.h estruct.h exec.h execute.h flook.h input.h random.h search.h \
|
display.h estruct.h exec.h execute.h flook.h input.h random.h search.h \
|
||||||
terminal.h defines.h termio.h version.h window.h
|
terminal.h defines.h termio.h version.h window.h
|
||||||
exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \
|
exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \
|
||||||
@ -160,19 +160,19 @@ fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
|
|||||||
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
||||||
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
||||||
exec.h retcode.h names.h terminal.h defines.h wrapper.h
|
exec.h retcode.h names.h terminal.h defines.h wrapper.h
|
||||||
isearch.o: isearch.c isearch.h basic.h buffer.h line.h retcode.h utf8.h \
|
isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
|
||||||
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
||||||
window.h
|
window.h
|
||||||
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
|
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
|
||||||
window.h defines.h
|
window.h defines.h
|
||||||
lock.o: lock.c estruct.h lock.h
|
lock.o: lock.c estruct.h lock.h
|
||||||
main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h line.h \
|
main.o: main.c estruct.h basic.h retcode.h bind.h bindable.h buffer.h \
|
||||||
retcode.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h \
|
line.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h random.h \
|
||||||
random.h search.h terminal.h defines.h termio.h version.h window.h
|
search.h terminal.h defines.h termio.h version.h window.h
|
||||||
mingw32.o: mingw32.c
|
mingw32.o: mingw32.c
|
||||||
mlout.o: mlout.c mlout.h
|
mlout.o: mlout.c mlout.h
|
||||||
names.o: names.c names.h basic.h bind.h bindable.h buffer.h line.h \
|
names.o: names.c names.h basic.h retcode.h bind.h bindable.h buffer.h \
|
||||||
retcode.h utf8.h display.h estruct.h eval.h exec.h file.h isearch.h \
|
line.h utf8.h display.h estruct.h eval.h exec.h file.h isearch.h \
|
||||||
region.h random.h search.h spawn.h window.h defines.h word.h
|
region.h random.h search.h spawn.h window.h defines.h word.h
|
||||||
pklock.o: pklock.c estruct.h pklock.h
|
pklock.o: pklock.c estruct.h pklock.h
|
||||||
posix.o: posix.c
|
posix.o: posix.c
|
||||||
@ -192,7 +192,7 @@ termio.o: termio.c termio.h utf8.h estruct.h retcode.h
|
|||||||
utf8.o: utf8.c utf8.h
|
utf8.o: utf8.c utf8.h
|
||||||
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
||||||
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
||||||
word.o: word.c word.h basic.h buffer.h line.h retcode.h utf8.h estruct.h \
|
word.o: word.c word.h basic.h retcode.h buffer.h line.h utf8.h estruct.h \
|
||||||
mlout.h random.h region.h window.h defines.h
|
mlout.h random.h region.h window.h defines.h
|
||||||
wrapper.o: wrapper.c wrapper.h
|
wrapper.o: wrapper.c wrapper.h
|
||||||
wscreen.o: wscreen.c wscreen.h
|
wscreen.o: wscreen.c wscreen.h
|
||||||
|
295
basic.c
295
basic.c
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "basic.h"
|
#include "basic.h"
|
||||||
|
|
||||||
#define CVMVAS 1 /* arguments to page forward/back in pages */
|
|
||||||
|
|
||||||
/* basic.c
|
/* basic.c
|
||||||
*
|
*
|
||||||
* The routines in this file move the cursor around on the screen. They
|
* The routines in this file move the cursor around on the screen. They
|
||||||
@ -18,18 +16,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "estruct.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "line.h"
|
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "utf8.h"
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
int overlap = 0 ; /* line overlap in forw/back page */
|
#define CVMVAS 1 /* arguments to page forward/back in pages */
|
||||||
|
|
||||||
|
|
||||||
|
int overlap = DEFAULT_OVERLAP ; /* line overlap in forw/back page */
|
||||||
int curgoal ; /* Goal for C-P, C-N */
|
int curgoal ; /* Goal for C-P, C-N */
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +35,7 @@ int curgoal ; /* Goal for C-P, C-N */
|
|||||||
* column, return the best choice for the offset. The offset is returned.
|
* column, return the best choice for the offset. The offset is returned.
|
||||||
* Used by "C-N" and "C-P".
|
* Used by "C-N" and "C-P".
|
||||||
*/
|
*/
|
||||||
static unsigned getgoal( struct line *dlp) {
|
static unsigned getgoal( line_p dlp) {
|
||||||
int col ;
|
int col ;
|
||||||
unsigned idx ;
|
unsigned idx ;
|
||||||
const unsigned len = llength( dlp) ;
|
const unsigned len = llength( dlp) ;
|
||||||
@ -69,23 +66,119 @@ static unsigned getgoal( struct line *dlp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the cursor to the beginning of the current line.
|
* Move the cursor to the beginning of the current line of active window.
|
||||||
*/
|
*/
|
||||||
int gotobol(int f, int n)
|
boolean gotobol( int f, int n) {
|
||||||
{
|
|
||||||
curwp->w_doto = 0 ;
|
curwp->w_doto = 0 ;
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the cursor to the end of the current line. Trivial. No errors.
|
* Move the cursor to the end of the current line of active window.
|
||||||
*/
|
*/
|
||||||
int gotoeol(int f, int n)
|
boolean gotoeol( int f, int n) {
|
||||||
{
|
|
||||||
curwp->w_doto = llength( curwp->w_dotp) ;
|
curwp->w_doto = llength( curwp->w_dotp) ;
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Goto the beginning of the buffer. Massive adjustment of dot. This is
|
||||||
|
* considered to be hard motion; it really isn't if the original value of dot
|
||||||
|
* is the same as the new value of dot. Normally bound to "M-<".
|
||||||
|
*/
|
||||||
|
boolean gotobob( int f, int n) {
|
||||||
|
curwp->w_dotp = lforw( curbp->b_linep) ;
|
||||||
|
curwp->w_doto = 0 ;
|
||||||
|
curwp->w_flag |= WFHARD ;
|
||||||
|
return TRUE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move to the end of the buffer. Dot is always put at the end of the file
|
||||||
|
* (ZJ). The standard screen code does most of the hard parts of update.
|
||||||
|
* Bound to "M->".
|
||||||
|
*/
|
||||||
|
boolean gotoeob( int f, int n) {
|
||||||
|
curwp->w_dotp = curbp->b_linep ;
|
||||||
|
curwp->w_doto = 0 ;
|
||||||
|
curwp->w_flag |= WFHARD ;
|
||||||
|
return TRUE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move forward by full lines. If the number of lines to move is less than
|
||||||
|
* zero, call the backward line function to actually do it. The last command
|
||||||
|
* controls how the goal column is set. Bound to "C-N". No errors are
|
||||||
|
* possible.
|
||||||
|
*/
|
||||||
|
boolean forwline( int f, int n) {
|
||||||
|
line_p dlp ;
|
||||||
|
|
||||||
|
if (n < 0)
|
||||||
|
return backline(f, -n);
|
||||||
|
|
||||||
|
/* if we are on the last line as we start....fail the command */
|
||||||
|
if (curwp->w_dotp == curbp->b_linep)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* if the last command was not a line move, reset the goal column */
|
||||||
|
if ((lastflag & CFCPCN) == 0)
|
||||||
|
curgoal = getccol(FALSE);
|
||||||
|
|
||||||
|
/* flag this command as a line move */
|
||||||
|
thisflag |= CFCPCN;
|
||||||
|
|
||||||
|
/* and move the point down */
|
||||||
|
dlp = curwp->w_dotp;
|
||||||
|
while( n && dlp != curbp->b_linep) {
|
||||||
|
dlp = lforw( dlp) ;
|
||||||
|
n -= 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reseting the current position */
|
||||||
|
curwp->w_dotp = dlp;
|
||||||
|
curwp->w_doto = getgoal(dlp);
|
||||||
|
curwp->w_flag |= WFMOVE;
|
||||||
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is like "forwline", but goes backwards. The scheme is exactly
|
||||||
|
* the same. Check for arguments that are less than zero and call your
|
||||||
|
* alternate. Figure out the new line and call "movedot" to perform the
|
||||||
|
* motion. No errors are possible. Bound to "C-P".
|
||||||
|
*/
|
||||||
|
boolean backline( int f, int n) {
|
||||||
|
line_p dlp ;
|
||||||
|
|
||||||
|
if (n < 0)
|
||||||
|
return forwline(f, -n);
|
||||||
|
|
||||||
|
/* if we are on the first line as we start....fail the command */
|
||||||
|
if (lback(curwp->w_dotp) == curbp->b_linep)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* if the last command was not a line move, reset the goal column */
|
||||||
|
if ((lastflag & CFCPCN) == 0)
|
||||||
|
curgoal = getccol(FALSE);
|
||||||
|
|
||||||
|
/* flag this command as a line move */
|
||||||
|
thisflag |= CFCPCN;
|
||||||
|
|
||||||
|
/* and move the point up */
|
||||||
|
dlp = curwp->w_dotp;
|
||||||
|
while( n && lback( dlp) != curbp->b_linep) {
|
||||||
|
dlp = lback( dlp) ;
|
||||||
|
n -= 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reseting the current position */
|
||||||
|
curwp->w_dotp = dlp;
|
||||||
|
curwp->w_doto = getgoal(dlp);
|
||||||
|
curwp->w_flag |= WFMOVE;
|
||||||
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move to a particular line.
|
* Move to a particular line.
|
||||||
*
|
*
|
||||||
@ -120,107 +213,7 @@ int gotoline( int f, int n) {
|
|||||||
|
|
||||||
/* First, we go to the begin of the buffer. */
|
/* First, we go to the begin of the buffer. */
|
||||||
gotobob(f, n);
|
gotobob(f, n);
|
||||||
return forwline(f, n - 1);
|
return (n == 1) ? TRUE : forwline( f, n - 1) ;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Goto the beginning of the buffer. Massive adjustment of dot. This is
|
|
||||||
* considered to be hard motion; it really isn't if the original value of dot
|
|
||||||
* is the same as the new value of dot. Normally bound to "M-<".
|
|
||||||
*/
|
|
||||||
int gotobob(int f, int n)
|
|
||||||
{
|
|
||||||
curwp->w_dotp = lforw(curbp->b_linep);
|
|
||||||
curwp->w_doto = 0;
|
|
||||||
curwp->w_flag |= WFHARD;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move to the end of the buffer. Dot is always put at the end of the file
|
|
||||||
* (ZJ). The standard screen code does most of the hard parts of update.
|
|
||||||
* Bound to "M->".
|
|
||||||
*/
|
|
||||||
int gotoeob(int f, int n)
|
|
||||||
{
|
|
||||||
curwp->w_dotp = curbp->b_linep;
|
|
||||||
curwp->w_doto = 0;
|
|
||||||
curwp->w_flag |= WFHARD;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move forward by full lines. If the number of lines to move is less than
|
|
||||||
* zero, call the backward line function to actually do it. The last command
|
|
||||||
* controls how the goal column is set. Bound to "C-N". No errors are
|
|
||||||
* possible.
|
|
||||||
*/
|
|
||||||
int forwline(int f, int n)
|
|
||||||
{
|
|
||||||
struct line *dlp;
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
return backline(f, -n);
|
|
||||||
|
|
||||||
/* if we are on the last line as we start....fail the command */
|
|
||||||
if (curwp->w_dotp == curbp->b_linep)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* if the last command was not note a line move,
|
|
||||||
reset the goal column */
|
|
||||||
if ((lastflag & CFCPCN) == 0)
|
|
||||||
curgoal = getccol(FALSE);
|
|
||||||
|
|
||||||
/* flag this command as a line move */
|
|
||||||
thisflag |= CFCPCN;
|
|
||||||
|
|
||||||
/* and move the point down */
|
|
||||||
dlp = curwp->w_dotp;
|
|
||||||
while (n-- && dlp != curbp->b_linep)
|
|
||||||
dlp = lforw(dlp);
|
|
||||||
|
|
||||||
/* reseting the current position */
|
|
||||||
curwp->w_dotp = dlp;
|
|
||||||
curwp->w_doto = getgoal(dlp);
|
|
||||||
curwp->w_flag |= WFMOVE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function is like "forwline", but goes backwards. The scheme is exactly
|
|
||||||
* the same. Check for arguments that are less than zero and call your
|
|
||||||
* alternate. Figure out the new line and call "movedot" to perform the
|
|
||||||
* motion. No errors are possible. Bound to "C-P".
|
|
||||||
*/
|
|
||||||
int backline(int f, int n)
|
|
||||||
{
|
|
||||||
struct line *dlp;
|
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
return forwline(f, -n);
|
|
||||||
|
|
||||||
/* if we are on the last line as we start....fail the command */
|
|
||||||
if (lback(curwp->w_dotp) == curbp->b_linep)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* if the last command was not note a line move,
|
|
||||||
reset the goal column */
|
|
||||||
if ((lastflag & CFCPCN) == 0)
|
|
||||||
curgoal = getccol(FALSE);
|
|
||||||
|
|
||||||
/* flag this command as a line move */
|
|
||||||
thisflag |= CFCPCN;
|
|
||||||
|
|
||||||
/* and move the point up */
|
|
||||||
dlp = curwp->w_dotp;
|
|
||||||
while (n-- && lback(dlp) != curbp->b_linep)
|
|
||||||
dlp = lback(dlp);
|
|
||||||
|
|
||||||
/* reseting the current position */
|
|
||||||
curwp->w_dotp = dlp;
|
|
||||||
curwp->w_doto = getgoal(dlp);
|
|
||||||
curwp->w_flag |= WFMOVE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -229,20 +222,20 @@ int backline(int f, int n)
|
|||||||
* the overlap; this value is the default overlap value in ITS EMACS. Because
|
* the overlap; this value is the default overlap value in ITS EMACS. Because
|
||||||
* this zaps the top line in the display window, we have to do a hard update.
|
* this zaps the top line in the display window, we have to do a hard update.
|
||||||
*/
|
*/
|
||||||
int forwpage(int f, int n)
|
boolean forwpage( int f, int n) {
|
||||||
{
|
line_p lp ;
|
||||||
struct line *lp;
|
|
||||||
|
|
||||||
if (f == FALSE) {
|
if (f == FALSE) {
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
if (term.t_scroll != NULL)
|
if (term.t_scroll != NULL) /* $scroll == FALSE */
|
||||||
if (overlap == 0)
|
if (overlap == 0) /* $overlap == 0 */
|
||||||
n = curwp->w_ntrows / 3 * 2;
|
n = curwp->w_ntrows * 2 / 3 ;
|
||||||
else
|
else
|
||||||
n = curwp->w_ntrows - overlap;
|
n = curwp->w_ntrows - overlap;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
n = curwp->w_ntrows - 2; /* Default scroll. */
|
n = curwp->w_ntrows - 2; /* Default scroll. */
|
||||||
|
|
||||||
if (n <= 0) /* Forget the overlap. */
|
if (n <= 0) /* Forget the overlap. */
|
||||||
n = 1; /* If tiny window. */
|
n = 1; /* If tiny window. */
|
||||||
} else if (n < 0)
|
} else if (n < 0)
|
||||||
@ -251,12 +244,19 @@ int forwpage(int f, int n)
|
|||||||
else /* Convert from pages. */
|
else /* Convert from pages. */
|
||||||
n *= curwp->w_ntrows; /* To lines. */
|
n *= curwp->w_ntrows; /* To lines. */
|
||||||
#endif
|
#endif
|
||||||
lp = curwp->w_linep;
|
|
||||||
while (n-- && lp != curbp->b_linep)
|
/* lp = curwp->w_linep; */
|
||||||
|
lp = curwp->w_dotp ;
|
||||||
|
while( n && lp != curbp->b_linep) {
|
||||||
lp = lforw( lp) ;
|
lp = lforw( lp) ;
|
||||||
curwp->w_linep = lp;
|
n -= 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* curwp->w_linep = lp; */
|
||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
|
reposition( TRUE, 0) ;
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFHARD | WFKILLS;
|
curwp->w_flag |= WFHARD | WFKILLS;
|
||||||
#else
|
#else
|
||||||
@ -271,20 +271,28 @@ int forwpage(int f, int n)
|
|||||||
* EMACS manual. Bound to "M-V". We do a hard update for exactly the same
|
* EMACS manual. Bound to "M-V". We do a hard update for exactly the same
|
||||||
* reason.
|
* reason.
|
||||||
*/
|
*/
|
||||||
int backpage(int f, int n)
|
boolean backpage( int f, int n) {
|
||||||
{
|
line_p lp ;
|
||||||
struct line *lp;
|
|
||||||
|
if (f == FALSE) { /* interactive, default n = 1 supplied */
|
||||||
|
/* in interactive mode, first move dot to top of window */
|
||||||
|
if( curwp->w_dotp != curwp->w_linep) {
|
||||||
|
curwp->w_dotp = curwp->w_linep ;
|
||||||
|
curwp->w_doto = 0 ;
|
||||||
|
/* curwp->w_flag |= WFMOVE ; */
|
||||||
|
return TRUE ;
|
||||||
|
}
|
||||||
|
|
||||||
if (f == FALSE) {
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
if (term.t_scroll != NULL)
|
if (term.t_scroll != NULL) /* $scroll != FALSE */
|
||||||
if (overlap == 0)
|
if (overlap == 0) /* $overlap == 0 */
|
||||||
n = curwp->w_ntrows / 3 * 2;
|
n = curwp->w_ntrows * 2 / 3 ;
|
||||||
else
|
else
|
||||||
n = curwp->w_ntrows - overlap;
|
n = curwp->w_ntrows - overlap;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
n = curwp->w_ntrows - 2; /* Default scroll. */
|
n = curwp->w_ntrows - 2; /* Default scroll. */
|
||||||
|
|
||||||
if (n <= 0) /* Don't blow up if the. */
|
if (n <= 0) /* Don't blow up if the. */
|
||||||
n = 1; /* Window is tiny. */
|
n = 1; /* Window is tiny. */
|
||||||
} else if (n < 0)
|
} else if (n < 0)
|
||||||
@ -293,12 +301,19 @@ int backpage(int f, int n)
|
|||||||
else /* Convert from pages. */
|
else /* Convert from pages. */
|
||||||
n *= curwp->w_ntrows; /* To lines. */
|
n *= curwp->w_ntrows; /* To lines. */
|
||||||
#endif
|
#endif
|
||||||
lp = curwp->w_linep;
|
|
||||||
while (n-- && lback(lp) != curbp->b_linep)
|
/* lp = curwp->w_linep; */
|
||||||
|
lp = curwp->w_dotp ;
|
||||||
|
while( n && lback( lp) != curbp->b_linep) {
|
||||||
lp = lback( lp) ;
|
lp = lback( lp) ;
|
||||||
curwp->w_linep = lp;
|
n -= 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* curwp->w_linep = lp; */
|
||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
|
reposition( TRUE, (f == FALSE) ? 1 : 0) ;
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFHARD | WFINS;
|
curwp->w_flag |= WFHARD | WFINS;
|
||||||
#else
|
#else
|
||||||
@ -311,8 +326,7 @@ int backpage(int f, int n)
|
|||||||
* Set the mark in the current window to the value of "." in the window. No
|
* Set the mark in the current window to the value of "." in the window. No
|
||||||
* errors are possible. Bound to "M-.".
|
* errors are possible. Bound to "M-.".
|
||||||
*/
|
*/
|
||||||
int setmark(int f, int n)
|
boolean setmark( int f, int n) {
|
||||||
{
|
|
||||||
curwp->w_markp = curwp->w_dotp;
|
curwp->w_markp = curwp->w_dotp;
|
||||||
curwp->w_marko = curwp->w_doto;
|
curwp->w_marko = curwp->w_doto;
|
||||||
mloutstr( "(Mark set)") ;
|
mloutstr( "(Mark set)") ;
|
||||||
@ -321,13 +335,12 @@ int setmark(int f, int n)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Swap the values of "." and "mark" in the current window. This is pretty
|
* Swap the values of "." and "mark" in the current window. This is pretty
|
||||||
* easy, bacause all of the hard work gets done by the standard routine
|
* easy, because all of the hard work gets done by the standard routine
|
||||||
* that moves the mark about. The only possible error is "no mark". Bound to
|
* that moves the mark about. The only possible error is "no mark". Bound to
|
||||||
* "C-X C-X".
|
* "C-X C-X".
|
||||||
*/
|
*/
|
||||||
int swapmark(int f, int n)
|
boolean swapmark( int f, int n) {
|
||||||
{
|
line_p odotp ;
|
||||||
struct line *odotp;
|
|
||||||
int odoto;
|
int odoto;
|
||||||
|
|
||||||
if( curwp->w_markp == NULL) {
|
if( curwp->w_markp == NULL) {
|
||||||
@ -344,3 +357,5 @@ int swapmark(int f, int n)
|
|||||||
curwp->w_flag |= WFMOVE;
|
curwp->w_flag |= WFMOVE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* end of basic.c */
|
||||||
|
34
basic.h
34
basic.h
@ -1,20 +1,34 @@
|
|||||||
|
/* basic.h -- basic commands for cursor movement in active window */
|
||||||
|
|
||||||
#ifndef _BASIC_H_
|
#ifndef _BASIC_H_
|
||||||
#define _BASIC_H_
|
#define _BASIC_H_
|
||||||
|
|
||||||
|
#include "retcode.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** $overlap is the size of the line overlap when doing page forw/back
|
||||||
|
** if 0, page will move by 2/3 of the window size (1/3 page overlap)
|
||||||
|
** default to 0
|
||||||
|
*/
|
||||||
|
#define DEFAULT_OVERLAP 0
|
||||||
extern int overlap ; /* line overlap in forw/back page */
|
extern int overlap ; /* line overlap in forw/back page */
|
||||||
|
|
||||||
|
|
||||||
extern int curgoal ; /* Goal for C-P, C-N */
|
extern int curgoal ; /* Goal for C-P, C-N */
|
||||||
|
|
||||||
|
|
||||||
int gotobol( int f, int n) ;
|
boolean gotobol( int f, int n) ;
|
||||||
int gotoeol( int f, int n) ;
|
boolean gotoeol( int f, int n) ;
|
||||||
int gotoline( int f, int n) ;
|
int gotoline( int f, int n) ;
|
||||||
int gotobob( int f, int n) ;
|
boolean gotobob( int f, int n) ;
|
||||||
int gotoeob( int f, int n) ;
|
boolean gotoeob( int f, int n) ;
|
||||||
int forwline( int f, int n) ;
|
boolean forwline( int f, int n) ;
|
||||||
int backline( int f, int n) ;
|
boolean backline( int f, int n) ;
|
||||||
int forwpage( int f, int n) ;
|
boolean forwpage( int f, int n) ;
|
||||||
int backpage( int f, int n) ;
|
boolean backpage( int f, int n) ;
|
||||||
int setmark( int f, int n) ;
|
boolean setmark( int f, int n) ;
|
||||||
int swapmark( int f, int n) ;
|
boolean swapmark( int f, int n) ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* end of basic.h */
|
||||||
|
56
ebind.c
56
ebind.c
@ -35,7 +35,7 @@
|
|||||||
* control-X commands.
|
* control-X commands.
|
||||||
*/
|
*/
|
||||||
struct key_tab keytab[NBINDS] = {
|
struct key_tab keytab[NBINDS] = {
|
||||||
{CONTROL | 'A', gotobol}
|
{CONTROL | 'A', (fn_t) gotobol}
|
||||||
,
|
,
|
||||||
{CONTROL | 'B', (fn_t) backchar}
|
{CONTROL | 'B', (fn_t) backchar}
|
||||||
,
|
,
|
||||||
@ -43,7 +43,7 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{CONTROL | 'D', forwdel}
|
{CONTROL | 'D', forwdel}
|
||||||
,
|
,
|
||||||
{CONTROL | 'E', gotoeol}
|
{CONTROL | 'E', (fn_t) gotoeol}
|
||||||
,
|
,
|
||||||
{CONTROL | 'F', (fn_t) forwchar}
|
{CONTROL | 'F', (fn_t) forwchar}
|
||||||
,
|
,
|
||||||
@ -61,11 +61,11 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{CONTROL | 'M', insert_newline}
|
{CONTROL | 'M', insert_newline}
|
||||||
,
|
,
|
||||||
{CONTROL | 'N', forwline}
|
{CONTROL | 'N', (fn_t) forwline}
|
||||||
,
|
,
|
||||||
{CONTROL | 'O', openline}
|
{CONTROL | 'O', openline}
|
||||||
,
|
,
|
||||||
{CONTROL | 'P', backline}
|
{CONTROL | 'P', (fn_t) backline}
|
||||||
,
|
,
|
||||||
{CONTROL | 'Q', quote}
|
{CONTROL | 'Q', quote}
|
||||||
,
|
,
|
||||||
@ -77,7 +77,7 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{CONTROL | 'U', unarg}
|
{CONTROL | 'U', unarg}
|
||||||
,
|
,
|
||||||
{CONTROL | 'V', forwpage}
|
{CONTROL | 'V', (fn_t) forwpage}
|
||||||
,
|
,
|
||||||
{CONTROL | 'W', killregion}
|
{CONTROL | 'W', killregion}
|
||||||
,
|
,
|
||||||
@ -85,7 +85,7 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{CONTROL | 'Y', yank}
|
{CONTROL | 'Y', yank}
|
||||||
,
|
,
|
||||||
{CONTROL | 'Z', backpage}
|
{CONTROL | 'Z', (fn_t) backpage}
|
||||||
,
|
,
|
||||||
{CONTROL | ']', metafn}
|
{CONTROL | ']', metafn}
|
||||||
,
|
,
|
||||||
@ -138,7 +138,7 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{CTLX | CONTROL | 'W', filewrite}
|
{CTLX | CONTROL | 'W', filewrite}
|
||||||
,
|
,
|
||||||
{CTLX | CONTROL | 'X', swapmark}
|
{CTLX | CONTROL | 'X', (fn_t) swapmark}
|
||||||
,
|
,
|
||||||
{CTLX | CONTROL | 'Z', shrinkwind}
|
{CTLX | CONTROL | 'Z', shrinkwind}
|
||||||
,
|
,
|
||||||
@ -246,17 +246,17 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
#endif
|
#endif
|
||||||
{META | CONTROL | 'Z', scrnextup}
|
{META | CONTROL | 'Z', scrnextup}
|
||||||
,
|
,
|
||||||
{META | ' ', setmark}
|
{META | ' ', (fn_t) setmark}
|
||||||
,
|
,
|
||||||
{META | '?', help}
|
{META | '?', help}
|
||||||
,
|
,
|
||||||
{META | '!', reposition}
|
{META | '!', reposition}
|
||||||
,
|
,
|
||||||
{META | '.', setmark}
|
{META | '.', (fn_t) setmark}
|
||||||
,
|
,
|
||||||
{META | '>', gotoeob}
|
{META | '>', (fn_t) gotoeob}
|
||||||
,
|
,
|
||||||
{META | '<', gotobob}
|
{META | '<', (fn_t) gotobob}
|
||||||
,
|
,
|
||||||
{META | '~', unmark}
|
{META | '~', unmark}
|
||||||
,
|
,
|
||||||
@ -307,7 +307,7 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
#endif
|
#endif
|
||||||
{META | 'U', upperword}
|
{META | 'U', upperword}
|
||||||
,
|
,
|
||||||
{META | 'V', backpage}
|
{META | 'V', (fn_t) backpage}
|
||||||
,
|
,
|
||||||
{META | 'W', copyregion}
|
{META | 'W', copyregion}
|
||||||
,
|
,
|
||||||
@ -323,21 +323,21 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{SPEC | CONTROL | 'S', backhunt}
|
{SPEC | CONTROL | 'S', backhunt}
|
||||||
,
|
,
|
||||||
{SPEC | 71, gotobol}
|
{SPEC | 71, (fn_t) gotobol}
|
||||||
,
|
,
|
||||||
{SPEC | 72, backline}
|
{SPEC | 72, (fn_t) backline}
|
||||||
,
|
,
|
||||||
{SPEC | 73, backpage}
|
{SPEC | 73, (fn_t) backpage}
|
||||||
,
|
,
|
||||||
{SPEC | 75, (fn_t) backchar}
|
{SPEC | 75, (fn_t) backchar}
|
||||||
,
|
,
|
||||||
{SPEC | 77, (fn_t) forwchar}
|
{SPEC | 77, (fn_t) forwchar}
|
||||||
,
|
,
|
||||||
{SPEC | 79, gotoeol}
|
{SPEC | 79, (fn_t) gotoeol}
|
||||||
,
|
,
|
||||||
{SPEC | 80, forwline}
|
{SPEC | 80, (fn_t) forwline}
|
||||||
,
|
,
|
||||||
{SPEC | 81, forwpage}
|
{SPEC | 81, (fn_t) forwpage}
|
||||||
,
|
,
|
||||||
{SPEC | 82, insspace}
|
{SPEC | 82, insspace}
|
||||||
,
|
,
|
||||||
@ -374,9 +374,9 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
{SPEC | 93, cbuf10}
|
{SPEC | 93, cbuf10}
|
||||||
,
|
,
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{SPEC | 117, gotoeob}
|
{SPEC | 117, (fn_t) gotoeob}
|
||||||
,
|
,
|
||||||
{SPEC | 119, gotobob}
|
{SPEC | 119, (fn_t) gotobob}
|
||||||
,
|
,
|
||||||
{SPEC | 141, gotobop}
|
{SPEC | 141, gotobop}
|
||||||
,
|
,
|
||||||
@ -390,21 +390,21 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VT220
|
#if VT220
|
||||||
{SPEC | '1', gotobob /* fisearch */}
|
{SPEC | '1', (fn_t) gotobob /* fisearch */}
|
||||||
, /* VT220 keys */
|
, /* VT220 keys */
|
||||||
{SPEC | '2', yank}
|
{SPEC | '2', yank}
|
||||||
,
|
,
|
||||||
{SPEC | '3', forwdel /* killregion */}
|
{SPEC | '3', forwdel /* killregion */}
|
||||||
,
|
,
|
||||||
{SPEC | '4', gotoeob /* setmark */}
|
{SPEC | '4', (fn_t) gotoeob /* setmark */}
|
||||||
,
|
,
|
||||||
{SPEC | '5', backpage}
|
{SPEC | '5', (fn_t) backpage}
|
||||||
,
|
,
|
||||||
{SPEC | '6', forwpage}
|
{SPEC | '6', (fn_t) forwpage}
|
||||||
,
|
,
|
||||||
{SPEC | 'A', backline}
|
{SPEC | 'A', (fn_t) backline}
|
||||||
,
|
,
|
||||||
{SPEC | 'B', forwline}
|
{SPEC | 'B', (fn_t) forwline}
|
||||||
,
|
,
|
||||||
{SPEC | 'C', (fn_t) forwchar}
|
{SPEC | 'C', (fn_t) forwchar}
|
||||||
,
|
,
|
||||||
@ -414,9 +414,9 @@ struct key_tab keytab[NBINDS] = {
|
|||||||
,
|
,
|
||||||
{SPEC | 'd', (fn_t) backchar}
|
{SPEC | 'd', (fn_t) backchar}
|
||||||
,
|
,
|
||||||
{SPEC | 'e', forwline}
|
{SPEC | 'e', (fn_t) forwline}
|
||||||
,
|
,
|
||||||
{SPEC | 'f', gotobob}
|
{SPEC | 'f', (fn_t) gotobob}
|
||||||
,
|
,
|
||||||
{SPEC | 'h', help}
|
{SPEC | 'h', help}
|
||||||
,
|
,
|
||||||
|
20
names.c
20
names.c
@ -36,8 +36,8 @@ struct name_bind names[] = {
|
|||||||
#endif
|
#endif
|
||||||
{"backward-character", (fn_t) backchar},
|
{"backward-character", (fn_t) backchar},
|
||||||
{"begin-macro", ctlxlp},
|
{"begin-macro", ctlxlp},
|
||||||
{"beginning-of-file", gotobob},
|
{"beginning-of-file", (fn_t) gotobob},
|
||||||
{"beginning-of-line", gotobol},
|
{"beginning-of-line", (fn_t) gotobol},
|
||||||
{"bind-to-key", bindtokey},
|
{"bind-to-key", bindtokey},
|
||||||
{"buffer-position", showcpos},
|
{"buffer-position", showcpos},
|
||||||
{"case-region-lower", lowerregion},
|
{"case-region-lower", lowerregion},
|
||||||
@ -71,12 +71,12 @@ struct name_bind names[] = {
|
|||||||
{"detab-line", detab},
|
{"detab-line", detab},
|
||||||
#endif
|
#endif
|
||||||
{"end-macro", ctlxrp},
|
{"end-macro", ctlxrp},
|
||||||
{"end-of-file", gotoeob},
|
{"end-of-file", (fn_t) gotoeob},
|
||||||
{"end-of-line", gotoeol},
|
{"end-of-line", (fn_t) gotoeol},
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{"entab-line", entab},
|
{"entab-line", entab},
|
||||||
#endif
|
#endif
|
||||||
{"exchange-point-and-mark", swapmark},
|
{"exchange-point-and-mark", (fn_t) swapmark},
|
||||||
{"execute-buffer", execbuf},
|
{"execute-buffer", execbuf},
|
||||||
{"execute-command-line", execcmd},
|
{"execute-command-line", execcmd},
|
||||||
{"execute-file", execfile},
|
{"execute-file", execfile},
|
||||||
@ -165,8 +165,8 @@ struct name_bind names[] = {
|
|||||||
{"newline", insert_newline},
|
{"newline", insert_newline},
|
||||||
{"newline-and-indent", indent},
|
{"newline-and-indent", indent},
|
||||||
{"next-buffer", nextbuffer},
|
{"next-buffer", nextbuffer},
|
||||||
{"next-line", forwline},
|
{"next-line", (fn_t) forwline},
|
||||||
{"next-page", forwpage},
|
{"next-page", (fn_t) forwpage},
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{"next-paragraph", gotoeop},
|
{"next-paragraph", gotoeop},
|
||||||
#endif
|
#endif
|
||||||
@ -176,8 +176,8 @@ struct name_bind names[] = {
|
|||||||
{"open-line", openline},
|
{"open-line", openline},
|
||||||
{"overwrite-string", ovstring},
|
{"overwrite-string", ovstring},
|
||||||
{"pipe-command", pipecmd},
|
{"pipe-command", pipecmd},
|
||||||
{"previous-line", backline},
|
{"previous-line", (fn_t) backline},
|
||||||
{"previous-page", backpage},
|
{"previous-page", (fn_t) backpage},
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{"previous-paragraph", gotobop},
|
{"previous-paragraph", gotobop},
|
||||||
#endif
|
#endif
|
||||||
@ -206,7 +206,7 @@ struct name_bind names[] = {
|
|||||||
{"select-buffer", usebuffer},
|
{"select-buffer", usebuffer},
|
||||||
{"set", setvar},
|
{"set", setvar},
|
||||||
{"set-fill-column", setfillcol},
|
{"set-fill-column", setfillcol},
|
||||||
{"set-mark", setmark},
|
{"set-mark", (fn_t) setmark},
|
||||||
{"shell-command", spawn},
|
{"shell-command", spawn},
|
||||||
{"shrink-window", shrinkwind},
|
{"shrink-window", shrinkwind},
|
||||||
{"split-current-window", splitwind},
|
{"split-current-window", splitwind},
|
||||||
|
6
random.c
6
random.c
@ -358,7 +358,7 @@ int detab(int f, int n)
|
|||||||
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 */
|
||||||
return TRUE;
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -433,7 +433,7 @@ int entab(int f, int n)
|
|||||||
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 */
|
||||||
return TRUE;
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -478,7 +478,7 @@ int trim(int f, int n)
|
|||||||
}
|
}
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
return TRUE;
|
return (n == 0) ? TRUE : FALSE ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user