VLC 4.0.0-dev
ansi_term.h
Go to the documentation of this file.
1/*****************************************************************************
2 * ansi_term.h: Common declarations and helpers for ANSI terminal handling
3 *****************************************************************************
4 * Copyright (C) 1998-2011 VLC authors and VideoLAN
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#ifndef VLC_ANSI_TERM_H
22#define VLC_ANSI_TERM_H 1
23
24#ifdef HAVE_CONFIG_H
25# include "config.h"
26#endif
27
28#if !defined( _WIN32 )
29# include <termios.h>
30# include <sys/ioctl.h>
31#endif
32
33/* ANSI terminal control ("escape") sequences */
34
35/* Terminal control sequence construction */
36#define term_seq(x) "\033[" #x "m"
37
38/**
39 * Codes:
40 *
41 * Effects:
42 * - Normal: 0 (reset)
43 * - Bold: 1
44 * - Dim: 2
45 * - Italic: 3
46 * - Underline: 4
47 * - Reverse: 7
48 * - Invisible: 8
49 * - Strike: 9 (Strike-through)
50 *
51 * Color set 1:
52 * - Black: 30
53 * - Red 31
54 * - Green 32
55 * - Yellow: 33
56 * - Blue: 34
57 * - Magenta: 35
58 * - Cyan: 36
59 * - White: 37
60 *
61 * Color set 2:
62 * - Black: 90
63 * - Red: 91
64 * - Green: 92
65 * - Yellow: 93
66 * - Blue: 94
67 * - Magenta: 95
68 * - Cyan: 96
69 * - White: 97
70 *
71 * Text background color highlighting, set 1:
72 * - Black: 40
73 * - Red: 41
74 * - Green: 42
75 * - Yellow: 43
76 * - Blue: 44
77 * - Magenta: 45
78 * - Cyan: 46
79 * - White: 47
80 *
81 * Text background color highlighting, set 2:
82 * - Black: 100
83 * - Red: 101
84 * - Green: 102
85 * - Yellow: 103
86 * - Blue: 104
87 * - Magenta: 105
88 * - Cyan: 106
89 * - White: 107
90 */
91
92#define TS_RESET term_seq(0)
93
94#define TS_RESET_BOLD term_seq(0;1)
95
96#define TS_BOLD term_seq(1)
97#define TS_DIM term_seq(2)
98#define TS_ITALIC term_seq(3)
99#define TS_UNDERSCORE term_seq(4)
100#define TS_REVERSE term_seq(7)
101#define TS_INVISIBLE term_seq(8)
102#define TS_STRIKE term_seq(9)
103
104#define TS_BLACK term_seq(30)
105#define TS_RED term_seq(31)
106#define TS_GREEN term_seq(32)
107#define TS_YELLOW term_seq(33)
108#define TS_BLUE term_seq(34)
109#define TS_MAGENTA term_seq(35)
110#define TS_CYAN term_seq(36)
111#define TS_WHITE term_seq(37)
112
113#define TS_BLACK_BOLD term_seq(30;1)
114#define TS_RED_BOLD term_seq(31;1)
115#define TS_GREEN_BOLD term_seq(32;1)
116#define TS_YELLOW_BOLD term_seq(33;1)
117#define TS_BLUE_BOLD term_seq(34;1)
118#define TS_MAGENTA_BOLD term_seq(35;1)
119#define TS_CYAN_BOLD term_seq(36;1)
120#define TS_WHITE_BOLD term_seq(37;1)
121
122#endif