Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.2beta

Request #12357 erase() does not work as expected on Windows
Submitted: 2007-10-30 02:44 UTC
From: cwiedmann Assigned: et
Status: Assigned Package: Console_ProgressBar (version CVS)
PHP Version: 5.2.4 OS: Windows_NT
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 38 - 12 = ?

 
 [2007-10-30 02:44 UTC] cwiedmann (Carsten Wiedmann)
Description: ------------ Hello, a) if you call erase() after the work is done, the bar/line is not erased. "echo chr(8);" on Windows shifts the curser left, but don't delete the character under the cursor. Curious: If I use ALT-8 in the cmd.exe, this works... With the attached patch, I first shift left, print a space and shift left once more. But only if the function erase() is not called from update(). b) in package2.xml is a wrong dependence to PHP. It must be 4.1.0 and not 4.0.0 (for this code) BTW: PEAR 1.4.0b1 requires 4.2.0. c) I have changed some docblocks and line lenghts, because of the PEAR coding standards. Regards, Carsten PS: Because of the upload limit, I must split the patch in more the one files. Test script: --------------- <?php require_once 'Console/ProgressBar.php'; $bar = new Console_ProgressBar('[%bar%] %percent%', '=>', ' ', 49, 7); for ($i = 0; $i <= 7; $i++) { $bar->update($i); sleep(1); } $bar->erase(); ?> Expected result: ---------------- D:\Apache2.2\htdocs>test.php D:\Apache2.2\htdocs> Actual result: -------------- D:\Apache2.2\htdocs>test.php [======================================>] 100.00% D:\Apache2.2\htdocs>

Comments

 [2007-11-08 09:01 UTC] et (Stefan Walk)
Thanks you for your assistance, unfortunately i won't have time to set up a windows test environment until mid to end of this month, so i will test, commit & release the patch when i get the chance. Thanks again for your efforts!
 [2007-11-25 18:13 UTC] et (Stefan Walk)
Thank you for taking the time to report a problem with the package. Unfortunately you are not using a current version of the package -- the problem might already be fixed. Please download a new version from http://pear.php.net/packages.php If you are able to reproduce the bug with one of the latest versions, please change the package version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PEAR. Added code to print spaces when erase(true) is called. Please test (your test script is missing the argument)
 [2007-11-29 09:12 UTC] cwiedmann (Carsten Wiedmann)
Hello Stefan, > (your test script is missing the argument) First, I have really make two mistakes: 1) I have not test the old code on *nix, thus I have assumed that's only a Windows problem. (but on *nix there was the same bahaviour) 2) Regarding to the method name erase() and the method description, I have assumed, that this method erase (remove) the printed line, and not only move the pointer back. And I was really wonderering, what this parameter $clear should do. > Added code to print spaces when erase(true) is called. Ok, now, with setting $clear to true, it works, like I have expected. Four remarks: 1) I think, the method description is still misleading (the new description makes it a little clearer) 2) If I set 'ansi_terminal' => true, 'ansi_clear' => true the line is allways removed, regardless if I set $clear to false or true. 3) I can't see your changes in CVS. 4) Making the code phpcs ready is still appreciated. Because of these remarks, it's now a "Feature/Change Request". Regards, Carsten
 [2007-11-29 10:16 UTC] et (Stefan Walk)
To your remarks ... Yes, the description could be clearer, maybe i'll rename the parameter to force_clear. The intention of the parameter is this: if it's set to true, the bar is to be removed from sight, if it's set to false, the code doesn't care - it's just so the next print is going to overwrite the place where the old one was. The repository has moved, that's on the package page (PHP CVS has annoyed me one last time). As for the CS issues - I'll do that when i find time.
 [2007-11-29 10:39 UTC] cwiedmann (Carsten Wiedmann)
> The intention of the parameter is this: if it's set > to true, the bar is to be removed from sight, if it's > set to false, the code doesn't care - it's just so > the next print is going to overwrite the place where > the old one was. Just an additional question: | <?php | require_once 'Console/ProgressBar.php'; | $bar = new Console_ProgressBar('[%bar%] %percent%', | '=>', ' ', 49, 7); | for ($i = 0; $i <= 7; $i++) { | $bar->update($i); | sleep(1); | } | $bar->erase(); | echo 'hallo'.PHP_EOL; | ?> Result with Windows: | D:\Apache2.2\htdocs\test>php test.php | hallo==================================>] 100.00% | | D:\Apache2.2\htdocs\test> Result with FreeBSD: | bsdserver-1-node2# bin/php test.php | hallo==================================>] 100.00% | bsdserver-1-node2# That's the desired behaviour on *nix? Regards, Carsten