mirror of
https://github.com/rfivet/uemacs.git
synced 2025-01-11 10:46:59 -05:00
Revise fence handling in CMODE.
This commit is contained in:
parent
860bace701
commit
b244adf23a
33
execute.c
33
execute.c
@ -55,10 +55,7 @@ static int inspound( int n) {
|
|||||||
static int insbrace( int n, int c) {
|
static int insbrace( int n, int c) {
|
||||||
int ch ; /* last character before input */
|
int ch ; /* last character before input */
|
||||||
int oc ; /* caractere oppose a c */
|
int oc ; /* caractere oppose a c */
|
||||||
int i, count ;
|
|
||||||
int target ; /* column brace should go after */
|
int target ; /* column brace should go after */
|
||||||
struct line *oldlp ;
|
|
||||||
int oldoff ;
|
|
||||||
|
|
||||||
/* if not called with {, acts as insertion */
|
/* if not called with {, acts as insertion */
|
||||||
if( c == '}')
|
if( c == '}')
|
||||||
@ -67,16 +64,17 @@ static int insbrace( int n, int c) {
|
|||||||
return linsert( n, c) ;
|
return linsert( n, c) ;
|
||||||
|
|
||||||
/* scan to see if all preceding spaces are white spaces, if not, insert */
|
/* scan to see if all preceding spaces are white spaces, if not, insert */
|
||||||
for( i = curwp->w_doto - 1 ; i >= 0 ; --i) {
|
for( int i = curwp->w_doto - 1 ; i >= 0 ; --i) {
|
||||||
ch = lgetc( curwp->w_dotp, i) ;
|
ch = lgetc( curwp->w_dotp, i) ;
|
||||||
if( ch != ' ' && ch != '\t')
|
if( ch != ' ' && ch != '\t')
|
||||||
return linsert( n, c) ;
|
return linsert( n, c) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldlp = curwp->w_dotp ;
|
/* save the original cursor position */
|
||||||
oldoff = curwp->w_doto ;
|
line_p oldlp = curwp->w_dotp ;
|
||||||
|
int oldoff = curwp->w_doto ;
|
||||||
|
|
||||||
count = 1 ;
|
int count = 1 ;
|
||||||
do {
|
do {
|
||||||
if( boundary( 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 */
|
||||||
@ -132,10 +130,6 @@ static int insbrace( int n, int c) {
|
|||||||
* char ch; fence type to match against
|
* char ch; fence type to match against
|
||||||
*/
|
*/
|
||||||
static void fmatch( int ch) {
|
static void fmatch( int ch) {
|
||||||
struct line *oldlp ; /* original line pointer */
|
|
||||||
int oldoff ; /* and offset */
|
|
||||||
struct line *toplp ; /* top line in current window */
|
|
||||||
int count ; /* current fence level count */
|
|
||||||
int opench ; /* open fence */
|
int opench ; /* open fence */
|
||||||
|
|
||||||
/* $tpause <= 0 disable fmatch */
|
/* $tpause <= 0 disable fmatch */
|
||||||
@ -146,8 +140,8 @@ static void fmatch( int ch) {
|
|||||||
update( FALSE) ;
|
update( FALSE) ;
|
||||||
|
|
||||||
/* save the original cursor position */
|
/* save the original cursor position */
|
||||||
oldlp = curwp->w_dotp ;
|
line_p oldlp = curwp->w_dotp ;
|
||||||
oldoff = curwp->w_doto ;
|
int oldoff = curwp->w_doto ;
|
||||||
|
|
||||||
/* setup proper open fence for passed close fence */
|
/* setup proper open fence for passed close fence */
|
||||||
if( ch == ')')
|
if( ch == ')')
|
||||||
@ -158,11 +152,11 @@ static void fmatch( int ch) {
|
|||||||
opench = '[' ;
|
opench = '[' ;
|
||||||
|
|
||||||
/* find the top line and set up for scan */
|
/* find the top line and set up for scan */
|
||||||
toplp = curwp->w_linep->l_bp ;
|
line_p toplp = curwp->w_linep->l_bp ;
|
||||||
backchar( FALSE, 1) ; /* . was after the }, move back */
|
backchar( FALSE, 1) ; /* . was after the }, move back */
|
||||||
|
|
||||||
/* scan back until we find it, or reach past the top of the window */
|
/* scan back until we find it, or reach past the top of the window */
|
||||||
count = 1 ;
|
int count = 1 ; /* current fence level count */
|
||||||
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
|
||||||
@ -209,17 +203,14 @@ static void fmatch( int ch) {
|
|||||||
* int f, n; not used
|
* int f, n; not used
|
||||||
*/
|
*/
|
||||||
BINDABLE( getfence) {
|
BINDABLE( getfence) {
|
||||||
struct line *oldlp; /* original line pointer */
|
|
||||||
int oldoff; /* and offset */
|
|
||||||
int sdir; /* direction of search (1/-1) */
|
int sdir; /* direction of search (1/-1) */
|
||||||
int count; /* current fence level count */
|
|
||||||
char ch; /* fence type to match against */
|
char ch; /* fence type to match against */
|
||||||
char ofence; /* open fence */
|
char ofence; /* open fence */
|
||||||
char c; /* current character in scan */
|
char c; /* current character in scan */
|
||||||
|
|
||||||
/* save the original cursor position */
|
/* save the original cursor position */
|
||||||
oldlp = curwp->w_dotp;
|
line_p oldlp = curwp->w_dotp ;
|
||||||
oldoff = curwp->w_doto;
|
int oldoff = curwp->w_doto ;
|
||||||
|
|
||||||
/* get the current character */
|
/* get the current character */
|
||||||
if (oldoff == llength(oldlp))
|
if (oldoff == llength(oldlp))
|
||||||
@ -259,7 +250,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 ;
|
int count = 1 ; /* current fence level count */
|
||||||
do {
|
do {
|
||||||
if( boundary( 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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user