diff options
author | Alex Deymo <deymo@chromium.org> | 2013-03-21 15:04:52 -0700 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-03-25 12:54:48 +0200 |
commit | 82e49df634e38283b714a06d7a07d94f1f40a802 (patch) | |
tree | 816275c05e77a8c9304b1291229e15feb6224907 /client/main.c | |
parent | f037e82669982c2277fb90ccc5f6812dae993ee9 (diff) | |
download | bluez-82e49df634e38283b714a06d7a07d94f1f40a802.tar.gz |
client: Right prompt management on agent input
Registering an agent shares the user input interface with the normal console
command interface. The way it is implemented (using rl_message, rl_save_prompt
and rl_restore_prompt) conflicts with the rl_printf calls that may appear
while waiting for user input, loosing the [bluetooth]# prompt.
This patch fixes this and makes clear if the expected input is a command or an
agent reply changing the color and text of the prompt.
Diffstat (limited to 'client/main.c')
-rw-r--r-- | client/main.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/client/main.c b/client/main.c index d8547c0f1..704cf4676 100644 --- a/client/main.c +++ b/client/main.c @@ -46,6 +46,9 @@ #define COLORED_CHG COLOR_YELLOW "CHG" COLOR_OFF #define COLORED_DEL COLOR_RED "DEL" COLOR_OFF +#define PROMPT_ON COLOR_BLUE "[bluetooth]" COLOR_OFF "# " +#define PROMPT_OFF "[bluetooth]# " + static GMainLoop *main_loop; static DBusConnection *dbus_conn; @@ -63,7 +66,7 @@ static void proxy_leak(gpointer data) static void connect_handler(DBusConnection *connection, void *user_data) { - rl_set_prompt(COLOR_BLUE "[bluetooth]" COLOR_OFF "# "); + rl_set_prompt(PROMPT_ON); printf("\r"); rl_on_new_line(); rl_redisplay(); @@ -71,7 +74,7 @@ static void connect_handler(DBusConnection *connection, void *user_data) static void disconnect_handler(DBusConnection *connection, void *user_data) { - rl_set_prompt("[bluetooth]# "); + rl_set_prompt(PROMPT_OFF); printf("\r"); rl_on_new_line(); rl_redisplay(); @@ -1283,11 +1286,11 @@ int main(int argc, char *argv[]) rl_erase_empty_line = 1; rl_callback_handler_install(NULL, rl_handler); - rl_set_prompt("[bluetooth]# "); + rl_set_prompt(PROMPT_OFF); rl_redisplay(); - input = setup_standard_input(); - signal = setup_signalfd(); + input = setup_standard_input(); + signal = setup_signalfd(); client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez"); g_dbus_client_set_connect_watch(client, connect_handler, NULL); |