

HOW TO CENTER TEXT IN WORD AT THE CENTER OF THE PAGE HOW TO
This will be an exercise in learning how to utilize a new library into your programs and should be exciting.

There is a library called JavaCurses on source forge that provides this capability to java programs. On with the answerĪny how, so you can use one of these libraries in java to determine whether or not you are working on a proper terminal. On VMS I believe the library is called SMG$ (screen management library). One of the most popular versions of this library is the GNU curses library (previously known as ncurses). The second library is called curses, circa 1985 (?) it was developed as part of the BSD system and was used to write games. It could tell a running program of the available capabilities of the terminal (for example the ability to change text color) or to position cursor at a location, or to clear itself etc, and the program would then modify its behavior accordingly. The first one is called termcap (terminal-capabilities) library, circa 1978, which provided a generic way to deal with terminals on UNIX systems. So the necessity to make that simple caused a couple of abstraction libraries to developed that would hide away the hideousness. If you wrote a program specific to one it would make no sense elsewhere. ctrl-l is clear screen on ansi and vt terminals, but it may be page feed on something else. However this was done using "control" characters. These terminals could do positioning of cursors and windowing and colors, highlight text, underline etc. There were a bunch of terminal standards vt100, vt200, vt220, ansi, that came about at various points in terminal development history and hundreds of proprietary ones along the way. These teletype terminals were developed to solve lots of problems like being able to display content remotely from mainframes and minicomputers. Teletype terminals were complicated things and come from the legacy that there were a lots of terminal manufacturers (IBM, DEC, etc.). Teletype terminals of the old can do a lot of fun things. What you are asking for is the ability to treat the console as a smart teletype (tty) terminal with character-based control capabilities. So question is how do you get all this information? For example if you are not does it make sense to "prettify" your code? probably not. Once you've written a program such that you can give it any string that will display properly on those assumptions (that terminal is 80 characters wide) you can now start worrying about what happens if you are connected to a terminal which is more or less than 80 characters? Or whether or not you are even connected to a terminal. How would you center a string on an 80 character wide terminal screen?ĭo you need to worry about the length of the string? How do you position something horizontally? Do you add spaces? Is there a format string you can come up with? So as a first step start with the assumption that it's 80 characters wide. So some hints for you:įirst question is, how wide is the terminal? (it's counted in number of characters) old terminals had a fixed dimensions of 80 characters and 25 lines It is a newbie question :) but it's a valid question. Read below it's in there.īefore you do though let's answer your entire question in some context You can use the JavaCurses library to do fun things on the console.
