This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Needing basic info on print position control
- From: Stuart Longland <stuartl at longlandclan dot hopto dot org>
- To: Andrew Lietzow <andrewl at theaclgroup dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 17 Mar 2003 00:14:15 +1000
- Subject: Re: Needing basic info on print position control
- References: <200303161401.h2GE1dI08339@ss.hostahaven.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrew Lietzow wrote:
> Dear List,
>
> Newbie looking for info on print position and screen position control. I
> want the system to display something to an exact location on the
screen, or
> on a printer.
>
> With Business Basic, one says something like:
> print @(20,15) -- for screen control
> and
> print @(20) for position control within the current line -- for print
control
>
For console (screen) under UNIX, most consoles here understand ANSI
escape sequences. For example:
^[[r;cH will position your cursor on row r, column C. The r;c may be
ommitted, in which case, it will place the cursor at the top right hand
corner (row 1, column 1).
You also have relative controls in ANSI:
^[[xA Up x rows
^[[xB Down x rows
^[[xC Right x columns
^[[xD Left x columns
If x is ommitted, it's assumed to be 1.
With the above examples, remember to replace ^[ with the ESCAPE
character (ASCII Character 27), so in a printf statement, to go to the
8th row, 20th column, use the following:
printf("\033[8;20Hwhatever text goes here");
Or with your example:
printf("\033[15;20H");
As for the printer, I think you'll find the backspace (^H) and space
are your friends. ^H will go back a space, single space will go forward
a space.
So in your example, make sure there's 15 spaces before your desired
text, like this:
printf(" Text starts here");
Then, say, to go back to column 5, do this: (^H = character 8 or \010)
printf("\010\010\010\010\010New text starts here");
There are probably more efficient ways of doing this, this is what I know.
- --
+-------------------------------------------------------------+
| Stuart Longland stuartl at longlandclan.hopto.org |
| Brisbane Mesh Node: 719 http://stuartl.cjb.net/ |
| I haven't lost my mind - it's backed up on a tape somewhere |
| Griffith Student No: Course: Bachelor/IT @ Nathan |
+-------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1-nr1 (Windows 2000)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+dIa3IGJk7gLSDPcRAkdhAJ4q/QkF1zgEsAbsLf2C/Bd7upvPbwCeJjVp
TOWKt3INBW7A8dslVtj+jIE=
=rAbE
-----END PGP SIGNATURE-----