summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAlex Deymo <deymo@chromium.org>2013-03-21 15:04:51 -0700
committerJohan Hedberg <johan.hedberg@intel.com>2013-03-25 12:53:48 +0200
commitf037e82669982c2277fb90ccc5f6812dae993ee9 (patch)
tree0da3b3eb7641c40e18560cb0fd0d83256ee35d7d /client
parent4f7b4fd3214f2a6e55d41c9052aa061b0dd647fe (diff)
client: Add color modifiers to NEW, CHG and DEL events.
Events like [NEW], [CHG] and [DEL] can appear in the command console at any time, even when the user is typing a command. The last line is kept making the event line appear just before it, something that can be unnoticed. This patch add meaningful colors for those three event to make it easier to see them.
Diffstat (limited to 'client')
-rw-r--r--client/display.h3
-rw-r--r--client/main.c20
2 files changed, 16 insertions, 7 deletions
diff --git a/client/display.h b/client/display.h
index 393a3c8cc..9cb891aad 100644
--- a/client/display.h
+++ b/client/display.h
@@ -22,6 +22,9 @@
*/
#define COLOR_OFF "\x1B[0m"
+#define COLOR_RED "\x1B[0;91m"
+#define COLOR_GREEN "\x1B[0;92m"
+#define COLOR_YELLOW "\x1B[0;93m"
#define COLOR_BLUE "\x1B[0;34m"
void rl_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
diff --git a/client/main.c b/client/main.c
index 9a927a893..d8547c0f1 100644
--- a/client/main.c
+++ b/client/main.c
@@ -41,6 +41,11 @@
#include "agent.h"
#include "display.h"
+/* String display constants */
+#define COLORED_NEW COLOR_GREEN "NEW" COLOR_OFF
+#define COLORED_CHG COLOR_YELLOW "CHG" COLOR_OFF
+#define COLORED_DEL COLOR_RED "DEL" COLOR_OFF
+
static GMainLoop *main_loop;
static DBusConnection *dbus_conn;
@@ -252,7 +257,7 @@ static void proxy_added(GDBusProxy *proxy, void *user_data)
if (device_is_child(proxy, default_ctrl) == TRUE) {
dev_list = g_list_append(dev_list, proxy);
- print_device(proxy, "NEW");
+ print_device(proxy, COLORED_NEW);
}
} else if (!strcmp(interface, "org.bluez.Adapter1")) {
ctrl_list = g_list_append(ctrl_list, proxy);
@@ -260,7 +265,7 @@ static void proxy_added(GDBusProxy *proxy, void *user_data)
if (!default_ctrl)
default_ctrl = proxy;
- print_adapter(proxy, "NEW");
+ print_adapter(proxy, COLORED_NEW);
} else if (!strcmp(interface, "org.bluez.AgentManager1")) {
if (!agent_manager) {
agent_manager = proxy;
@@ -282,12 +287,12 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data)
if (device_is_child(proxy, default_ctrl) == TRUE) {
dev_list = g_list_remove(dev_list, proxy);
- print_device(proxy, "DEL");
+ print_device(proxy, COLORED_DEL);
}
} else if (!strcmp(interface, "org.bluez.Adapter1")) {
ctrl_list = g_list_remove(ctrl_list, proxy);
- print_adapter(proxy, "DEL");
+ print_adapter(proxy, COLORED_DEL);
if (default_ctrl == proxy) {
default_ctrl = NULL;
@@ -319,8 +324,8 @@ static void property_changed(GDBusProxy *proxy, const char *name,
dbus_message_iter_get_basic(&addr_iter,
&address);
- str = g_strdup_printf("[CHG] Device %s ",
- address);
+ str = g_strdup_printf("[" COLORED_CHG
+ "] Device %s ", address);
} else
str = g_strdup("");
@@ -336,7 +341,8 @@ static void property_changed(GDBusProxy *proxy, const char *name,
const char *address;
dbus_message_iter_get_basic(&addr_iter, &address);
- str = g_strdup_printf("[CHG] Controller %s ", address);
+ str = g_strdup_printf("[" COLORED_CHG
+ "] Controller %s ", address);
} else
str = g_strdup("");