Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Center curses output

by mhearse (Hermit)
on Jul 04, 2013 at 05:58 UTC ( #1042331=perlquestion: print w/ replies, xml ) Need Help??
mhearse has asked for the wisdom of the Perl Monks concerning the following question:

I have a curses app which is designed to run on a standard 80x25 console. By that I mean the output has a width of 80 characters and a height of 25 characters. When running this app in a terminal emulator I'm trying to figure out how to center my output. Can someone help me figure out how to calculate the beginning x,y coordinates?

Comment on Center curses output
Re: Center curses output
by hdb (Parson) on Jul 04, 2013 at 06:27 UTC

    Is this a Perl question? In order to get a useful answer you probably have to provide some details about your app.

    If your question is simply: on a screen of width $w and height $h and a centered window of 80x25, how wide is my left and top margin (or bottom?), the following should be helpful:

    $left = ($w - 80) / 2; $top = ($h - 25) / 2;

    which both might be negative on a small screen.

      Hi hdb,
      ..which both might be negative on a small screen...

      easy maths?! Huh!!!
      I remembered my programming days with V.B 6.0.. Nice one bro..
      Update:
      hdb, am not undermining your point, am only emphasizing it...

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

        As I said, for a useful answer, more details might be needed...



Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1042331]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-08-23 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (171 votes), past polls