0

Alright, I'm working on a (supposed-to-be) simple counting script using ncurses. Everytime it increments the number, I need it to delete the previous number before adding another number, so that it updates rather than appends.

Here is my code:

<?php

ncurses_init();
$i = 0;
$nStr = "Number: ";
ncurses_addstr($nStr);
ncurses_refresh();
for ($i=0; $i < 100; $i++)
{
    $iLen = strlen($i);
    for ($j=0; $j < $iLen; $j++)
    {
        ncurses_delch();
    }
    ncurses_addstr($i);
    ncurses_refresh();
    sleep(2);
}
ncurses_end();

?>

Currently when I run it, it outputs like this: Number: 01234[...]

Anyone see where my problem is and how I can fix it?

Rob
  • 7,980
  • 30
  • 75
  • 115

1 Answers1

2

ncurses_delch() forward-deletes. If you want to move the cusor back one column then output \b instead.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • is there an integer value for that? – Rob Nov 23 '10 at 20:02
  • Thanks, it works perfectly. Except now it brings up a new problem. But I'll ask that in a new question if i can't solve it. Thanks again – Rob Nov 23 '10 at 20:11
  • Just to let you know, my other problem, I managed to solve. Thanks again – Rob Nov 23 '10 at 22:07