Unix Routines

Andreas Hoepfner hoepfner at usun01.UUCP
Wed Jan 16 01:04:25 AEST 1991


In <26284 at uflorida.cis.ufl.EDU> pm0 at springs.cis.ufl.edu (Patrick Martin) writes:

>Could someone tell me how to do the following on a Unix System:

>Up() {will move the Cursor up 1 position}
>Down() { ... down ...}
>Left() { ... left ...}
>Right() { ... right ...}

>PS:  I know I could use a system call to clear the screen but
>I would prefer sending the direct ascii code to a printf
>statement.

Normaly, to do this on all possible terminal types, you should use
the curses library.

This is an easy way for vtxxx Terminals :

#define up()      printf("%cA",0x1b)
#define down()    printf("%cB",0x1b)
#define right()   printf("%cC",0x1b)
#define left()    printf("%cD",0x1b)
#define home()    printf("%cH",0x1b)
#define CLS     printf("\033[2J\033[H")
#define setcur(a,b) printf("\033[%d;%dH",a,b)
#define BELL    printf("%c",0x07)

 :-) Andreas


 +-----------------------------------------------------------------------+
 |                   Andreas Hoepfner                                    |
 |                                                                       |
 |     paper mail:                            e-mail:                    |
 | Siemens Nixdorf Informations                                          |
 | Systeme                        USA:  hoepfner.kd at nixdorf.com          |
 | Abt. PU 2222                   !USA: hoepfner.kd at nixdorf.de           |
 | Heinz Nixdorf Ring                                                    |
 | D-4790 Paderborn                                                      |
 | tel.: (+49) 5251 10-7479                                              |
 +-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list