greg@noel.CTS.COM (J. Gregory Noel) (12/27/89)
I'm sure that this is someplace obvious in TFM, but I've hunted and hunted and I can't find it..... I would like to be able to determine the size of the current window (the window attached to my program's stdout, to be precise) and the size of the current font. The idea is to convert this to the number of rows and columns that I can place on the screen. It needs to work correctly whether the window has borders or not. I know it's possible to do as the "vi" clone that comes with Aztec C can do it, and I can't believe that it's \that/ hard to do. Obviously, my environment is Aztec C, but an answer that works with the Lattice compiler should be similar enough. Many thanks, J. Gregory Noel, UNIX Guru greg@noel.cts.com or greg@noel.uucp
cmcmanis@stpeter.Sun.COM (Chuck McManis) (12/29/89)
In article <0983.AA0983@noel> greg@noel.CTS.COM (J. Gregory Noel) writes: >I'm sure that this is someplace obvious in TFM, but I've hunted and hunted and >I can't find it..... Not exactly, but probably in the new ones. >I would like to be able to determine the size of the current window (the window >attached to my program's stdout, to be precise) and the size of the current >font. The idea is to convert this to the number of rows and columns that I can >place on the screen. It needs to work correctly whether the window has borders >or not. I know it's possible to do as the "vi" clone that comes with Aztec C >can do it, and I can't believe that it's \that/ hard to do. Ok the short answer for the cognoscenti is : Send an ACTION_INFO packet to the console handler and get the data from the result. There was an example of this in AmigaMail (and it's on a fish disk or two) that Carolyn wrote that sends packets to handlers, the con handler in particular. The name of the example was ConsPackets.c (I don't seem to have a copy on line). There are two reasons why you will want to do this. The first is that you can get the current window info, and the other is that you use packets to set the console into and out of RAW mode. In pictorial form you sort of have this : +-------------------------+ +---------+ +---------+ +-----------+ | : | | Console | | Console | | | | Application : Stdio Lib +->+ Handler +->+ device +->+ Intuition | | : | | (CON:) | | | | | +-------------------------+ +---------+ +---------+ +-----------+ Anyway, once you get the window information from the console.device (via the console handler) you can look at Window->RPort->TxWidth (Text Width, NOT USEFUL FOR PROPORTIONAL TEXT) Window->RPort->TxHeight (Text Height) Window->BorderTop (Subtract these from Window->Width and ) ...->BorderBottom (Window->Height to get rendering area ) ...->BorderLeft ...->BorderRight --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@Eng.Sun.COM These opinions are my own and no one elses, but you knew that didn't you. "If it didn't have bones in it, it wouldn't be crunchy now would it?!"
caw@jolnet.ORPK.IL.US (Chris Wichura) (12/29/89)
The way you find out this info is to query the console device attached to your window. Get a copy of the source to LS3.1 and you will find (in assembly) a routine to return both the total number of rows and columns available in the current window. -- Christopher A. Wichura u12401 @ uicvm.uic.edu (my home account) caw @ jolnet.UUCP (my Usenet feed)
duncant@mbunix.mitre.org (Thomson) (01/09/90)
If i remember correctly, if you set the console handler into RAW mode (which you do by sending a IO request to the handler) you can then just write a certain ANSI sequence to the handler (by just doing a printf) the console will (since it acts like an ANSI terminal) send back a text string which tells you the width and height (in characters) of the console. I have code which does all this, but I don't have it with me now on this machine. Let me know if you really want it and I can send it to you.. (although I have problems with file transfers - but I can give it a try if you want.) Duncan Thomson