Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uwm.edu!rpi!sci.ccny.cuny.edu!phri!marob!daveh From: daveh@marob.masa.com (Dave Hammond) Newsgroups: comp.lang.c Subject: Re: Question about curses Keywords: curses Message-ID: <25B219F5.1C06@marob.masa.com> Date: 15 Jan 90 18:44:03 GMT References: <1498@skye.ed.ac.uk> <599@xdos.UUCP> <1473@mdbs.UUCP> <417@quad.uucp> <1911@ultb.isc.rit.edu> Reply-To: daveh@marob.masa.com (Dave Hammond) Organization: ESCC, New York City Lines: 55 In article <1911@ultb.isc.rit.edu> (J.S. Veiss) writes: > >I'm trying to print graphics characters from the alternate character set >and another character set I created in a program using the curses library. >I'm using standard ANSI escape codes to access the character sets. >I've gotten things down to be the only way the print the escape codes to >change the character set is to print it to stdout instead of stdscr. >[...] >PrintCard (row, col) >int row, col; >{ > move (row, col + 3); > printw ("%d", col / 10); > move (++row, col); > printf ("%slqqqqqk%s", GRPH, ASCII); > refresh (); >} Curses has no idea that "%slqqqqqk%s" is on screen, so it will unwittingly overwrite portions of the box rule with spaces, whenever it determines that the surrounding display area must be refreshed. You generally can not intermix direct display output with curses output, because (1) curses has no idea what you are placing on screen, and (2) curses buffers output until a refresh(), making it difficult to coordinate direct output with curses output. The only way to ensure that your direct output survives is to re-output ALL direct output after EACH refresh(). The coordination effort can be minimized by only refreshing immediately prior to reading user input events. If you only have a single event processing loop, then this becomes fairly easy. Of course, there is still the overhead imposed by redrawing every box rule, before every input event. As a point of information, newer curses implementations may support the terminfo A_ALTCHARSET attribute, which will switch in and out of the display's alternate character set. Basically, you would code the above as: PrintCard (row, col) int row, col; { move (row, col + 3); printw ("%d", col / 10); move (++row, col); attron(A_ALTCHARSET); addstr("lqqqqqk"); attroff(A_ALTCHARSET); refresh (); } However, it should be noted that this option is highly unportable. -- Dave Hammond daveh@marob.masa.com uunet!masa.com!marob!daveh