Module Name: src
Committed By: roy
Date: Wed Oct 16 19:59:29 UTC 2013
Modified Files:
src/lib/libcurses: addbytes.c curses.c curses.h curses_private.h
ins_wch.c ins_wstr.c setterm.c
Log Message:
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libcurses/addbytes.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/curses.c
cvs rdiff -u -r1.105 -r1.106 src/lib/libcurses/curses.h
cvs rdiff -u -r1.47 -r1.48 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.5 -r1.6 src/lib/libcurses/ins_wch.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libcurses/ins_wstr.c
cvs rdiff -u -r1.51 -r1.52 src/lib/libcurses/setterm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libcurses/addbytes.c
diff -u src/lib/libcurses/addbytes.c:1.39 src/lib/libcurses/addbytes.c:1.40
--- src/lib/libcurses/addbytes.c:1.39 Fri Jul 1 01:19:33 2011
+++ src/lib/libcurses/addbytes.c Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: addbytes.c,v 1.39 2011/07/01 01:19:33 joerg Exp $ */
+/* $NetBSD: addbytes.c,v 1.40 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: addbytes.c,v 1.39 2011/07/01 01:19:33 joerg Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.40 2013/10/16 19:59:29 roy Exp $");
#endif
#endif /* not lint */
@@ -199,11 +199,13 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
static char blanks[] = " ";
int newx;
attr_t attributes;
+ int tabsize;
switch (c) {
case '\t':
+ tabsize = win->screen->TABSIZE;
PSYNCH_OUT;
- if (waddbytes(win, blanks, 8 - (*x % 8)) == ERR)
+ if (waddbytes(win, blanks, tabsize - (*x % tabsize)) == ERR)
return (ERR);
PSYNCH_IN;
break;
@@ -324,7 +326,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **
#ifndef HAVE_WCHAR
return (ERR);
#else
- int sx = 0, ex = 0, cw = 0, i = 0, newx = 0;
+ int sx = 0, ex = 0, cw = 0, i = 0, newx = 0, tabsize;
__LDATA *lp = &win->alines[*y]->line[*x], *tp = NULL;
nschar_t *np = NULL;
cchar_t cc;
@@ -360,7 +362,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **
cc.vals[0] = L' ';
cc.elements = 1;
cc.attributes = win->wattr;
- for (i = 0; i < 8 - (*x % 8); i++) {
+ tabsize = win->screen->TABSIZE;
+ for (i = 0; i < tabsize - (*x % tabsize); i++) {
if (wadd_wch(win, &cc) == ERR)
return ERR;
}
Index: src/lib/libcurses/curses.c
diff -u src/lib/libcurses/curses.c:1.24 src/lib/libcurses/curses.c:1.25
--- src/lib/libcurses/curses.c:1.24 Wed Feb 3 15:34:40 2010
+++ src/lib/libcurses/curses.c Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.c,v 1.24 2010/02/03 15:34:40 roy Exp $ */
+/* $NetBSD: curses.c,v 1.25 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#)curses.c 8.3 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: curses.c,v 1.24 2010/02/03 15:34:40 roy Exp $");
+__RCSID("$NetBSD: curses.c,v 1.25 2013/10/16 19:59:29 roy Exp $");
#endif
#endif /* not lint */
@@ -66,6 +66,7 @@ WINDOW *__virtscr; /* Virtual screen (
SCREEN *_cursesi_screen; /* the current screen we are using */
int COLS; /* Columns on the screen. */
int LINES; /* Lines on the screen. */
+int TABSIZE; /* Size of a tab. */
int COLORS; /* Maximum colors on the screen */
int COLOR_PAIRS = 0; /* Maximum color pairs on the screen */
int My_term = 0; /* Use Def_term regardless. */
Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.105 src/lib/libcurses/curses.h:1.106
--- src/lib/libcurses/curses.h:1.105 Wed Oct 16 12:43:35 2013
+++ src/lib/libcurses/curses.h Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.105 2013/10/16 12:43:35 roy Exp $ */
+/* $NetBSD: curses.h,v 1.106 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -410,6 +410,7 @@ extern int COLORS; /* Max colors on th
extern int COLOR_PAIRS; /* Max color pairs on the screen. */
extern int ESCDELAY; /* Delay between keys in esc seq's. */
+extern int TABSIZE; /* Size of a tab. */
#ifndef OK
#define ERR (-1) /* Error return. */
Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.47 src/lib/libcurses/curses_private.h:1.48
--- src/lib/libcurses/curses_private.h:1.47 Tue Oct 4 11:01:13 2011
+++ src/lib/libcurses/curses_private.h Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_private.h,v 1.47 2011/10/04 11:01:13 roy Exp $ */
+/* $NetBSD: curses_private.h,v 1.48 2013/10/16 19:59:29 roy Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@@ -193,6 +193,7 @@ struct __screen {
int lx, ly; /* loop parameters for refresh */
int COLS; /* Columns on the screen. */
int LINES; /* Lines on the screen. */
+ int TABSIZE; /* Size of a tab. */
int COLORS; /* Maximum colors on the screen */
int COLOR_PAIRS; /* Maximum color pairs on the screen */
int My_term; /* Use Def_term regardless. */
Index: src/lib/libcurses/ins_wch.c
diff -u src/lib/libcurses/ins_wch.c:1.5 src/lib/libcurses/ins_wch.c:1.6
--- src/lib/libcurses/ins_wch.c:1.5 Tue Feb 23 19:48:26 2010
+++ src/lib/libcurses/ins_wch.c Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: ins_wch.c,v 1.5 2010/02/23 19:48:26 drochner Exp $ */
+/* $NetBSD: ins_wch.c,v 1.6 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ins_wch.c,v 1.5 2010/02/23 19:48:26 drochner Exp $");
+__RCSID("$NetBSD: ins_wch.c,v 1.6 2013/10/16 19:59:29 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -102,7 +102,7 @@ wins_wch(WINDOW *win, const cchar_t *wch
#else
__LDATA *start, *temp1, *temp2;
__LINE *lnp;
- int cw, pcw, x, y, sx, ex, newx, i;
+ int cw, pcw, x, y, sx, ex, newx, i, tabsize;
nschar_t *np, *tnp;
wchar_t ws[] = L" ";
@@ -146,8 +146,9 @@ wins_wch(WINDOW *win, const cchar_t *wch
}
return OK;
case L'\t':
- if (wins_nwstr(win, ws, min(win->maxx - x, 8-(x % 8)))
- == ERR)
+ tabsize = win->screen->TABSIZE;
+ if (wins_nwstr(win, ws, min(win->maxx - x,
+ tabsize - (x % tabsize))) == ERR)
return ERR;
return OK;
}
Index: src/lib/libcurses/ins_wstr.c
diff -u src/lib/libcurses/ins_wstr.c:1.6 src/lib/libcurses/ins_wstr.c:1.7
--- src/lib/libcurses/ins_wstr.c:1.6 Thu Dec 16 17:42:28 2010
+++ src/lib/libcurses/ins_wstr.c Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: ins_wstr.c,v 1.6 2010/12/16 17:42:28 wiz Exp $ */
+/* $NetBSD: ins_wstr.c,v 1.7 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ins_wstr.c,v 1.6 2010/12/16 17:42:28 wiz Exp $");
+__RCSID("$NetBSD: ins_wstr.c,v 1.7 2013/10/16 19:59:29 roy Exp $");
#endif /* not lint */
#include <string.h>
@@ -136,7 +136,7 @@ wins_nwstr(WINDOW *win, const wchar_t *w
__LDATA *start, *temp1, *temp2;
__LINE *lnp;
const wchar_t *scp;
- int width, len, sx, x, y, cw, pcw, newx;
+ int width, len, sx, x, y, cw, pcw, newx, tabsize;
nschar_t *np;
wchar_t ws[] = L" ";
@@ -266,9 +266,10 @@ wins_nwstr(WINDOW *win, const wchar_t *w
}
continue;
case L'\t':
+ tabsize = win->screen->TABSIZE;
if (wins_nwstr(win, ws,
- min(win->maxx - x, 8-(x % 8)))
- == ERR)
+ min(win->maxx - x, tabsize - (x % tabsize)))
+ == ERR)
return ERR;
continue;
}
Index: src/lib/libcurses/setterm.c
diff -u src/lib/libcurses/setterm.c:1.51 src/lib/libcurses/setterm.c:1.52
--- src/lib/libcurses/setterm.c:1.51 Wed Sep 25 03:28:20 2013
+++ src/lib/libcurses/setterm.c Wed Oct 16 19:59:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: setterm.c,v 1.51 2013/09/25 03:28:20 dsainty Exp $ */
+/* $NetBSD: setterm.c,v 1.52 2013/10/16 19:59:29 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94";
#else
-__RCSID("$NetBSD: setterm.c,v 1.51 2013/09/25 03:28:20 dsainty Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.52 2013/10/16 19:59:29 roy Exp $");
#endif
#endif /* not lint */
@@ -95,7 +95,6 @@ _cursesi_setterm(char *type, SCREEN *scr
screen->LINES = t_lines(screen->term);
screen->COLS = t_columns(screen->term);
}
-
}
/* POSIX 1003.2 requires that the environment override. */
@@ -105,7 +104,12 @@ _cursesi_setterm(char *type, SCREEN *scr
screen->COLS = (int) strtol(p, NULL, 0);
if ((p = getenv("ESCDELAY")) != NULL)
ESCDELAY = (int) strtol(p, NULL, 0);
-
+ if ((p = getenv("TABSIZE")) != NULL)
+ screen->TABSIZE = (int) strtol(p, NULL, 0);
+ else if (t_init_tabs(screen->term) >= 0)
+ screen->TABSIZE = (int) t_init_tabs(screen->term);
+ else
+ screen->TABSIZE = 8;
/*
* Want cols > 4, otherwise things will fail.
*/
@@ -114,10 +118,12 @@ _cursesi_setterm(char *type, SCREEN *scr
LINES = screen->LINES;
COLS = screen->COLS;
+ TABSIZE = screen->TABSIZE;
#ifdef DEBUG
- __CTRACE(__CTRACE_INIT, "setterm: LINES = %d, COLS = %d\n",
- LINES, COLS);
+ __CTRACE(__CTRACE_INIT,
+ "setterm: LINES = %d, COLS = %d\n, TABSIZE = %d\n",
+ LINES, COLS, TABSIZE);
#endif
/*
@@ -243,6 +249,7 @@ _cursesi_resetterm(SCREEN *screen)
LINES = screen->LINES;
COLS = screen->COLS;
+ TABSIZE = screen->TABSIZE;
__GT = screen->GT;
__noqch = screen->noqch;