mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Remove tab width constraints, was [2, 4, 8], now [1...
This commit is contained in:
parent
3e27fcf19e
commit
c390cf2a3e
9
basic.c
9
basic.c
@ -51,13 +51,14 @@ static unsigned getgoal( struct line *dlp) {
|
|||||||
|
|
||||||
/* Take tabs, ^X and \xx hex characters into account */
|
/* Take tabs, ^X and \xx hex characters into account */
|
||||||
if( c == '\t')
|
if( c == '\t')
|
||||||
col |= tabmask ;
|
col += tabwidth - col % tabwidth ;
|
||||||
else if( c < 0x20 || c == 0x7F)
|
else if( c < 0x20 || c == 0x7F)
|
||||||
col += 1 ;
|
|
||||||
else if( c >= 0x80 && c <= 0xA0)
|
|
||||||
col += 2 ;
|
col += 2 ;
|
||||||
|
else if( c >= 0x80 && c <= 0xA0)
|
||||||
|
col += 3 ;
|
||||||
|
else
|
||||||
col += 1 ;
|
col += 1 ;
|
||||||
|
|
||||||
if( col > curgoal)
|
if( col > curgoal)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
13
display.c
13
display.c
@ -210,7 +210,8 @@ static void vtputc(int c)
|
|||||||
if (c == '\t') {
|
if (c == '\t') {
|
||||||
do {
|
do {
|
||||||
vtputc(' ');
|
vtputc(' ');
|
||||||
} while (((vtcol + taboff) & tabmask) != 0);
|
} while( ((vtcol + taboff) % tabwidth) != 0) ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,13 +581,13 @@ void updpos(void)
|
|||||||
|
|
||||||
i += utf8_to_unicode( lp->l_text, i, curwp->w_doto, &c) ;
|
i += utf8_to_unicode( lp->l_text, i, curwp->w_doto, &c) ;
|
||||||
if( c == '\t')
|
if( c == '\t')
|
||||||
curcol |= tabmask ;
|
curcol += tabwidth - curcol % tabwidth ;
|
||||||
else if( c < 0x20 || c == 0x7F)
|
else if( c < 0x20 || c == 0x7F)
|
||||||
curcol += 1 ; /* displayed as ^c */
|
curcol += 2 ; /* displayed as ^c */
|
||||||
else if( c >= 0x80 && c <= 0xA0)
|
else if( c >= 0x80 && c <= 0xA0)
|
||||||
curcol += 2 ; /* displayed as \xx */
|
curcol += 3 ; /* displayed as \xx */
|
||||||
|
else
|
||||||
++curcol;
|
curcol += 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if extended, flag so and update the virtual line image */
|
/* if extended, flag so and update the virtual line image */
|
||||||
|
11
eval.c
11
eval.c
@ -734,7 +734,7 @@ static char *gtenv( char *vname) {
|
|||||||
case EVRVAL:
|
case EVRVAL:
|
||||||
return i_to_a(rval);
|
return i_to_a(rval);
|
||||||
case EVTAB:
|
case EVTAB:
|
||||||
return i_to_a(tabmask + 1);
|
return i_to_a( tabwidth) ;
|
||||||
case EVOVERLAP:
|
case EVOVERLAP:
|
||||||
return i_to_a(overlap);
|
return i_to_a(overlap);
|
||||||
case EVSCROLLCOUNT:
|
case EVSCROLLCOUNT:
|
||||||
@ -1049,10 +1049,13 @@ static int svar(struct variable_description *var, char *value)
|
|||||||
case EVRVAL:
|
case EVRVAL:
|
||||||
break;
|
break;
|
||||||
case EVTAB:
|
case EVTAB:
|
||||||
tabmask = atoi(value) - 1;
|
c = atoi( value) ;
|
||||||
if( tabmask != 0x07 && tabmask != 0x03 && tabmask != 1)
|
if( c > 0) {
|
||||||
tabmask = 0x07;
|
tabwidth = c ;
|
||||||
curwp->w_flag |= WFHARD;
|
curwp->w_flag |= WFHARD;
|
||||||
|
} else
|
||||||
|
status = FALSE ;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EVOVERLAP:
|
case EVOVERLAP:
|
||||||
overlap = atoi(value);
|
overlap = atoi(value);
|
||||||
|
@ -70,7 +70,7 @@ int execute(int c, int f, int n)
|
|||||||
if (curwp->w_bufp->b_mode & MDOVER &&
|
if (curwp->w_bufp->b_mode & MDOVER &&
|
||||||
curwp->w_doto < curwp->w_dotp->l_used &&
|
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) & tabmask) == tabmask))
|
((curwp->w_doto) % tabwidth) == (tabwidth - 1)))
|
||||||
ldelchar(1, FALSE);
|
ldelchar(1, FALSE);
|
||||||
|
|
||||||
/* do the appropriate insertion */
|
/* do the appropriate insertion */
|
||||||
|
14
line.c
14
line.c
@ -26,7 +26,7 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
int tabmask = 0x07 ; /* tabulator mask */
|
int tabwidth = 8 ; /* column span of a tab */
|
||||||
|
|
||||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||||
|
|
||||||
@ -418,12 +418,14 @@ int linsert( int n, unicode_t c) {
|
|||||||
*
|
*
|
||||||
* 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) & tabmask) == tabmask))
|
((curwp->w_doto) % tabwidth) == (tabwidth - 1)
|
||||||
|
))
|
||||||
ldelchar( 1, FALSE) ;
|
ldelchar( 1, FALSE) ;
|
||||||
|
|
||||||
return linsert( 1, c) ;
|
return linsert( 1, c) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
line.h
2
line.h
@ -28,7 +28,7 @@ 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)
|
||||||
|
|
||||||
extern int tabmask ;
|
extern int tabwidth ;
|
||||||
|
|
||||||
char *getkill( void) ;
|
char *getkill( void) ;
|
||||||
|
|
||||||
|
56
random.c
56
random.c
@ -179,12 +179,13 @@ int getccol(int bflg)
|
|||||||
if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */
|
if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */
|
||||||
break;
|
break;
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
col |= tabmask;
|
col += tabwidth - col % tabwidth ;
|
||||||
else if (c < 0x20 || c == 0x7F) /* displayed as ^c */
|
else if (c < 0x20 || c == 0x7F) /* displayed as ^c */
|
||||||
++col;
|
|
||||||
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
|
|
||||||
col += 2 ;
|
col += 2 ;
|
||||||
++col;
|
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
|
||||||
|
col += 3 ;
|
||||||
|
else
|
||||||
|
col += 1 ;
|
||||||
}
|
}
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
@ -213,10 +214,11 @@ int setccol(int pos)
|
|||||||
/* advance one character */
|
/* advance one character */
|
||||||
c = lgetc(curwp->w_dotp, i);
|
c = lgetc(curwp->w_dotp, i);
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
col |= tabmask;
|
col += tabwidth - col % tabwidth ;
|
||||||
else if (c < 0x20 || c == 0x7F)
|
else if (c < 0x20 || c == 0x7F)
|
||||||
++col;
|
col += 2 ;
|
||||||
++col;
|
else
|
||||||
|
col += 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set us at the new position */
|
/* set us at the new position */
|
||||||
@ -329,10 +331,9 @@ int detab(int f, int n)
|
|||||||
/* if we have a tab */
|
/* if we have a tab */
|
||||||
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
||||||
ldelchar(1, FALSE);
|
ldelchar(1, FALSE);
|
||||||
insspace(TRUE,
|
insspace( TRUE, tabwidth - curwp->w_doto % tabwidth);
|
||||||
(tabmask + 1) -
|
|
||||||
(curwp->w_doto & tabmask));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forwchar(FALSE, 1);
|
forwchar(FALSE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +354,7 @@ int detab(int f, int n)
|
|||||||
*/
|
*/
|
||||||
int entab(int f, int n)
|
int entab(int f, int n)
|
||||||
{
|
{
|
||||||
#define nextab(a) (a & ~tabmask) + (tabmask+1)
|
#define nextab(a) (a + tabwidth - a % tabwidth)
|
||||||
|
|
||||||
int inc; /* increment to next line [sgn(n)] */
|
int inc; /* increment to next line [sgn(n)] */
|
||||||
int fspace; /* pointer to first space if in a run */
|
int fspace; /* pointer to first space if in a run */
|
||||||
@ -759,37 +760,44 @@ int deblank(int f, int n)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a newline, then enough tabs and spaces to duplicate the indentation
|
* Insert a newline, then enough tabs and spaces to duplicate the indentation
|
||||||
* of the previous line. Assumes tabs are every eight characters. Quite simple.
|
* of the previous line. Assumes tabs are every tabwidth characters.
|
||||||
* Figure out the indentation of the current line. Insert a newline by calling
|
* Figure out the indentation of the current line. Insert a newline by calling
|
||||||
* the standard routine. Insert the indentation by inserting the right number
|
* the standard routine. Insert the indentation by inserting the right number
|
||||||
* of tabs and spaces. Return TRUE if all ok. Return FALSE if one of the
|
* of tabs and spaces. Return TRUE if all ok. Return FALSE if one of the
|
||||||
* subcomands failed. Normally bound to "C-J".
|
* subcomands failed. Normally bound to "C-J".
|
||||||
*/
|
*/
|
||||||
int indent(int f, int n)
|
int indent( int f, int n) {
|
||||||
{
|
|
||||||
int nicol ;
|
int nicol ;
|
||||||
int c;
|
|
||||||
int i ;
|
int i ;
|
||||||
|
|
||||||
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return rdonly() ; /* we are in read only mode */
|
return rdonly() ; /* we are in read only mode */
|
||||||
|
|
||||||
if( n < 0)
|
if( n < 0)
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
while (n--) {
|
|
||||||
|
/* number of columns to indent */
|
||||||
nicol = 0 ;
|
nicol = 0 ;
|
||||||
for (i = 0; i < llength(curwp->w_dotp); ++i) {
|
for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) {
|
||||||
|
int c ;
|
||||||
|
|
||||||
c = lgetc( curwp->w_dotp, i) ;
|
c = lgetc( curwp->w_dotp, i) ;
|
||||||
if (c != ' ' && c != '\t')
|
|
||||||
break;
|
|
||||||
if( c == '\t')
|
if( c == '\t')
|
||||||
nicol |= tabmask;
|
nicol += tabwidth - nicol % tabwidth ;
|
||||||
++nicol;
|
else if( c == ' ')
|
||||||
|
nicol += 1 ;
|
||||||
|
else
|
||||||
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i = nicol / tabwidth ; /* # of tab to insert */
|
||||||
|
nicol %= tabwidth ; /* # of space to insert */
|
||||||
|
while( n--)
|
||||||
if( lnewline() == FALSE
|
if( lnewline() == FALSE
|
||||||
|| ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE)
|
|| ( i != 0 && linsert( i, '\t') == FALSE)
|
||||||
|| ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))
|
|| ( nicol != 0 && linsert( nicol, ' ') == FALSE))
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user