Introduce boolean $hardtab to control insertion of hardcoded tab or soft ones (spaces). Review insert_tab accordingly.

This commit is contained in:
Renaud 2016-02-24 21:17:45 +08:00
parent 8dfa92ba44
commit 3436443807
4 changed files with 36 additions and 19 deletions

View File

@ -152,8 +152,9 @@ eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h retcode.h \
exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \ exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \
display.h estruct.h eval.h file.h flook.h input.h random.h window.h \ display.h estruct.h eval.h file.h flook.h input.h random.h window.h \
defines.h defines.h
execute.o: execute.c execute.h estruct.h bind.h random.h display.h file.h \ execute.o: execute.c execute.h estruct.h bind.h random.h retcode.h \
buffer.h crypt.h line.h retcode.h utf8.h mlout.h window.h defines.h display.h file.h buffer.h crypt.h line.h utf8.h mlout.h window.h \
defines.h
file.o: file.c file.h buffer.h crypt.h line.h retcode.h utf8.h defines.h \ file.o: file.c file.h buffer.h crypt.h line.h retcode.h utf8.h defines.h \
display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \ display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \
window.h window.h
@ -178,7 +179,7 @@ names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \
isearch.h region.h random.h search.h spawn.h window.h defines.h word.h isearch.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
random.o: random.c random.h basic.h buffer.h crypt.h line.h retcode.h \ random.o: random.c random.h retcode.h basic.h buffer.h crypt.h line.h \
utf8.h display.h estruct.h execute.h input.h bind.h search.h terminal.h \ utf8.h display.h estruct.h execute.h input.h bind.h search.h terminal.h \
defines.h window.h defines.h window.h
region.o: region.c region.h line.h retcode.h utf8.h buffer.h crypt.h \ region.o: region.c region.h line.h retcode.h utf8.h buffer.h crypt.h \

15
eval.c
View File

@ -129,7 +129,8 @@ static const char *envars[] = {
"line", /* text of current line */ "line", /* text of current line */
"gflags", /* global internal emacs flags */ "gflags", /* global internal emacs flags */
"rval", /* child process return value */ "rval", /* child process return value */
"tab", /* tab 4 or 8 */ "tab", /* tab width, 1... */
"hardtab", /* TRUE for hard coded tab, FALSE for soft ones */
"overlap", "overlap",
"jump", "jump",
#if SCROLLCODE #if SCROLLCODE
@ -177,9 +178,10 @@ static const char *envars[] = {
#define EVGFLAGS 35 #define EVGFLAGS 35
#define EVRVAL 36 #define EVRVAL 36
#define EVTAB 37 #define EVTAB 37
#define EVOVERLAP 38 #define EVHARDTAB 38
#define EVSCROLLCOUNT 39 #define EVOVERLAP 39
#define EVSCROLL 40 #define EVSCROLLCOUNT 40
#define EVSCROLL 41
enum function_type { enum function_type {
NILNAMIC = 0, NILNAMIC = 0,
@ -735,6 +737,8 @@ static char *gtenv( char *vname) {
return i_to_a(rval); return i_to_a(rval);
case EVTAB: case EVTAB:
return i_to_a( tabwidth) ; return i_to_a( tabwidth) ;
case EVHARDTAB:
return ltos( hardtab) ;
case EVOVERLAP: case EVOVERLAP:
return i_to_a(overlap); return i_to_a(overlap);
case EVSCROLLCOUNT: case EVSCROLLCOUNT:
@ -1057,6 +1061,9 @@ static int svar(struct variable_description *var, char *value)
status = FALSE ; status = FALSE ;
break; break;
case EVHARDTAB:
hardtab = stol( value) ;
break ;
case EVOVERLAP: case EVOVERLAP:
overlap = atoi(value); overlap = atoi(value);
break; break;

View File

@ -40,7 +40,7 @@ static const char *cname[] = { /* names of colors */
int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */ int gfcolor = NCOLORS - 1 ; /* global forgrnd color (white) */
int gbcolor = 0 ; /* global backgrnd color (black) */ int gbcolor = 0 ; /* global backgrnd color (black) */
static int tabsize ; /* Tab size (0: use real tabs) */ boolean hardtab = TRUE ; /* use hard tab instead of soft tab */
int fillcol = 72 ; /* Current fill column */ int fillcol = 72 ; /* Current fill column */
/* uninitialized global definitions */ /* uninitialized global definitions */
@ -292,17 +292,21 @@ int quote(int f, int n)
* done in this slightly funny way because the tab (in ASCII) has been turned * done in this slightly funny way because the tab (in ASCII) has been turned
* into "C-I" (in 10 bit code) already. Bound to "C-I". * into "C-I" (in 10 bit code) already. Bound to "C-I".
*/ */
int insert_tab(int f, int n) int insert_tab( int f, int n) {
{ int status ;
if (n < 0)
return FALSE; if( n < 0)
if (n == 0 || n > 1) { status = FALSE ;
tabsize = n; else if( n == 0)
return TRUE; status = TRUE ;
} else if( hardtab == TRUE)
if (!tabsize) status = linsert( n, '\t') ;
return linsert(1, '\t'); else /* softtab */
return linsert(tabsize - (getccol(FALSE) % tabsize), ' '); do {
status = linsert( tabwidth - getccol( FALSE) % tabwidth, ' ') ;
} while( status != FALSE && --n) ;
return status ;
} }
#if AEDIT #if AEDIT

View File

@ -1,9 +1,14 @@
#ifndef _RANDOM_H_ #ifndef _RANDOM_H_
#define _RANDOM_H_ #define _RANDOM_H_
#include "retcode.h"
#define AEDIT 1 #define AEDIT 1
extern int fillcol ; /* Fill column */ extern int fillcol ; /* Fill column */
extern boolean hardtab ; /* Use hard tab instead of soft tab */
/* Uninitialized global external declarations. */ /* Uninitialized global external declarations. */