diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 13:39:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 13:39:30 -0400 |
commit | 4b17cafaa4cc000a490821db649c5a3bf7ba9671 (patch) | |
tree | 9e6a1ed383be31f7a28ebfee726acf2cc15c377f /tools/perf/util/ui/helpline.c | |
parent | 36450e9c953b2a6838def5945de8ae508141e834 (diff) | |
parent | 88d89da64951377962334b684634cfc1468aa93f (diff) |
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (30 commits)
perf: Add back list_head data types
perf ui hist browser: Fixup key bindings
perf ui browser: Add ui_browser__show counterpart: __hide
perf annotate: Cycle thru sorted lines with samples
perf ui: Make SPACE work as PGDN in all browsers
perf annotate: Sort by hottest lines in the TUI
perf ui: Complete the breakdown of util/newt.c
perf ui: Move hists browser to util/ui/browsers/
perf symbols: Ignore mapping symbols on ARM
perf ui: Move map browser to util/ui/browsers/
perf ui: Move annotate browser to util/ui/browsers/
perf ui: Move ui_progress routines to separate file in util/ui/
perf ui: Move ui_helpline routines to separate file in util/ui/
perf ui: Shorten ui_browser member names
perf, x86: P4 PMU -- update nmi irq statistics and unmask lvt entry properly
perf ui: Start breaking down newt.c into multiple files
perf tui: Introduce list_head based generic ui_browser refresh routine
perf probe: Fix memory leaks in add_perf_probe_events
perf probe: Fix to copy the type for raw parameters
perf report: Speed up exit path
...
Diffstat (limited to 'tools/perf/util/ui/helpline.c')
-rw-r--r-- | tools/perf/util/ui/helpline.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/perf/util/ui/helpline.c b/tools/perf/util/ui/helpline.c new file mode 100644 index 000000000000..8d79daa4458a --- /dev/null +++ b/tools/perf/util/ui/helpline.c | |||
@@ -0,0 +1,69 @@ | |||
1 | #define _GNU_SOURCE | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <newt.h> | ||
5 | |||
6 | #include "../debug.h" | ||
7 | #include "helpline.h" | ||
8 | |||
9 | void ui_helpline__pop(void) | ||
10 | { | ||
11 | newtPopHelpLine(); | ||
12 | } | ||
13 | |||
14 | void ui_helpline__push(const char *msg) | ||
15 | { | ||
16 | newtPushHelpLine(msg); | ||
17 | } | ||
18 | |||
19 | void ui_helpline__vpush(const char *fmt, va_list ap) | ||
20 | { | ||
21 | char *s; | ||
22 | |||
23 | if (vasprintf(&s, fmt, ap) < 0) | ||
24 | vfprintf(stderr, fmt, ap); | ||
25 | else { | ||
26 | ui_helpline__push(s); | ||
27 | free(s); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | void ui_helpline__fpush(const char *fmt, ...) | ||
32 | { | ||
33 | va_list ap; | ||
34 | |||
35 | va_start(ap, fmt); | ||
36 | ui_helpline__vpush(fmt, ap); | ||
37 | va_end(ap); | ||
38 | } | ||
39 | |||
40 | void ui_helpline__puts(const char *msg) | ||
41 | { | ||
42 | ui_helpline__pop(); | ||
43 | ui_helpline__push(msg); | ||
44 | } | ||
45 | |||
46 | void ui_helpline__init(void) | ||
47 | { | ||
48 | ui_helpline__puts(" "); | ||
49 | } | ||
50 | |||
51 | char ui_helpline__last_msg[1024]; | ||
52 | |||
53 | int ui_helpline__show_help(const char *format, va_list ap) | ||
54 | { | ||
55 | int ret; | ||
56 | static int backlog; | ||
57 | |||
58 | ret = vsnprintf(ui_helpline__last_msg + backlog, | ||
59 | sizeof(ui_helpline__last_msg) - backlog, format, ap); | ||
60 | backlog += ret; | ||
61 | |||
62 | if (ui_helpline__last_msg[backlog - 1] == '\n') { | ||
63 | ui_helpline__puts(ui_helpline__last_msg); | ||
64 | newtRefresh(); | ||
65 | backlog = 0; | ||
66 | } | ||
67 | |||
68 | return ret; | ||
69 | } | ||