diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-12-18 04:17:45 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-18 04:17:45 +0100 |
commit | fc7ae83f91cc99b24143880293ca757f4024a62d (patch) | |
tree | 7671e53a0f173d4ff21b8024a4755828308b086f /client/display.c | |
parent | d9c65661475266d552a14b374a51e74b9a82579d (diff) | |
download | bluez-fc7ae83f91cc99b24143880293ca757f4024a62d.tar.gz |
client: Add helper function for readline async printing
Diffstat (limited to 'client/display.c')
-rw-r--r-- | client/display.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/client/display.c b/client/display.c new file mode 100644 index 000000000..197049d64 --- /dev/null +++ b/client/display.c @@ -0,0 +1,57 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdbool.h> +#include <readline/readline.h> + +#include "display.h" + +void rl_printf(const char *fmt, ...) +{ + va_list args; + char *saved_line; + int saved_point; + + saved_point = rl_point; + saved_line = rl_copy_text(0, rl_end); + rl_save_prompt(); + rl_replace_line("", 0); + rl_redisplay(); + + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); + + rl_restore_prompt(); + rl_replace_line(saved_line, 0); + rl_point = saved_point; + rl_redisplay(); + free(saved_line); +} |