source: trunk/include/helpers/ansiscrn.h@ 18

Last change on this file since 18 was 7, checked in by umoeller, 25 years ago

Initial checkin of helpers code, which used to be in WarpIN.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/* $Id: ansiscrn.h 7 2000-10-27 21:27:02Z umoeller $ */
2
3
4/*
5 *@@sourcefile ansiscrn.h:
6 * quick ANSI screen code macros for use with printf().
7 * This file does not correspond to any .C code file.
8 *
9 * Usage: Any C code on platforms which support ANSI
10 * escape sequences.
11 *
12 * Based on ANSISCRN.H, which was
13 * contributed to the public domain 12-26-91 by
14 * Matthew J. Glass.
15 *
16 * Note: Version numbering in this file relates to XWorkplace version
17 * numbering.
18 */
19
20#ifndef ANSISCRN_INCLUDED
21#define ANSISCRN_INCLUDED
22
23#include <stdio.h>
24
25#define ESC 27
26#define ANSI_cup(a,b) printf("%c[%d;%dH",ESC,a,b)
27#define ANSI_up(a) printf("%c[%dA",ESC,a)
28#define ANSI_down(a) printf("%c[%dB",ESC,a)
29#define ANSI_right(a) printf("%c[%dC",ESC,a)
30#define ANSI_left(a) printf("%c[%dD",ESC,a)
31#define ANSI_locate(a,b) printf("%c[%d;%df",ESC,a,b)
32#define ANSI_savecurs() printf("%c[S",ESC)
33#define ANSI_restcurs() printf("%c[U",ESC)
34#define ANSI_cls() printf("%c[2J",ESC)
35#define ANSI_cleol() printf("%c[K",ESC)
36#define ANSI_margins(a,b) printf("%c[%d;%dr",ESC,a,b)
37
38#define NORMAL 0 /* attributes for ANSI_attrib() */
39#define BOLD 1
40#define USCORE 2
41#define BLINK 3
42#define REVERSE 4
43#define INVIS 5
44
45#define BLACK 0 /* colors for ANSI_bg_color() and */
46#define RED 1 /* ANSI_fg_color. */
47#define GREEN 2
48#define YELLOW 3
49#define BLUE 4
50#define MAGENTA 5
51#define CYAN 6
52#define WHITE 7
53#define B_BLACK 8 /* bright colors for ANSI_fg_color() */
54#define B_RED 9
55#define B_GREEN 10
56#define B_YELLOW 11
57#define B_BLUE 12
58#define B_MAGENTA 13
59#define B_CYAN 14
60#define B_WHITE 15
61
62static char *_atrb_plt[] = {
63 "0","1","4","5","7","8"
64 };
65
66static char *_fg_plt[] = {
67 "0;30","0;31","0;32","0;33",
68 "0;34","0;35","0;36","0;37",
69 "1;30","1;31","1;32","1;33",
70 "1;34","1;35","1;36","1;37"
71 };
72
73static char *_bg_plt[] = {
74 "40","41","42","43",
75 "44","45","46","47"
76 };
77
78#define ANSI_attrib(a) printf("%c[%sm",ESC,_atrb_plt[a])
79#define ANSI_fg_color(a) printf("%c[%sm",ESC, _fg_plt[a] )
80#define ANSI_bg_color(a) printf("%c[%sm",ESC, _bg_plt[a] )
81
82#endif /* ANSISCRN */
Note: See TracBrowser for help on using the repository browser.