Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / tools / perf / ui / gtk / helpline.c
blob3388cbd12186ac5848562e0de10faa7afa025982
1 #include <stdio.h>
2 #include <string.h>
4 #include "gtk.h"
5 #include "../ui.h"
6 #include "../helpline.h"
7 #include "../../util/debug.h"
9 static void gtk_helpline_pop(void)
11 if (!perf_gtk__is_active_context(pgctx))
12 return;
14 gtk_statusbar_pop(GTK_STATUSBAR(pgctx->statbar),
15 pgctx->statbar_ctx_id);
18 static void gtk_helpline_push(const char *msg)
20 if (!perf_gtk__is_active_context(pgctx))
21 return;
23 gtk_statusbar_push(GTK_STATUSBAR(pgctx->statbar),
24 pgctx->statbar_ctx_id, msg);
27 static int gtk_helpline_show(const char *fmt, va_list ap)
29 int ret;
30 char *ptr;
31 static int backlog;
33 ret = vscnprintf(ui_helpline__current + backlog,
34 sizeof(ui_helpline__current) - backlog, fmt, ap);
35 backlog += ret;
37 /* only first line can be displayed */
38 ptr = strchr(ui_helpline__current, '\n');
39 if (ptr && (ptr - ui_helpline__current) <= backlog) {
40 *ptr = '\0';
41 ui_helpline__puts(ui_helpline__current);
42 backlog = 0;
45 return ret;
48 static struct ui_helpline gtk_helpline_fns = {
49 .pop = gtk_helpline_pop,
50 .push = gtk_helpline_push,
51 .show = gtk_helpline_show,
54 void perf_gtk__init_helpline(void)
56 helpline_fns = &gtk_helpline_fns;