aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/gtk/helpline.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2012-08-16 04:14:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-17 11:37:56 -0400
commit0985a94891c73740dea1e2697f9d598a4a7810ab (patch)
tree6cf8ceff2dad3e1f36415885c0aaf2e00f4a20cb /tools/perf/ui/gtk/helpline.c
parented70c609ae92e0cb03b746ab566c3cf8f2aaede4 (diff)
perf ui gtk: Add perf_gtk__show_helpline() for pr_*
Use helpline for printing error/debug messages. The code resembles a TUI counter part and only print the first line of the message. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1345104894-14205-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/gtk/helpline.c')
-rw-r--r--tools/perf/ui/gtk/helpline.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/ui/gtk/helpline.c b/tools/perf/ui/gtk/helpline.c
index 2511b3746797..5db4432ff12a 100644
--- a/tools/perf/ui/gtk/helpline.c
+++ b/tools/perf/ui/gtk/helpline.c
@@ -1,5 +1,10 @@
1#include <stdio.h>
2#include <string.h>
3
1#include "gtk.h" 4#include "gtk.h"
5#include "../ui.h"
2#include "../helpline.h" 6#include "../helpline.h"
7#include "../../util/debug.h"
3 8
4static void gtk_helpline_pop(void) 9static void gtk_helpline_pop(void)
5{ 10{
@@ -28,3 +33,24 @@ void perf_gtk__init_helpline(void)
28{ 33{
29 helpline_fns = &gtk_helpline_fns; 34 helpline_fns = &gtk_helpline_fns;
30} 35}
36
37int perf_gtk__show_helpline(const char *fmt, va_list ap)
38{
39 int ret;
40 char *ptr;
41 static int backlog;
42
43 ret = vscnprintf(ui_helpline__current + backlog,
44 sizeof(ui_helpline__current) - backlog, fmt, ap);
45 backlog += ret;
46
47 /* only first line can be displayed */
48 ptr = strchr(ui_helpline__current, '\n');
49 if (ptr && (ptr - ui_helpline__current) <= backlog) {
50 *ptr = '\0';
51 ui_helpline__puts(ui_helpline__current);
52 backlog = 0;
53 }
54
55 return ret;
56}