7 Replies - 701 Views - Last Post: 20 April 2013 - 07:50 AM Rate Topic: -----

#1 lukeme99  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 15-March 11

How To Get Width Of Console?

Posted 18 April 2013 - 12:30 PM

Hi! I am making a text based UI that runs inside console. So far it works by having 2 2D arrays, one that holds the "Objects" (letters) and one that transposes the data from the first array to show up on screen (I like to call it the renderer :P). It would be much more efficient if I could check the buffer width of the window rather than assume that it is default 80. How would I go about doing this? (Would it work cross platform? I may be a mac lover but OSX works in mysterious ways!)

Is This A Good Question/Topic? 0
  • +

Replies To: How To Get Width Of Console?

#2 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 651
  • View blog
  • Posts: 2,225
  • Joined: 31-December 10

Re: How To Get Width Of Console?

Posted 18 April 2013 - 01:47 PM

More than likely it won't be cross-platform. Does it matter that the game is in the console? Or could you use a library/framework, something simple like SFML?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3468
  • View blog
  • Posts: 10,688
  • Joined: 05-May 12

Re: How To Get Width Of Console?

Posted 18 April 2013 - 07:56 PM

For text based, I've been told that the curses library is cross platform. I've only had a chance to try in on the old Wyse 52's and I forget which colored terminal. Both worked way back when.
Was This Post Helpful? 0
  • +
  • -

#4 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 651
  • View blog
  • Posts: 2,225
  • Joined: 31-December 10

Re: How To Get Width Of Console?

Posted 19 April 2013 - 02:15 PM

View PostSkydiver, on 18 April 2013 - 10:56 PM, said:

For text based, I've been told that the curses library is cross platform. I've only had a chance to try in on the old Wyse 52's and I forget which colored terminal. Both worked way back when.

ncurses might be a better choice.
Was This Post Helpful? 0
  • +
  • -

#5 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1311
  • View blog
  • Posts: 4,503
  • Joined: 19-February 09

Re: How To Get Width Of Console?

Posted 19 April 2013 - 06:24 PM

You could throw it to the user. Have a default of 80, and to change it have a config file or use an environment variable.
Was This Post Helpful? 0
  • +
  • -

#6 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,179
  • Joined: 21-June 11

Re: How To Get Width Of Console?

Posted 20 April 2013 - 03:16 AM

View Post#define, on 20 April 2013 - 03:24 AM, said:

You could throw it to the user. Have a default of 80, and to change it have a config file or use an environment variable.


Speaking as someone who uses a few command line applications, I would not take any application that did that seriously.
Was This Post Helpful? 0
  • +
  • -

#7 lukeme99  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 15-March 11

Re: How To Get Width Of Console?

Posted 20 April 2013 - 03:20 AM

View Post#define, on 20 April 2013 - 02:24 AM, said:

You could throw it to the user. Have a default of 80, and to change it have a config file or use an environment variable.


Ahh! Good idea, thanks!
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3468
  • View blog
  • Posts: 10,688
  • Joined: 05-May 12

Re: How To Get Width Of Console?

Posted 20 April 2013 - 07:50 AM

View Postsepp2k, on 20 April 2013 - 06:16 AM, said:

View Post#define, on 20 April 2013 - 03:24 AM, said:

You could throw it to the user. Have a default of 80, and to change it have a config file or use an environment variable.


Speaking as someone who uses a few command line applications, I would not take any application that did that seriously.


As I recall, back in the late 80's, when I was installing SCO Unix and AIX, after I popped in their floppy disks, the first thing they asked for was the width of the console. Perhaps that's why we don't hear too much about those versions anymore. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1