From dbccd477cfb2063018eedc1de2fd3c6b8728569a Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Thu, 4 Sep 2008 16:36:14 +0000 Subject: [PATCH] Fixed display problem with percent complete messages svn path=/trunk/; revision=895 --- AUTHORS | 1 + ChangeLog | 9 +++++++++ include/Utils.h | 3 ++- src/Utils.cc | 27 ++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4d539cd3..bfab65b6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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 + * 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 diff --git a/ChangeLog b/ChangeLog index 2ee5df2e..10cda37f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-09-04 Curtis Gedak + + * 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 * COPYING-DOCS: Added new file containing GFDL 1.2 license diff --git a/include/Utils.h b/include/Utils.h index 89cf93d3..c140c3c1 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -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 diff --git a/src/Utils.cc b/src/Utils.cc index 21ab5b99..c8bb0986 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -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..