tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: curses vs non-ASCII



> I'm going to take the misbehaving test program, the one I posted
> earlier, and add a bunch of move()/inch() pairs (there seems to be no
> mvinch, oddly) to see what curses thinks is supposed to be displayed.

Okay, the updated program is below.

The text on the interesting line, according to inch() and assuming
_its_ display is trustworthy, alternates between b7 20 41 62 62 61 3a
20 54 68... (when it's displayed with one space before it) and 41 62 62
61 3a 20 54 68 61 6e... (when it's displayed right up against the left
margin).  (The use of r to just refresh() without a replot() was me
wondering if that would affect anything.  It doesn't; I've never seen r
produce a visible change.)

In view of how the replot() is coded, I have trouble seeing this as
_not_ being a curses bug.  Possibly two bugs, even.  One, it appears
that the string is sometimes making it to stdscr's internal text
storage unmangled, but is getting damaged somewhere between there and
display.  Two, it appears that what gets written into stdscr's internal
text structure when that string is displayed depends on what's already
there, or some such.

I'll probably be looking into this more at some point, but it's looking
like way too much of a timesink for me to deal with it before this
evening at the very earliest.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

#include <curses.h>

static void replot(void)
{
 move(0,0);
 addstr("  54-40: Trusted By Millions");
 move(1,0);
 addstr("  Abba: Abba");
 move(2,0);
 addstr("  Abba: Abba Live");
 move(3,0);
 addstr("  Abba: Thank You For The Music (Disc 1)");
 move(4,0);
 addstr("  Abba: Thank You For The Music (Disc 2)");
 move(5,0);
 addstr("\267 Abba: Thank You For The Music (Disc 3)");
 move(6,0);
 addstr("  Abba: Thank You For The Music (Disc 4)");
 move(7,0);
 addstr("  Abba: Voulez-Vous");
 move(8,0);
 addstr("  Ace Of Base: Best Of");
 move(LINES-1,COLS-1);
}

static void probe(void)
{
 int l;
 int i;
 int c;

 for (l=4;l<=6;l++)
  { for (i=0;i<10;i++)
     { move(l,i);
       c = inch();
       move(l+7,6*i);
       printw("%-6x",c);
     }
    move(l+7,60);
    clrtoeol();
  }
}

int main(void)
{
 initscr();
 noecho();
 cbreak();
 clearok(stdscr,TRUE);
 replot();
 refresh();
 while (1)
  { switch (getch())
     { case '.':
	  endwin();
	  return(0);
	  break;
       case 'p':
	  probe();
	  refresh();
	  break;
       case 'r':
	  refresh();
	  break;
       case ' ':
	  replot();
	  refresh();
	  break;
     }
  }
}


Home | Main Index | Thread Index | Old Index