[yast-commit] r67418 - in /trunk/ncurses/src: NCtext.cc NCurses.h
Author: gs Date: Mon Feb 13 12:32:04 2012 New Revision: 67418 URL: http://svn.opensuse.org/viewcvs/yast?rev=67418&view=rev Log: remove \r from text, respect tabs for calculation of columns Modified: trunk/ncurses/src/NCtext.cc trunk/ncurses/src/NCurses.h Modified: trunk/ncurses/src/NCtext.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCtext.cc?rev=67418&r1=67417&r2=67418&view=diff ============================================================================== --- trunk/ncurses/src/NCtext.cc (original) +++ trunk/ncurses/src/NCtext.cc Mon Feb 13 12:32:04 2012 @@ -46,6 +46,7 @@ #include <wchar.h> // wcwidth #include <langinfo.h> +#include <boost/algorithm/string.hpp> const NCstring NCtext::emptyStr; @@ -81,7 +82,7 @@ if ( ntext.str().empty() ) return; - const wstring & text( ntext.str() ); + wstring text( ntext.str() ); wstring::size_type spos = 0; @@ -89,6 +90,9 @@ bool sawnl = false; // saw new line + // handle DOS text + boost::erase_all( text, L"\r" ); + while (( cpos = text.find( L'\n', spos ) ) != wstring::npos ) { if ( sawnl ) @@ -119,8 +123,11 @@ if ( ntext.str().empty() ) return; - const wstring & text( ntext.str() ); + wstring text( ntext.str() ); + // handle DOS text + boost::erase_all( text, L"\r" ); + wstring::size_type spos = 0; wstring::size_type cpos = wstring::npos; @@ -194,7 +201,10 @@ for ( wstr_it = ( *line ).str().begin(); wstr_it != ( *line ).str().end() ; ++wstr_it ) { - tmp_len += wcwidth( *wstr_it ); + if ( iswprint( *wstr_it ) ) + tmp_len += wcwidth( *wstr_it ); + else if ( *wstr_it == L'\t' ) + tmp_len += NCurses::tabsize(); } if ( tmp_len > llen ) Modified: trunk/ncurses/src/NCurses.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCurses.h?rev=67418&r1=67417&r2=67418&view=diff ============================================================================== --- trunk/ncurses/src/NCurses.h (original) +++ trunk/ncurses/src/NCurses.h Mon Feb 13 12:32:04 2012 @@ -207,6 +207,8 @@ static int lines() { return ::LINES; } + static int tabsize() { return ::TABSIZE; } + void run(); public: -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn2.opensuse.org