Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Abusing `curses' WINDOW structure Message-ID: <7565@sun.uucp> Date: Wed, 24-Sep-86 02:42:28 EDT Article-I.D.: sun.7565 Posted: Wed Sep 24 02:42:28 1986 Date-Received: Wed, 24-Sep-86 22:00:40 EDT References: <314@bty.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 30 > I'm writing a program which uses the curses library, and need to > include a "print screen" type of utility. Rather than reproducing > my display logic in order to print a text file image, I was thinking > of simply copying the screen from stdscr->_y directly into my textfile > (adding newlines where appropriate). ... > Now, my machine uses termcap, and this seems to work OK. The question > is, is the WINDOW structure different in the terminfo implementation? > And if so, can the routine above be rewritten and made to work? "Abusing" is right! Assuming you "know" what an unadvertised data structure of a package looks like is a great way to get into trouble. Yes, the window structure is different, although that sort of thing will sort of work. Don't do it, though. There is a macro "winch" that returns the "character" at the current position on the screen. Use that instead. "character" is in quotes, because it masks out the character attributes in the 4BSD "curses" but not the S5 "curses". You should mask the result of that operation with 0177 if you just want the character. (Note that your sample code would not work properly for characters in standout mode; the raw data in the screen buffer has high bits set if the character has an attribute turned on.) This stuff is documented both in the 4.2BSD and the S5 "curses" documentation. Please, people, before you decide you have no choice but to sneak around the back door of a facility, check out the documentation - in painful detail, if need be - first! -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)