🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #13213

Re: How do I find the size of the screen?

#13213
From: Chuck McManis
Date: Thu, 28 Dec 1989 20:32
45 lines
2798 bytes
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?!"
Technical Details
Message-ID: <129683@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!sun-barr!newstop!sun!stpeter!cmcmanis
References: <0983.AA0983@noel>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!sun-barr!newstop!sun!stpeter!cmcmanis
From: cmcmanis@stpeter.Sun.COM (Chuck McManis)
Newsgroups: comp.sys.amiga.tech
Subject: Re: How do I find the size of the screen?
Message-ID: <129683@sun.Eng.Sun.COM>
Date: 28 Dec 89 20:32:46 GMT
References: <0983.AA0983@noel>
Sender: news@sun.Eng.Sun.COM
Reply-To: cmcmanis@sun.UUCP (Chuck McManis)
Organization: Sun Microsystems, Mountain View
Lines: 45