Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ncurses on gnome-terminal

35 views
Skip to first unread message

Harold

unread,
Jul 21, 2009, 5:23:22 PM7/21/09
to
It seems that ncurses occasionally displays bad data on my terminal.
The following test program should display a single fixed digit at each
location of stdscr, but the data actually displayed is randomly wrong.

I'm using gnome-terminal 2.7.3, and libncurses 5.4. These came with
CentOS 4.4
I looked for related bugs in both projects without success. Any help
would be appreciated.

Thanks!
Harold

------------- snip ------------------

#include <ncurses.h>
#include <stdlib.h>

int main (void) {
initscr (); // initialize curses

for (;;) {
int top, left;
top = rand() % 24;
left = rand() % 70; // pick a random location on the
screen

mvprintw (top, left, "%d", (top + left) % 10); // display
LS digit of (top+left)
refresh (); // update display
}
}

Thomas Dickey

unread,
Jul 21, 2009, 8:41:57 PM7/21/09
to
On Jul 21, 5:23 pm, Harold <hzrab...@gmail.com> wrote:
> It seems thatncursesoccasionally displays bad data on my terminal.

> The following test program should display a single fixed digit at each
> location of stdscr, but the data actually displayed is randomly wrong.
>
> I'm using gnome-terminal 2.7.3, and libncurses 5.4.  These came with
> CentOS 4.4
> I looked for related bugs in both projects without success. Any help
> would be appreciated.

just running it, I don't see any problems (with gnome-terminal 2.24.3
and ncurses 5.7). On the other hand, I don't recall any relevant bug
in ncurses, and gnome-terminal has at least one visible bug in every
release. (If you cannot reproduce the problem with xterm, it's just
another gnome-terminal bug).

Spiros Bousbouras

unread,
Jul 26, 2009, 8:43:33 PM7/26/09
to

If the dimensions of the window are 24 x 70 then eventually all
positions will be filled but not with a fixed digit since the
expression (top + left) % 10 is not fixed but changes
(pseudo)randomly.

Thomas Dickey

unread,
Jul 30, 2009, 7:18:50 PM7/30/09
to
On Jul 26, 8:43 pm, Spiros Bousbouras <spi...@gmail.com> wrote:
> On 21 July, 22:23, Harold <hzrab...@gmail.com> wrote:

> >         mvprintw (top, left, "%d", (top + left) % 10);      // display

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> If the dimensions of the window are 24 x 70 then eventually all
> positions will be filled but not with a fixed digit since the
> expression    (top + left) % 10    is not fixed but changes
> (pseudo)randomly.

no - the digit printed at a given location is constant, because it is
always
a (nonrandom) function of the location's coordinates.

If the screensize were smaller than 24x70, the result would be
(reasonably) unpredictable. OP did not mention this; we're assuming
it is at least 24x70.

Spiros Bousbouras

unread,
Aug 8, 2009, 2:54:59 PM8/8/09
to
On 31 July, 00:18, Thomas Dickey <dic...@his.com> wrote:
> On Jul 26, 8:43 pm, Spiros Bousbouras <spi...@gmail.com> wrote:
>
> > On 21 July, 22:23, Harold <hzrab...@gmail.com> wrote:
> > > mvprintw (top, left, "%d", (top + left) % 10); // display
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> > If the dimensions of the window are 24 x 70 then eventually all
> > positions will be filled but not with a fixed digit since the
> > expression (top + left) % 10 is not fixed but changes
> > (pseudo)randomly.
>
> no - the digit printed at a given location is constant, because it is
> always
> a (nonrandom) function of the location's coordinates.

I took the phrase "a single fixed digit at each location of stdscr"
in the opening post to mean the same digit in every position but
perhaps your interpretation is what the opening poster meant.

> If the screensize were smaller than 24x70, the result would be
> (reasonably) unpredictable. OP did not mention this; we're assuming
> it is at least 24x70.

I wasn't assuming anything. If the dimensions of the screen are
smaller than 24x70 that might explain why he's not getting what he
expects. Are the curses cursor positioning functions meant to do
anything predictable when they receive position arguments beyond the
screen boundaries or does the final outcome depend on how the
terminal (emulator) reacts when receiving illegal coordinates ?

--
Who's your mama ?

0 new messages