Author: mlandres Date: Fri Nov 27 19:23:41 2009 New Revision: 59840 URL: http://svn.opensuse.org/viewcvs/yast?rev=59840&view=rev Log: Work around 32768 lines limit in ncurses table. (bnc #550733) Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.cc branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.h branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.cc branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.h branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCtext.cc branches/SuSE-SLE-10-SP3-Branch/ncurses/src/ncursesw.h Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.cc?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.cc (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.cc Fri Nov 27 19:23:41 2009 @@ -19,6 +19,42 @@ #include "Y2Log.h" #include "NCPad.h" +#if 0 +#undef DBG_CLASS +#define DBG_CLASS "_NCPad_" +#endif + +/////////////////////////////////////////////////////////////////// + +// 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() + +/////////////////////////////////////////////////////////////////// +// +// +// METHOD NAME : NCPad::NCPad +// METHOD TYPE : Constructor +// +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 ) +{ + IDBG << maxcoord() << endl; +} + + /////////////////////////////////////////////////////////////////// // // @@ -33,9 +69,9 @@ destwin = dwin; 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; @@ -61,12 +97,27 @@ void NCPad::resize( wsze nsze ) { SetPadSize( nsze ); // might be enlarged by NCPadWidget if redirected - if ( nsze.H != height() + + if ( nsze.H != vheight() || nsze.W != width() ) { NCursesWindow * odest = Destwin(); if ( odest ) Destwin( 0 ); + + if ( nsze.H > MAX_PAD_HEIGHT ) + { + IDBG << "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; + } + + IDBG << "Pageing ?: " << pageing() << endl; + if ( odest ) Destwin( odest ); } @@ -106,12 +157,28 @@ updateScrollHint(); + if ( ! pageing() ) + { return copywin( *destwin, srect.Pos.L, srect.Pos.C, drect.Pos.L, drect.Pos.C, maxdpos.L, maxdpos.C, 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; } @@ -162,7 +229,7 @@ ScrlUp( destwin->maxy() ); break; case KEY_HOME: - ScrlUp( maxy() ); + ScrlUp( vheight() ); break; case KEY_DOWN: @@ -172,7 +239,7 @@ ScrlDown( destwin->maxy() ); break; case KEY_END: - ScrlDown( maxy() ); + ScrlDown( vheight() ); break; case KEY_LEFT: Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.h?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.h (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCPad.h Fri Nov 27 19:23:41 2009 @@ -97,6 +97,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; @@ -110,6 +127,12 @@ 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; } + protected: virtual int dirtyPad() { dirty = false; return setpos( CurPos() ); } @@ -121,17 +144,20 @@ virtual void updateScrollHint(); + /** 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 ) {} + public: - NCPad( int lines, int cols, const NCWidget & p ) - : NCursesPad( lines, cols ) - , parw( p ) - , destwin ( 0 ) - , maxdpos ( 0 ) - , maxspos ( 0 ) - , dclear ( false ) - , dirty ( false ) - {} + NCPad( int lines, int cols, const NCWidget & p ); virtual ~NCPad() {} public: Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.cc?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.cc (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.cc Fri Nov 27 19:23:41 2009 @@ -241,10 +241,10 @@ // wsze NCTablePad::UpdateFormat() { - IDBG << endl; dirty = true; dirtyFormat = false; ItemStyle.ResetToMinCols(); + for( unsigned l = 0; l < Lines(); ++l ) { Items[l]->UpdateFormat( ItemStyle ); } @@ -274,11 +274,17 @@ bkgdset( ItemStyle.getBG() ); clear(); + 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() ); @@ -291,6 +297,14 @@ return update(); } +void NCTablePad::directDraw( NCursesWindow & w, const wrect at, unsigned lineno ) +{ + if ( lineno < Lines() ) + Items[lineno]->DrawAt( w, at, ItemStyle, ((unsigned)citem.L == lineno) ); + else + IDBG << "Illegal Lineno " << lineno << " (" << Lines() << ")" << endl; +} + /////////////////////////////////////////////////////////////////// // // @@ -326,6 +340,8 @@ return DoRedraw(); } + if ( ! pageing() ) + { // adjust only if ( citem.L != oitem ) { Items[oitem]->DrawAt( *this, wrect( wpos( oitem, 0 ), wsze( 1, width() ) ), @@ -334,6 +350,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-SLE-10-SP3-Branch/ncurses/src/NCTablePad.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.h?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.h (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCTablePad.h Fri Nov 27 19:23:41 2009 @@ -67,6 +67,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-SLE-10-SP3-Branch/ncurses/src/NCtext.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCtext.cc?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCtext.cc (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCtext.cc Fri Nov 27 19:23:41 2009 @@ -322,7 +322,7 @@ w.move( l, area.Pos.C + pre ); } - NCDBG << "TERMINAL: " << NCstring::terminalEncoding() << " CODESET: " << nl_langinfo( CODESET) << endl; + DDBG << "TERMINAL: " << NCstring::terminalEncoding() << " CODESET: " << nl_langinfo( CODESET) << endl; if ( len ) { if ( NCstring::terminalEncoding() != "UTF-8" ) Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/ncursesw.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/ncursesw.h?rev=59840&r1=59839&r2=59840&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/ncursesw.h (original) +++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/ncursesw.h Fri Nov 27 19:23:41 2009 @@ -27,6 +27,7 @@ #include <etip.h> #include <cstdio> #include <cstdarg> +#include <climits> #include "position.h" extern "C" { @@ -746,6 +747,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. */ @@ -959,6 +963,8 @@ */ int maxy() const { return w->_maxy; } + /** Ncurses up to ncurses5 internally uses \c short. */ + static int maxcoord() { return ncursesMaxCoord<NCURSES_SIZE_T>(); } wsze size() const { return wsze(height(),width()); } wpos begpos() const { return wpos(begy(),begx()); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org