Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / monitor / display.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2011-2014  Intel Corporation
6  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License as published by the Free Software Foundation; either
12  *  version 2.1 of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #include <stdbool.h>
26
27 bool use_color(void);
28
29 #define COLOR_OFF       "\x1B[0m"
30 #define COLOR_BLACK     "\x1B[0;30m"
31 #define COLOR_RED       "\x1B[0;31m"
32 #define COLOR_GREEN     "\x1B[0;32m"
33 #define COLOR_YELLOW    "\x1B[0;33m"
34 #define COLOR_BLUE      "\x1B[0;34m"
35 #define COLOR_MAGENTA   "\x1B[0;35m"
36 #define COLOR_CYAN      "\x1B[0;36m"
37 #define COLOR_WHITE     "\x1B[0;37m"
38 #define COLOR_WHITE_BG  "\x1B[0;47;30m"
39 #define COLOR_HIGHLIGHT "\x1B[1;39m"
40
41 #define COLOR_ERROR     "\x1B[1;31m"
42 #define COLOR_WARN      "\x1B[1m"
43 #define COLOR_INFO      COLOR_OFF
44 #define COLOR_DEBUG     COLOR_WHITE
45
46 #define FALLBACK_TERMINAL_WIDTH 80
47
48 #define print_indent(indent, color1, prefix, title, color2, fmt, args...) \
49 do { \
50         printf("%*c%s%s%s%s" fmt "%s\n", (indent), ' ', \
51                 use_color() ? (color1) : "", prefix, title, \
52                 use_color() ? (color2) : "", ## args, \
53                 use_color() ? COLOR_OFF : ""); \
54 } while (0)
55
56 #define print_text(color, fmt, args...) \
57                 print_indent(8, COLOR_OFF, "", "", color, fmt, ## args)
58
59 #define print_field(fmt, args...) \
60                 print_indent(8, COLOR_OFF, "", "", COLOR_OFF, fmt, ## args)
61
62 int num_columns(void);
63
64 void open_pager(void);
65 void close_pager(void);