From ab3de212bfee5ba86666aa6fe3855d9f627af48e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 12 Jul 2009 14:01:36 -0400 Subject: [PATCH] Bug Fix - Conditional compilation (via FEATURE_NCURSES_COLS) to either use ncurses COLS and LINES global variables, or determine these from the WINDOW structure. --- src/interactive.cpp | 20 +++++++++++--------- src/main.h | 7 ++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/interactive.cpp b/src/interactive.cpp index a2e5a59f4..90177c74b 100644 --- a/src/interactive.cpp +++ b/src/interactive.cpp @@ -58,14 +58,15 @@ int Context::interactive () // throw std::string ("unimplemented Context::interactive"); // Fake interactive teaser... -/* - WINDOW* w = initscr (); - int width = w->_maxx + 1; - int height = w->_maxy + 1; -*/ +#ifdef FEATURE_NCURSES_COLS initscr (); int width = COLS; int height = LINES; +#else + WINDOW* w = initscr (); + int width = w->_maxx + 1; + int height = w->_maxy + 1; +#endif (void) nonl (); (void) cbreak (); @@ -141,12 +142,13 @@ int Context::getWidth () #ifdef HAVE_LIBNCURSES if (config.get ("curses", true)) { -/* - WINDOW* w = initscr (); - width = w->_maxx + 1; -*/ +#ifdef FEATURE_NCURSES_COLS initscr (); width = COLS; +#else + WINDOW* w = initscr (); + width = w->_maxx + 1; +#endif endwin (); std::stringstream out; diff --git a/src/main.h b/src/main.h index a5374a460..8735c5e7d 100644 --- a/src/main.h +++ b/src/main.h @@ -27,9 +27,10 @@ #ifndef INCLUDED_MAIN #define INCLUDED_MAIN -#define FEATURE_TDB_OPT 1 // TDB Optimization reduces file I/O. -#define FEATURE_NEW_ID 1 // Echoes back new id. -#define FEATURE_SHELL 1 // Interactive shell. +#define FEATURE_TDB_OPT 1 // TDB Optimization reduces file I/O. +#define FEATURE_NEW_ID 1 // Echoes back new id. +#define FEATURE_SHELL 1 // Interactive shell. +#define FEATURE_NCURSES_COLS 1 // Shortcut that avoids WINDOW. #include #include