View Single Post
Old Feb 18th, 2008, 9:15 PM   #8
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: determing whitespace to center text

Quote:
Originally Posted by malavar View Post
hey thanks for the reply, im using linux, i was hoping that there was a function in the standard library that comes with C++. its a pretty simple concept, and it is a console based application. sorry i didnt give enough information in the first place. i have a simple algorithm that centers it, but its based on a fixed width, i.e running it in a tty terminal it will be centered, but when running it in a gui based terminal i.e gnome terminal or kterm, it will not be centered.
Quote:
Originally Posted by Game_Ender View Post
He is a linux user talking about "consoles". Which means he writing a terminal program. If you are writing a terminal program and wish to make a decent text bested interface, using something like ncurses is the way to go. This is the same thing I would say to someone on windows trying to slog it out with the Win32 API. I would tell them to go use something like QT or wxWidgets. Somebodies already done the work take advantage of it.
You are quite right about linux, but his problem is with centering while using a GUI based terminal it is broken. My experience with linux GUI is X11R6 and Motief. I know QT is a better solution for students, and there are probably others too that I'm not aware of. Whatever the tools used the solution is probably the same -- getting the width of the terminal in pixels and the width in pixels of the text to be centered. There must be functions in the gui tools to get that information, but I don'w know that those functions are.
Ancient Dragon is offline   Reply With Quote