Fixed display problem with percent complete messages

svn path=/trunk/; revision=895
This commit is contained in:
Curtis Gedak 2008-09-04 16:36:14 +00:00
parent 3844c2b096
commit dbccd477cf
4 changed files with 38 additions and 2 deletions

View File

@ -12,6 +12,7 @@ not an invitation to misrepresent who contributed to GNU GParted.
We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org).
Curtis Gedak <gedakc@users.sourceforge.net>
* Wrote Utils::cleanup_cursor() function
* Rewrote get_label functionality for hfs
* Wrote create, get_label, and check_repair functionality for hfs+
* Wrote get_label functionality for fat16 and fat32 filesystems

View File

@ -1,3 +1,12 @@
2008-09-04 Curtis Gedak <gedakc@gmail.com>
* include/Utils.h,
src/Utils.cc: Fixed display problem with percent complete messages.
- Some commands use cursor repositioning to display progress.
This cursoring does not display well within the tracking of
gparted details. A newly added function will cleanup the output.
- Closes GParted bug #532574
2008-09-01 Curtis Gedak <gedakc@gmail.com>
* COPYING-DOCS: Added new file containing GFDL 1.2 license

View File

@ -140,9 +140,10 @@ public:
const char drive_letter, const Glib::ustring & device_path ) ;
static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
static Glib::ustring trim( const Glib::ustring & src, const Glib::ustring & c = " \t\r\n" ) ;
static Glib::ustring cleanup_cursor( const Glib::ustring & text ) ;
};
}//GParted

View File

@ -254,7 +254,7 @@ int Utils::execute_command( const Glib::ustring & command,
return -1 ;
}
output = std_out ;
output = Utils::cleanup_cursor( std_out ) ;
error = std_error ;
return exit_status ;
@ -331,4 +331,29 @@ Glib::ustring Utils::trim( const Glib::ustring & src, const Glib::ustring & c /*
return src.substr(p1, (p2-p1)+1);
}
Glib::ustring Utils::cleanup_cursor( const Glib::ustring & text )
{
//Clean up text for commands that use cursoring to display progress.
Glib::ustring str = text;
//remove backspace '\b' and delete previous character. Used in mke2fs output.
for ( unsigned int index = str .find( "\b" ) ; index < str .length() ; index = str .find( "\b" ) ) {
if ( index > 0 )
str .erase( index - 1, 2 ) ;
else
str .erase( index, 1 ) ;
}
//remove carriage return and line up to previous line feed. Used in ntfsclone output.
//NOTE: Normal linux line end is line feed. DOS uses CR + LF.
for ( unsigned int index1 = str .find( "\r") ; index1 < str .length() ; index1 = str .find( "\r" ) ) {
if ( str .at(index1 + 1) != '\n') { //Only process if next character is not a LF
unsigned int index2 = str .rfind( "\n", index1 ) ;
if ( index2 <= index1 )
str .erase( index2 + 1, index1 - index2 ) ;
}
}
return str;
}
} //GParted..