mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-17 23:06:25 -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 */
|
||||
if( c == '\t')
|
||||
col |= tabmask ;
|
||||
col += tabwidth - col % tabwidth ;
|
||||
else if( c < 0x20 || c == 0x7F)
|
||||
col += 1 ;
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
col += 2 ;
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
col += 3 ;
|
||||
else
|
||||
col += 1 ;
|
||||
|
||||
col += 1 ;
|
||||
if( col > curgoal)
|
||||
break ;
|
||||
|
||||
|
15
display.c
15
display.c
@ -210,8 +210,9 @@ static void vtputc(int c)
|
||||
if (c == '\t') {
|
||||
do {
|
||||
vtputc(' ');
|
||||
} while (((vtcol + taboff) & tabmask) != 0);
|
||||
return;
|
||||
} while( ((vtcol + taboff) % tabwidth) != 0) ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
if (c < 0x20) {
|
||||
@ -580,13 +581,13 @@ void updpos(void)
|
||||
|
||||
i += utf8_to_unicode( lp->l_text, i, curwp->w_doto, &c) ;
|
||||
if( c == '\t')
|
||||
curcol |= tabmask ;
|
||||
curcol += tabwidth - curcol % tabwidth ;
|
||||
else if( c < 0x20 || c == 0x7F)
|
||||
curcol += 1 ; /* displayed as ^c */
|
||||
curcol += 2 ; /* displayed as ^c */
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
curcol += 2 ; /* displayed as \xx */
|
||||
|
||||
++curcol;
|
||||
curcol += 3 ; /* displayed as \xx */
|
||||
else
|
||||
curcol += 1 ;
|
||||
}
|
||||
|
||||
/* if extended, flag so and update the virtual line image */
|
||||
|
13
eval.c
13
eval.c
@ -734,7 +734,7 @@ static char *gtenv( char *vname) {
|
||||
case EVRVAL:
|
||||
return i_to_a(rval);
|
||||
case EVTAB:
|
||||
return i_to_a(tabmask + 1);
|
||||
return i_to_a( tabwidth) ;
|
||||
case EVOVERLAP:
|
||||
return i_to_a(overlap);
|
||||
case EVSCROLLCOUNT:
|
||||
@ -1049,10 +1049,13 @@ static int svar(struct variable_description *var, char *value)
|
||||
case EVRVAL:
|
||||
break;
|
||||
case EVTAB:
|
||||
tabmask = atoi(value) - 1;
|
||||
if( tabmask != 0x07 && tabmask != 0x03 && tabmask != 1)
|
||||
tabmask = 0x07;
|
||||
curwp->w_flag |= WFHARD;
|
||||
c = atoi( value) ;
|
||||
if( c > 0) {
|
||||
tabwidth = c ;
|
||||
curwp->w_flag |= WFHARD;
|
||||
} else
|
||||
status = FALSE ;
|
||||
|
||||
break;
|
||||
case EVOVERLAP:
|
||||
overlap = atoi(value);
|
||||
|
@ -70,7 +70,7 @@ int execute(int c, int f, int n)
|
||||
if (curwp->w_bufp->b_mode & MDOVER &&
|
||||
curwp->w_doto < curwp->w_dotp->l_used &&
|
||||
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
((curwp->w_doto) & tabmask) == tabmask))
|
||||
((curwp->w_doto) % tabwidth) == (tabwidth - 1)))
|
||||
ldelchar(1, FALSE);
|
||||
|
||||
/* do the appropriate insertion */
|
||||
|
18
line.c
18
line.c
@ -26,7 +26,7 @@
|
||||
#include "window.h"
|
||||
|
||||
|
||||
int tabmask = 0x07 ; /* tabulator mask */
|
||||
int tabwidth = 8 ; /* column span of a tab */
|
||||
|
||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||
|
||||
@ -418,13 +418,15 @@ int linsert( int n, unicode_t c) {
|
||||
*
|
||||
* int c; character to overwrite on current position
|
||||
*/
|
||||
static int lowrite(int c)
|
||||
{
|
||||
if (curwp->w_doto < curwp->w_dotp->l_used &&
|
||||
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
((curwp->w_doto) & tabmask) == tabmask))
|
||||
ldelchar(1, FALSE);
|
||||
return linsert(1, c);
|
||||
static int lowrite( int c) {
|
||||
if( curwp->w_doto < curwp->w_dotp->l_used
|
||||
&& (
|
||||
lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
((curwp->w_doto) % tabwidth) == (tabwidth - 1)
|
||||
))
|
||||
ldelchar( 1, FALSE) ;
|
||||
|
||||
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 llength(lp) ((lp)->l_used)
|
||||
|
||||
extern int tabmask ;
|
||||
extern int tabwidth ;
|
||||
|
||||
char *getkill( void) ;
|
||||
|
||||
|
80
random.c
80
random.c
@ -179,12 +179,13 @@ int getccol(int bflg)
|
||||
if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */
|
||||
break;
|
||||
if (c == '\t')
|
||||
col |= tabmask;
|
||||
col += tabwidth - col % tabwidth ;
|
||||
else if (c < 0x20 || c == 0x7F) /* displayed as ^c */
|
||||
++col;
|
||||
col += 2 ;
|
||||
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
|
||||
col += 2;
|
||||
++col;
|
||||
col += 3 ;
|
||||
else
|
||||
col += 1 ;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
@ -213,10 +214,11 @@ int setccol(int pos)
|
||||
/* advance one character */
|
||||
c = lgetc(curwp->w_dotp, i);
|
||||
if (c == '\t')
|
||||
col |= tabmask;
|
||||
col += tabwidth - col % tabwidth ;
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++col;
|
||||
++col;
|
||||
col += 2 ;
|
||||
else
|
||||
col += 1 ;
|
||||
}
|
||||
|
||||
/* set us at the new position */
|
||||
@ -329,10 +331,9 @@ int detab(int f, int n)
|
||||
/* if we have a tab */
|
||||
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
||||
ldelchar(1, FALSE);
|
||||
insspace(TRUE,
|
||||
(tabmask + 1) -
|
||||
(curwp->w_doto & tabmask));
|
||||
insspace( TRUE, tabwidth - curwp->w_doto % tabwidth);
|
||||
}
|
||||
|
||||
forwchar(FALSE, 1);
|
||||
}
|
||||
|
||||
@ -353,7 +354,7 @@ int detab(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 fspace; /* pointer to first space if in a run */
|
||||
@ -759,38 +760,45 @@ int deblank(int f, int n)
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
* subcomands failed. Normally bound to "C-J".
|
||||
*/
|
||||
int indent(int f, int n)
|
||||
{
|
||||
int nicol;
|
||||
int c;
|
||||
int i;
|
||||
int indent( int f, int n) {
|
||||
int nicol ;
|
||||
int i ;
|
||||
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly(); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return FALSE;
|
||||
while (n--) {
|
||||
nicol = 0;
|
||||
for (i = 0; i < llength(curwp->w_dotp); ++i) {
|
||||
c = lgetc(curwp->w_dotp, i);
|
||||
if (c != ' ' && c != '\t')
|
||||
break;
|
||||
if (c == '\t')
|
||||
nicol |= tabmask;
|
||||
++nicol;
|
||||
}
|
||||
if (lnewline() == FALSE
|
||||
|| ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE)
|
||||
|| ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))
|
||||
return FALSE;
|
||||
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly() ; /* we are in read only mode */
|
||||
|
||||
if( n < 0)
|
||||
return FALSE ;
|
||||
|
||||
/* number of columns to indent */
|
||||
nicol = 0 ;
|
||||
for( i = 0 ; i < llength( curwp->w_dotp) ; i += 1) {
|
||||
int c ;
|
||||
|
||||
c = lgetc( curwp->w_dotp, i) ;
|
||||
if( c == '\t')
|
||||
nicol += tabwidth - nicol % tabwidth ;
|
||||
else if( c == ' ')
|
||||
nicol += 1 ;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
i = nicol / tabwidth ; /* # of tab to insert */
|
||||
nicol %= tabwidth ; /* # of space to insert */
|
||||
while( n--)
|
||||
if( lnewline() == FALSE
|
||||
|| ( i != 0 && linsert( i, '\t') == FALSE)
|
||||
|| ( nicol != 0 && linsert( nicol, ' ') == FALSE))
|
||||
return FALSE ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user