From 5e0d809e1bc1d5e9d60e506588a9e02fbdf83952 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 30 Jul 2006 19:18:00 +0000 Subject: [PATCH] There's no need to have the tab size settable per window, and the functions to do it have been missing since version 2.2. I'm tempted to just hardwire it at 8... However, ncurses and Solaris curses define a global for it, "TABSIZE". So, let's do that. --- curses.h | 7 ++++--- pdcurses/getstr.c | 5 ++--- pdcurses/initscr.c | 3 ++- pdcurses/pdcwin.c | 8 +++----- pdcurses/window.c | 4 +--- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/curses.h b/curses.h index 5c25acfd..99827640 100644 --- a/curses.h +++ b/curses.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curses.h,v 1.204 2006/07/30 03:55:46 wmcbrine Exp $ */ +/* $Id: curses.h,v 1.205 2006/07/30 19:18:00 wmcbrine Exp $ */ /*----------------------------------------------------------------------* * PDCurses * @@ -536,7 +536,6 @@ typedef struct _win /* definition of a window */ int _flags; /* window properties */ chtype _attrs; /* standard attributes and colors */ chtype _bkgd; /* background, normally blank */ - int _tabsize; /* tab character size */ bool _clear; /* causes clear at next refresh */ bool _leaveit; /* leaves cursor where it is */ bool _scroll; /* allows window scrolling */ @@ -660,6 +659,7 @@ __declspec(dllimport) SCREEN *SP; __declspec(dllimport) MOUSE_STATUS Mouse_status; __declspec(dllimport) int COLORS; __declspec(dllimport) int COLOR_PAIRS; +__declspec(dllimport) int TABSIZE; # else __declspec(dllexport) extern int LINES; __declspec(dllexport) extern int COLS; @@ -669,6 +669,7 @@ __declspec(dllexport) extern SCREEN *SP; __declspec(dllexport) extern MOUSE_STATUS Mouse_status; __declspec(dllexport) extern int COLORS; __declspec(dllexport) extern int COLOR_PAIRS; +__declspec(dllexport) extern int TABSIZE; # endif #else extern int LINES; /* terminal height */ @@ -677,7 +678,7 @@ extern WINDOW *stdscr; /* the default screen window */ extern WINDOW *curscr; /* the current screen image */ extern SCREEN *SP; /* curses variables */ extern MOUSE_STATUS Mouse_status; -extern int COLORS, COLOR_PAIRS; +extern int COLORS, COLOR_PAIRS, TABSIZE; #endif #ifdef CURSES_LIBRARY diff --git a/pdcurses/getstr.c b/pdcurses/getstr.c index 65c85ec6..4af2f9fe 100644 --- a/pdcurses/getstr.c +++ b/pdcurses/getstr.c @@ -38,7 +38,7 @@ # undef wmove #endif -RCSID("$Id: getstr.c,v 1.26 2006/07/15 15:38:24 wmcbrine Exp $"); +RCSID("$Id: getstr.c,v 1.27 2006/07/30 19:18:00 wmcbrine Exp $"); /*man-start************************************************************** @@ -149,7 +149,6 @@ int wgetnstr(WINDOW *win, char *str, int n) p = str; stop = FALSE; - t = win->_tabsize; x = win->_curx; oldcbreak = SP->cbreak; /* remember states */ @@ -181,7 +180,7 @@ int wgetnstr(WINDOW *win, char *str, int n) case '\t': ch = ' '; - num = t - (win->_curx - x) % t; + num = TABSIZE - (win->_curx - x) % TABSIZE; for (i = 0; i < num; i++) { if (chars < n) diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c index f4749296..d3319873 100644 --- a/pdcurses/initscr.c +++ b/pdcurses/initscr.c @@ -38,7 +38,7 @@ # undef wnoutrefresh #endif -RCSID("$Id: initscr.c,v 1.63 2006/07/29 22:01:20 wmcbrine Exp $"); +RCSID("$Id: initscr.c,v 1.64 2006/07/30 19:18:00 wmcbrine Exp $"); const char *_curses_notice = "PDCurses 3.0 - Public Domain 2006"; @@ -49,6 +49,7 @@ WINDOW *stdscr = (WINDOW *)NULL; /* the default screen window */ int _default_lines = 25; /* default terminal height */ int LINES = 0; /* current terminal height */ int COLS = 0; /* current terminal width */ +int TABSIZE = 8; MOUSE_STATUS Mouse_status; diff --git a/pdcurses/pdcwin.c b/pdcurses/pdcwin.c index 009be732..a55e4cdc 100644 --- a/pdcurses/pdcwin.c +++ b/pdcurses/pdcwin.c @@ -20,7 +20,7 @@ #include #include -RCSID("$Id: pdcwin.c,v 1.48 2006/07/29 06:18:24 wmcbrine Exp $"); +RCSID("$Id: pdcwin.c,v 1.49 2006/07/30 19:18:00 wmcbrine Exp $"); static int PDC_newline(WINDOW *, int); @@ -190,7 +190,6 @@ WINDOW *PDC_makenew(int num_lines, int num_columns, int begy, int begx) win->_lastsy2 = LINES - 1; win->_lastsx2 = COLS - 1; win->_bkgd = ' '; /* wrs 4/10/93 -- initialize background to blank */ - win->_tabsize = 8; win->_clear = (bool) ((num_lines == LINES) && (num_columns == COLS)); win->_bmarg = num_lines - 1; win->_parx = win->_pary = -1; @@ -276,7 +275,7 @@ void PDC_sync(WINDOW *win) int PDC_chadd(WINDOW *win, chtype ch, bool xlat, bool advance) { - int x, y, newx, ts, retval; + int x, y, x2, retval; chtype attr, bktmp; PDC_LOG(("PDC_chadd() - called: win=%x ch=%x " @@ -288,7 +287,6 @@ int PDC_chadd(WINDOW *win, chtype ch, bool xlat, bool advance) x = win->_curx; y = win->_cury; - ts = win->_tabsize; if ((y > win->_maxy) || (x > win->_maxx) || (y < 0) || (x < 0)) return ERR; @@ -341,7 +339,7 @@ int PDC_chadd(WINDOW *win, chtype ch, bool xlat, bool advance) switch (ch) { case '\t': - for (newx = ((x / ts) + 1) * ts; x < newx; x++) + for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++) { if (waddch(win, ' ') == ERR) { diff --git a/pdcurses/window.c b/pdcurses/window.c index e93f2fa8..310d766d 100644 --- a/pdcurses/window.c +++ b/pdcurses/window.c @@ -43,7 +43,7 @@ # undef wclrtobot #endif -RCSID("$Id: window.c,v 1.34 2006/07/30 18:57:23 wmcbrine Exp $"); +RCSID("$Id: window.c,v 1.35 2006/07/30 19:18:00 wmcbrine Exp $"); /*man-start************************************************************** @@ -374,7 +374,6 @@ WINDOW *dupwin(WINDOW *win) new->_lastsx2 = win->_lastsx2; new->_flags = win->_flags; new->_attrs = win->_attrs; - new->_tabsize = win->_tabsize; new->_clear = win->_clear; new->_leaveit = win->_leaveit; new->_scroll = win->_scroll; @@ -429,7 +428,6 @@ WINDOW *resize_window(WINDOW *win, int lins, int cols) new->_cury = min(win->_cury, new->_maxy); new->_flags = win->_flags; new->_attrs = win->_attrs; - new->_tabsize = win->_tabsize; new->_clear = win->_clear; new->_leaveit = win->_leaveit; new->_scroll = win->_scroll;