Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Add TABSIZE, which is derived from terminfo in...
details: https://anonhg.NetBSD.org/src/rev/e4b131adfbd4
branches: trunk
changeset: 790540:e4b131adfbd4
user: roy <roy%NetBSD.org@localhost>
date: Wed Oct 16 19:59:29 2013 +0000
description:
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
diffstat:
lib/libcurses/addbytes.c | 13 ++++++++-----
lib/libcurses/curses.c | 5 +++--
lib/libcurses/curses.h | 3 ++-
lib/libcurses/curses_private.h | 3 ++-
lib/libcurses/ins_wch.c | 11 ++++++-----
lib/libcurses/ins_wstr.c | 11 ++++++-----
lib/libcurses/setterm.c | 19 +++++++++++++------
7 files changed, 40 insertions(+), 25 deletions(-)
diffs (254 lines):
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/addbytes.c Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
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 @@
#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 @@
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;
}
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/curses.c
--- a/lib/libcurses/curses.c Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/curses.c Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
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. */
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/curses.h Wed Oct 16 19:59:29 2013 +0000
@@ -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 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. */
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/curses_private.h Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
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. */
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/ins_wch.c
--- a/lib/libcurses/ins_wch.c Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/ins_wch.c Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
#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 @@
}
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;
}
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/ins_wstr.c
--- a/lib/libcurses/ins_wstr.c Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/ins_wstr.c Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
__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 @@
}
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;
}
diff -r 0848cdb34e22 -r e4b131adfbd4 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c Wed Oct 16 19:48:21 2013 +0000
+++ b/lib/libcurses/setterm.c Wed Oct 16 19:59:29 2013 +0000
@@ -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 @@
screen->LINES = t_lines(screen->term);
screen->COLS = t_columns(screen->term);
}
-
}
/* POSIX 1003.2 requires that the environment override. */
@@ -105,7 +104,12 @@
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 @@
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 @@
LINES = screen->LINES;
COLS = screen->COLS;
+ TABSIZE = screen->TABSIZE;
__GT = screen->GT;
__noqch = screen->noqch;
Home |
Main Index |
Thread Index |
Old Index