[yast-commit] r60145 - in /branches/SuSE-Linux-11_2-Branch/ncurses: VERSION package/yast2-ncurses.changes src/NCPad.cc src/NCPad.h src/NCTablePad.cc src/NCTablePad.h src/ncursesw.h
Author: mlandres Date: Fri Dec 18 11:47:37 2009 New Revision: 60145 URL: http://svn.opensuse.org/viewcvs/yast?rev=60145&view=rev Log: Work around 32768 lines limit in ncurses table. (bnc #550733) Modified: branches/SuSE-Linux-11_2-Branch/ncurses/VERSION branches/SuSE-Linux-11_2-Branch/ncurses/package/yast2-ncurses.changes branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.cc branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.h branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.cc branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.h branches/SuSE-Linux-11_2-Branch/ncurses/src/ncursesw.h Modified: branches/SuSE-Linux-11_2-Branch/ncurses/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/VERSION?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/VERSION (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/VERSION Fri Dec 18 11:47:37 2009 @@ -1 +1 @@ -2.18.10 +2.18.11 Modified: branches/SuSE-Linux-11_2-Branch/ncurses/package/yast2-ncurses.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/package/yast2-ncurses.changes?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/package/yast2-ncurses.changes (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/package/yast2-ncurses.changes Fri Dec 18 11:47:37 2009 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Dec 18 11:46:34 CET 2009 - ma@suse.de + +- Work around 32768 lines limit in ncurses table. (bnc #550733) +- V 2.18.11 + +------------------------------------------------------------------- Thu May 28 11:28:12 CEST 2009 - gs@suse.de - NCTable/NCTablePad: only sort in reverse order if Ctrl 'o' Modified: branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.cc?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.cc (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.cc Fri Dec 18 11:47:37 2009 @@ -20,6 +20,29 @@ #include <YUILog.h> #include "NCPad.h" +/////////////////////////////////////////////////////////////////// + +// PAD_PAGESIZE needs to be large enough to feed any destwin. We +// get in throuble here if the terminal has more than 1024 lines. +#define PAD_PAGESIZE 1024 + +// Maximum height of the NCursesPad (e.g. in case it can't hold more +// than 32768 lines). Larger pads need to page. +//#define MAX_PAD_HEIGHT 100 +#define MAX_PAD_HEIGHT NCursesWindow::maxcoord() + + +NCPad::NCPad( int lines, int cols, const NCWidget & p ) + : NCursesPad( lines > MAX_PAD_HEIGHT ? PAD_PAGESIZE : lines, cols ) + , _vheight( lines > MAX_PAD_HEIGHT ? lines : 0 ) + , parw( p ) + , destwin ( 0 ) + , maxdpos ( 0 ) + , maxspos ( 0 ) + , dclear ( false ) + , dirty ( false ) +{} + void NCPad::Destwin( NCursesWindow * dwin ) { @@ -29,9 +52,9 @@ if ( destwin ) { - wsze mysze( maxy() + 1, maxx() + 1 ); + wsze mysze( vheight(), width() ); - drect = wrect( 0, wsze( destwin->maxy() + 1, destwin->maxx() + 1 ) ); + drect = wrect( 0, wsze( destwin->height(), destwin->width() ) ); srect = wrect( 0, wsze::min( mysze, drect.Sze ) ); maxdpos = drect.Pos + srect.Sze - 1; maxspos = mysze - srect.Sze; @@ -52,7 +75,7 @@ { SetPadSize( nsze ); // might be enlarged by NCPadWidget if redirected - if ( nsze.H != height() + if ( nsze.H != vheight() || nsze.W != width() ) { NCursesWindow * odest = Destwin(); @@ -60,7 +83,19 @@ if ( odest ) Destwin( 0 ); + if ( nsze.H > MAX_PAD_HEIGHT ) + { + yuiDebug() << "TRUCNATE PAD: " << nsze.H << " > " << MAX_PAD_HEIGHT << endl; + NCursesPad::resize( PAD_PAGESIZE, nsze.W ); + _vheight = nsze.H; + } + else + { NCursesPad::resize( nsze.H, nsze.W ); + _vheight = 0; + } + + yuiDebug() << "Pageing ?: " << pageing() << endl; if ( odest ) Destwin( odest ); @@ -89,6 +124,8 @@ updateScrollHint(); + if ( ! pageing() ) + { return copywin( *destwin, srect.Pos.L, srect.Pos.C, drect.Pos.L, drect.Pos.C, @@ -96,6 +133,19 @@ false ); } + // Here: Table is pageing, so we must prepare the visible lines + // on the Pad before we're copying them to the destwin: + wsze lSze( 1, width() ); + for ( unsigned i = 0; i <= maxdpos.L; ++i ) + { + directDraw( *this, wrect( wpos( i, 0 ), lSze ), srect.Pos.L+i ); + } + return copywin( *destwin, + 0, srect.Pos.C, + drect.Pos.L, drect.Pos.C, + maxdpos.L, maxdpos.C, + false ); + } return OK; } @@ -128,7 +178,7 @@ break; case KEY_HOME: - ScrlUp( maxy() ); + ScrlUp( vheight() ); break; case KEY_DOWN: @@ -140,7 +190,7 @@ break; case KEY_END: - ScrlDown( maxy() ); + ScrlDown( vheight() ); break; case KEY_LEFT: Modified: branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.h?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.h (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/src/NCPad.h Fri Dec 18 11:47:37 2009 @@ -86,6 +86,23 @@ class NCPad : public NCursesPad, public NCScrollHint { +private: + + /** The real height in case the NCursesPad is truncated, otherwise \c 0. + * + * \note Don't use _vheight directly, but \ref vheight. + * + * Up to ncurses5, ncurses uses \c short for window dimensions (can't hold + * more than 32768 lines). If \ref resize truncated the window, the real + * size is in \ref _vheight. Longer lists need to be paged. + * + * \todo Once all NCPad based types are able to page, \a maxPadHeight could be + * set to e.g \c 1024 to avoid bigger widgets in memory. Currently just + * \ref NCTablePad supports paging. If paging is \c ON, all content lines are + * written via \ref directDraw. Without pageing \ref DoRedraw is reponsible for this. + */ + int _vheight; + protected: const NCWidget & parw; @@ -99,6 +116,11 @@ bool dclear; bool dirty; + /** The (virtual) height of the Pad (even if truncated). */ + int vheight() const { return _vheight ? _vheight : height(); } + + /** Whether the Pad is truncated (we're pageing). */ + bool pageing() const { return _vheight; } virtual int dirtyPad() { dirty = false; return setpos( CurPos() ); } @@ -111,18 +133,20 @@ virtual void updateScrollHint(); -public: + /** Directly draw a table item at a specific location. + * + * \ref update usually copies the visible table content from the + * \ref NCursesPad to \ref destwin. In case the \ref NCursesPad + * is truncated, the visible lines are prepared immediately before + * they are written to \ref destwin + * . + * \see \ref _vheight. + */ + virtual void directDraw( NCursesWindow & w, const wrect at, unsigned lineno ) {} - NCPad( int lines, int cols, const NCWidget & p ) - : NCursesPad( lines, cols ) - , parw( p ) - , destwin( 0 ) - , maxdpos( 0 ) - , maxspos( 0 ) - , dclear( false ) - , dirty( false ) - {} +public: + NCPad( int lines, int cols, const NCWidget & p ); virtual ~NCPad() {} public: Modified: branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.cc?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.cc (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.cc Fri Dec 18 11:47:37 2009 @@ -207,11 +207,15 @@ wsze lSze( 1, width() ); + if ( ! pageing() ) + { for ( unsigned l = 0; l < Lines(); ++l ) { Items[l]->DrawAt( *this, wrect( wpos( l, 0 ), lSze ), ItemStyle, (( unsigned )citem.L == l ) ); } + } + // else: item drawing requested via directDraw if ( Headpad.width() != width() ) Headpad.resize( 1, width() ); @@ -230,6 +234,16 @@ +void NCTablePad::directDraw( NCursesWindow & w, const wrect at, unsigned lineno ) +{ + if ( lineno < Lines() ) + Items[lineno]->DrawAt( w, at, ItemStyle, ((unsigned)citem.L == lineno) ); + else + yuiWarning() << "Illegal Lineno " << lineno << " (" << Lines() << ")" << endl; +} + + + int NCTablePad::setpos( const wpos & newpos ) { if ( !Lines() ) @@ -265,6 +279,8 @@ return DoRedraw(); } + if ( ! pageing() ) + { // adjust only if ( citem.L != oitem ) { @@ -275,6 +291,8 @@ Items[citem.L]->DrawAt( *this, wrect( wpos( citem.L, 0 ), wsze( 1, width() ) ), ItemStyle, true ); + } + // else: item drawing requested via directDraw if ( srect.Pos.C != opos ) SendHead(); Modified: branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.h?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.h (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/src/NCTablePad.h Fri Dec 18 11:47:37 2009 @@ -163,6 +163,8 @@ virtual int DoRedraw(); virtual void updateScrollHint(); + virtual void directDraw( NCursesWindow & w, const wrect at, unsigned lineno ); + public: NCTablePad( int lines, int cols, const NCWidget & p ); Modified: branches/SuSE-Linux-11_2-Branch/ncurses/src/ncursesw.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/ncurses/src/ncursesw.h?rev=60145&r1=60144&r2=60145&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/ncurses/src/ncursesw.h (original) +++ branches/SuSE-Linux-11_2-Branch/ncurses/src/ncursesw.h Fri Dec 18 11:47:37 2009 @@ -24,6 +24,7 @@ #include <ncursesw/etip.h> #include <cstdio> #include <cstdarg> +#include <climits> #include "position.h" #include <ncursesw/curses.h> @@ -887,6 +888,9 @@ #define bkgdset UNDEF(bkgdset) #endif +template <class _Tp> inline int ncursesMaxCoord() { return INT_MAX; } +template <> inline int ncursesMaxCoord<short>() { return SHRT_MAX; } + /** * @short C++ class for windows. */ @@ -1084,6 +1088,8 @@ */ int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; } + /** Ncurses up to ncurses5 internally uses \c short. */ + static int maxcoord() { return ncursesMaxCoord<NCURSES_SIZE_T>(); } wsze size() const { return wsze( height(), width() ); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mlandres@svn.opensuse.org