Linux Perf
helpline.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <string.h>
4 
5 #include "gtk.h"
6 #include "../ui.h"
7 #include "../helpline.h"
8 #include "../../util/debug.h"
9 
10 static void gtk_helpline_pop(void)
11 {
13  return;
14 
15  gtk_statusbar_pop(GTK_STATUSBAR(pgctx->statbar),
17 }
18 
19 static void gtk_helpline_push(const char *msg)
20 {
22  return;
23 
24  gtk_statusbar_push(GTK_STATUSBAR(pgctx->statbar),
25  pgctx->statbar_ctx_id, msg);
26 }
27 
28 static int gtk_helpline_show(const char *fmt, va_list ap)
29 {
30  int ret;
31  char *ptr;
32  static int backlog;
33 
34  ret = vscnprintf(ui_helpline__current + backlog,
35  sizeof(ui_helpline__current) - backlog, fmt, ap);
36  backlog += ret;
37 
38  /* only first line can be displayed */
39  ptr = strchr(ui_helpline__current, '\n');
40  if (ptr && (ptr - ui_helpline__current) <= backlog) {
41  *ptr = '\0';
43  backlog = 0;
44  }
45 
46  return ret;
47 }
48 
49 static struct ui_helpline gtk_helpline_fns = {
51  .push = gtk_helpline_push,
52  .show = gtk_helpline_show,
53 };
54 
56 {
58 }
char ui_helpline__current[512]
Definition: helpline.c:11
static int gtk_helpline_show(const char *fmt, va_list ap)
Definition: helpline.c:28
void(* pop)(void)
Definition: helpline.h:11
const char * fmt
Definition: dso.c:193
static void gtk_helpline_push(const char *msg)
Definition: helpline.c:19
static void gtk_helpline_pop(void)
Definition: helpline.c:10
void perf_gtk__init_helpline(void)
Definition: helpline.c:55
void ui_helpline__puts(const char *msg)
Definition: helpline.c:66
GtkWidget * statbar
Definition: gtk.h:20
guint statbar_ctx_id
Definition: gtk.h:21
struct perf_gtk_context * pgctx
Definition: util.c:10
static bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
Definition: gtk.h:29
struct ui_helpline * helpline_fns
Definition: helpline.c:33
static struct ui_helpline gtk_helpline_fns
Definition: helpline.c:49