perf ui: New hists tree widget
[deliverable/linux.git] / tools / perf / util / newt.c
1 #define _GNU_SOURCE
2 #include <stdio.h>
3 #undef _GNU_SOURCE
4 /*
5 * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks
6 * the build if it isn't defined. Use the equivalent one that glibc
7 * has on features.h.
8 */
9 #include <features.h>
10 #ifndef HAVE_LONG_LONG
11 #define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
12 #endif
13 #include <slang.h>
14 #include <stdlib.h>
15 #include <newt.h>
16 #include <sys/ttydefaults.h>
17
18 #include "cache.h"
19 #include "hist.h"
20 #include "pstack.h"
21 #include "session.h"
22 #include "sort.h"
23 #include "symbol.h"
24
25 #if SLANG_VERSION < 20104
26 #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args)
27 #define slsmg_write_nstring(msg, len) SLsmg_write_nstring((char *)msg, len)
28 #define sltt_set_color(obj, name, fg, bg) SLtt_set_color(obj,(char *)name,\
29 (char *)fg, (char *)bg)
30 #else
31 #define slsmg_printf SLsmg_printf
32 #define slsmg_write_nstring SLsmg_write_nstring
33 #define sltt_set_color SLtt_set_color
34 #endif
35
36 struct ui_progress {
37 newtComponent form, scale;
38 };
39
40 struct ui_progress *ui_progress__new(const char *title, u64 total)
41 {
42 struct ui_progress *self = malloc(sizeof(*self));
43
44 if (self != NULL) {
45 int cols;
46
47 if (use_browser <= 0)
48 return self;
49 newtGetScreenSize(&cols, NULL);
50 cols -= 4;
51 newtCenteredWindow(cols, 1, title);
52 self->form = newtForm(NULL, NULL, 0);
53 if (self->form == NULL)
54 goto out_free_self;
55 self->scale = newtScale(0, 0, cols, total);
56 if (self->scale == NULL)
57 goto out_free_form;
58 newtFormAddComponent(self->form, self->scale);
59 newtRefresh();
60 }
61
62 return self;
63
64 out_free_form:
65 newtFormDestroy(self->form);
66 out_free_self:
67 free(self);
68 return NULL;
69 }
70
71 void ui_progress__update(struct ui_progress *self, u64 curr)
72 {
73 /*
74 * FIXME: We should have a per UI backend way of showing progress,
75 * stdio will just show a percentage as NN%, etc.
76 */
77 if (use_browser <= 0)
78 return;
79 newtScaleSet(self->scale, curr);
80 newtRefresh();
81 }
82
83 void ui_progress__delete(struct ui_progress *self)
84 {
85 if (use_browser > 0) {
86 newtFormDestroy(self->form);
87 newtPopWindow();
88 }
89 free(self);
90 }
91
92 static void ui_helpline__pop(void)
93 {
94 newtPopHelpLine();
95 }
96
97 static void ui_helpline__push(const char *msg)
98 {
99 newtPushHelpLine(msg);
100 }
101
102 static void ui_helpline__vpush(const char *fmt, va_list ap)
103 {
104 char *s;
105
106 if (vasprintf(&s, fmt, ap) < 0)
107 vfprintf(stderr, fmt, ap);
108 else {
109 ui_helpline__push(s);
110 free(s);
111 }
112 }
113
114 static void ui_helpline__fpush(const char *fmt, ...)
115 {
116 va_list ap;
117
118 va_start(ap, fmt);
119 ui_helpline__vpush(fmt, ap);
120 va_end(ap);
121 }
122
123 static void ui_helpline__puts(const char *msg)
124 {
125 ui_helpline__pop();
126 ui_helpline__push(msg);
127 }
128
129 static char browser__last_msg[1024];
130
131 int browser__show_help(const char *format, va_list ap)
132 {
133 int ret;
134 static int backlog;
135
136 ret = vsnprintf(browser__last_msg + backlog,
137 sizeof(browser__last_msg) - backlog, format, ap);
138 backlog += ret;
139
140 if (browser__last_msg[backlog - 1] == '\n') {
141 ui_helpline__puts(browser__last_msg);
142 newtRefresh();
143 backlog = 0;
144 }
145
146 return ret;
147 }
148
149 static void newt_form__set_exit_keys(newtComponent self)
150 {
151 newtFormAddHotKey(self, NEWT_KEY_LEFT);
152 newtFormAddHotKey(self, NEWT_KEY_ESCAPE);
153 newtFormAddHotKey(self, 'Q');
154 newtFormAddHotKey(self, 'q');
155 newtFormAddHotKey(self, CTRL('c'));
156 }
157
158 static newtComponent newt_form__new(void)
159 {
160 newtComponent self = newtForm(NULL, NULL, 0);
161 if (self)
162 newt_form__set_exit_keys(self);
163 return self;
164 }
165
166 static int popup_menu(int argc, char * const argv[])
167 {
168 struct newtExitStruct es;
169 int i, rc = -1, max_len = 5;
170 newtComponent listbox, form = newt_form__new();
171
172 if (form == NULL)
173 return -1;
174
175 listbox = newtListbox(0, 0, argc, NEWT_FLAG_RETURNEXIT);
176 if (listbox == NULL)
177 goto out_destroy_form;
178
179 newtFormAddComponent(form, listbox);
180
181 for (i = 0; i < argc; ++i) {
182 int len = strlen(argv[i]);
183 if (len > max_len)
184 max_len = len;
185 if (newtListboxAddEntry(listbox, argv[i], (void *)(long)i))
186 goto out_destroy_form;
187 }
188
189 newtCenteredWindow(max_len, argc, NULL);
190 newtFormRun(form, &es);
191 rc = newtListboxGetCurrent(listbox) - NULL;
192 if (es.reason == NEWT_EXIT_HOTKEY)
193 rc = -1;
194 newtPopWindow();
195 out_destroy_form:
196 newtFormDestroy(form);
197 return rc;
198 }
199
200 static int ui__help_window(const char *text)
201 {
202 struct newtExitStruct es;
203 newtComponent tb, form = newt_form__new();
204 int rc = -1;
205 int max_len = 0, nr_lines = 0;
206 const char *t;
207
208 if (form == NULL)
209 return -1;
210
211 t = text;
212 while (1) {
213 const char *sep = strchr(t, '\n');
214 int len;
215
216 if (sep == NULL)
217 sep = strchr(t, '\0');
218 len = sep - t;
219 if (max_len < len)
220 max_len = len;
221 ++nr_lines;
222 if (*sep == '\0')
223 break;
224 t = sep + 1;
225 }
226
227 tb = newtTextbox(0, 0, max_len, nr_lines, 0);
228 if (tb == NULL)
229 goto out_destroy_form;
230
231 newtTextboxSetText(tb, text);
232 newtFormAddComponent(form, tb);
233 newtCenteredWindow(max_len, nr_lines, NULL);
234 newtFormRun(form, &es);
235 newtPopWindow();
236 rc = 0;
237 out_destroy_form:
238 newtFormDestroy(form);
239 return rc;
240 }
241
242 static bool dialog_yesno(const char *msg)
243 {
244 /* newtWinChoice should really be accepting const char pointers... */
245 char yes[] = "Yes", no[] = "No";
246 return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
247 }
248
249 static void ui__error_window(const char *fmt, ...)
250 {
251 va_list ap;
252
253 va_start(ap, fmt);
254 newtWinMessagev((char *)"Error", (char *)"Ok", (char *)fmt, ap);
255 va_end(ap);
256 }
257
258 #define HE_COLORSET_TOP 50
259 #define HE_COLORSET_MEDIUM 51
260 #define HE_COLORSET_NORMAL 52
261 #define HE_COLORSET_SELECTED 53
262 #define HE_COLORSET_CODE 54
263
264 static int ui_browser__percent_color(double percent, bool current)
265 {
266 if (current)
267 return HE_COLORSET_SELECTED;
268 if (percent >= MIN_RED)
269 return HE_COLORSET_TOP;
270 if (percent >= MIN_GREEN)
271 return HE_COLORSET_MEDIUM;
272 return HE_COLORSET_NORMAL;
273 }
274
275 struct ui_browser {
276 newtComponent form, sb;
277 u64 index, first_visible_entry_idx;
278 void *first_visible_entry, *entries;
279 u16 top, left, width, height;
280 void *priv;
281 unsigned int (*refresh_entries)(struct ui_browser *self);
282 void (*seek)(struct ui_browser *self,
283 off_t offset, int whence);
284 u32 nr_entries;
285 };
286
287 static void ui_browser__list_head_seek(struct ui_browser *self,
288 off_t offset, int whence)
289 {
290 struct list_head *head = self->entries;
291 struct list_head *pos;
292
293 switch (whence) {
294 case SEEK_SET:
295 pos = head->next;
296 break;
297 case SEEK_CUR:
298 pos = self->first_visible_entry;
299 break;
300 case SEEK_END:
301 pos = head->prev;
302 break;
303 default:
304 return;
305 }
306
307 if (offset > 0) {
308 while (offset-- != 0)
309 pos = pos->next;
310 } else {
311 while (offset++ != 0)
312 pos = pos->prev;
313 }
314
315 self->first_visible_entry = pos;
316 }
317
318 static bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row)
319 {
320 return (self->first_visible_entry_idx + row) == self->index;
321 }
322
323 static void ui_browser__refresh_dimensions(struct ui_browser *self)
324 {
325 int cols, rows;
326 newtGetScreenSize(&cols, &rows);
327
328 if (self->width > cols - 4)
329 self->width = cols - 4;
330 self->height = rows - 5;
331 if (self->height > self->nr_entries)
332 self->height = self->nr_entries;
333 self->top = (rows - self->height) / 2;
334 self->left = (cols - self->width) / 2;
335 }
336
337 static void ui_browser__reset_index(struct ui_browser *self)
338 {
339 self->index = self->first_visible_entry_idx = 0;
340 self->seek(self, 0, SEEK_SET);
341 }
342
343 static int ui_browser__show(struct ui_browser *self, const char *title)
344 {
345 if (self->form != NULL) {
346 newtFormDestroy(self->form);
347 newtPopWindow();
348 }
349 ui_browser__refresh_dimensions(self);
350 newtCenteredWindow(self->width, self->height, title);
351 self->form = newt_form__new();
352 if (self->form == NULL)
353 return -1;
354
355 self->sb = newtVerticalScrollbar(self->width, 0, self->height,
356 HE_COLORSET_NORMAL,
357 HE_COLORSET_SELECTED);
358 if (self->sb == NULL)
359 return -1;
360
361 newtFormAddHotKey(self->form, NEWT_KEY_UP);
362 newtFormAddHotKey(self->form, NEWT_KEY_DOWN);
363 newtFormAddHotKey(self->form, NEWT_KEY_PGUP);
364 newtFormAddHotKey(self->form, NEWT_KEY_PGDN);
365 newtFormAddHotKey(self->form, NEWT_KEY_HOME);
366 newtFormAddHotKey(self->form, NEWT_KEY_END);
367 newtFormAddComponent(self->form, self->sb);
368 return 0;
369 }
370
371 static int objdump_line__show(struct objdump_line *self, struct list_head *head,
372 int width, struct hist_entry *he, int len,
373 bool current_entry)
374 {
375 if (self->offset != -1) {
376 struct symbol *sym = he->ms.sym;
377 unsigned int hits = 0;
378 double percent = 0.0;
379 int color;
380 struct sym_priv *priv = symbol__priv(sym);
381 struct sym_ext *sym_ext = priv->ext;
382 struct sym_hist *h = priv->hist;
383 s64 offset = self->offset;
384 struct objdump_line *next = objdump__get_next_ip_line(head, self);
385
386 while (offset < (s64)len &&
387 (next == NULL || offset < next->offset)) {
388 if (sym_ext) {
389 percent += sym_ext[offset].percent;
390 } else
391 hits += h->ip[offset];
392
393 ++offset;
394 }
395
396 if (sym_ext == NULL && h->sum)
397 percent = 100.0 * hits / h->sum;
398
399 color = ui_browser__percent_color(percent, current_entry);
400 SLsmg_set_color(color);
401 slsmg_printf(" %7.2f ", percent);
402 if (!current_entry)
403 SLsmg_set_color(HE_COLORSET_CODE);
404 } else {
405 int color = ui_browser__percent_color(0, current_entry);
406 SLsmg_set_color(color);
407 slsmg_write_nstring(" ", 9);
408 }
409
410 SLsmg_write_char(':');
411 slsmg_write_nstring(" ", 8);
412 if (!*self->line)
413 slsmg_write_nstring(" ", width - 18);
414 else
415 slsmg_write_nstring(self->line, width - 18);
416
417 return 0;
418 }
419
420 static int ui_browser__refresh_entries(struct ui_browser *self)
421 {
422 int row;
423
424 newtScrollbarSet(self->sb, self->index, self->nr_entries - 1);
425 row = self->refresh_entries(self);
426 SLsmg_set_color(HE_COLORSET_NORMAL);
427 SLsmg_fill_region(self->top + row, self->left,
428 self->height - row, self->width, ' ');
429
430 return 0;
431 }
432
433 static int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
434 {
435 if (ui_browser__refresh_entries(self) < 0)
436 return -1;
437
438 while (1) {
439 off_t offset;
440
441 newtFormRun(self->form, es);
442
443 if (es->reason != NEWT_EXIT_HOTKEY)
444 break;
445 if (is_exit_key(es->u.key))
446 return es->u.key;
447 switch (es->u.key) {
448 case NEWT_KEY_DOWN:
449 if (self->index == self->nr_entries - 1)
450 break;
451 ++self->index;
452 if (self->index == self->first_visible_entry_idx + self->height) {
453 ++self->first_visible_entry_idx;
454 self->seek(self, +1, SEEK_CUR);
455 }
456 break;
457 case NEWT_KEY_UP:
458 if (self->index == 0)
459 break;
460 --self->index;
461 if (self->index < self->first_visible_entry_idx) {
462 --self->first_visible_entry_idx;
463 self->seek(self, -1, SEEK_CUR);
464 }
465 break;
466 case NEWT_KEY_PGDN:
467 case ' ':
468 if (self->first_visible_entry_idx + self->height > self->nr_entries - 1)
469 break;
470
471 offset = self->height;
472 if (self->index + offset > self->nr_entries - 1)
473 offset = self->nr_entries - 1 - self->index;
474 self->index += offset;
475 self->first_visible_entry_idx += offset;
476 self->seek(self, +offset, SEEK_CUR);
477 break;
478 case NEWT_KEY_PGUP:
479 if (self->first_visible_entry_idx == 0)
480 break;
481
482 if (self->first_visible_entry_idx < self->height)
483 offset = self->first_visible_entry_idx;
484 else
485 offset = self->height;
486
487 self->index -= offset;
488 self->first_visible_entry_idx -= offset;
489 self->seek(self, -offset, SEEK_CUR);
490 break;
491 case NEWT_KEY_HOME:
492 ui_browser__reset_index(self);
493 break;
494 case NEWT_KEY_END:
495 offset = self->height - 1;
496 if (offset >= self->nr_entries)
497 offset = self->nr_entries - 1;
498
499 self->index = self->nr_entries - 1;
500 self->first_visible_entry_idx = self->index - offset;
501 self->seek(self, -offset, SEEK_END);
502 break;
503 default:
504 return es->u.key;
505 }
506 if (ui_browser__refresh_entries(self) < 0)
507 return -1;
508 }
509 return 0;
510 }
511
512 static char *callchain_list__sym_name(struct callchain_list *self,
513 char *bf, size_t bfsize)
514 {
515 if (self->ms.sym)
516 return self->ms.sym->name;
517
518 snprintf(bf, bfsize, "%#Lx", self->ip);
519 return bf;
520 }
521
522 static unsigned int hist_entry__annotate_browser_refresh(struct ui_browser *self)
523 {
524 struct objdump_line *pos;
525 struct list_head *head = self->entries;
526 struct hist_entry *he = self->priv;
527 int row = 0;
528 int len = he->ms.sym->end - he->ms.sym->start;
529
530 if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries)
531 self->first_visible_entry = head->next;
532
533 pos = list_entry(self->first_visible_entry, struct objdump_line, node);
534
535 list_for_each_entry_from(pos, head, node) {
536 bool current_entry = ui_browser__is_current_entry(self, row);
537 SLsmg_gotorc(self->top + row, self->left);
538 objdump_line__show(pos, head, self->width,
539 he, len, current_entry);
540 if (++row == self->height)
541 break;
542 }
543
544 return row;
545 }
546
547 int hist_entry__tui_annotate(struct hist_entry *self)
548 {
549 struct ui_browser browser;
550 struct newtExitStruct es;
551 struct objdump_line *pos, *n;
552 LIST_HEAD(head);
553 int ret;
554
555 if (self->ms.sym == NULL)
556 return -1;
557
558 if (self->ms.map->dso->annotate_warned)
559 return -1;
560
561 if (hist_entry__annotate(self, &head) < 0) {
562 ui__error_window(browser__last_msg);
563 return -1;
564 }
565
566 ui_helpline__push("Press <- or ESC to exit");
567
568 memset(&browser, 0, sizeof(browser));
569 browser.entries = &head;
570 browser.refresh_entries = hist_entry__annotate_browser_refresh;
571 browser.seek = ui_browser__list_head_seek;
572 browser.priv = self;
573 list_for_each_entry(pos, &head, node) {
574 size_t line_len = strlen(pos->line);
575 if (browser.width < line_len)
576 browser.width = line_len;
577 ++browser.nr_entries;
578 }
579
580 browser.width += 18; /* Percentage */
581 ui_browser__show(&browser, self->ms.sym->name);
582 newtFormAddHotKey(browser.form, ' ');
583 ret = ui_browser__run(&browser, &es);
584 newtFormDestroy(browser.form);
585 newtPopWindow();
586 list_for_each_entry_safe(pos, n, &head, node) {
587 list_del(&pos->node);
588 objdump_line__free(pos);
589 }
590 ui_helpline__pop();
591 return ret;
592 }
593
594 struct hist_browser {
595 struct ui_browser b;
596 struct hists *hists;
597 struct hist_entry *he_selection;
598 struct map_symbol *selection;
599 };
600
601 static void hist_browser__reset(struct hist_browser *self);
602 static int hist_browser__run(struct hist_browser *self, const char *title,
603 struct newtExitStruct *es);
604 static unsigned int hist_browser__refresh_entries(struct ui_browser *self);
605 static void ui_browser__hists_seek(struct ui_browser *self,
606 off_t offset, int whence);
607
608 static struct hist_browser *hist_browser__new(struct hists *hists)
609 {
610 struct hist_browser *self = zalloc(sizeof(*self));
611
612 if (self) {
613 self->hists = hists;
614 self->b.refresh_entries = hist_browser__refresh_entries;
615 self->b.seek = ui_browser__hists_seek;
616 }
617
618 return self;
619 }
620
621 static void hist_browser__delete(struct hist_browser *self)
622 {
623 newtFormDestroy(self->b.form);
624 newtPopWindow();
625 free(self);
626 }
627
628 static struct hist_entry *hist_browser__selected_entry(struct hist_browser *self)
629 {
630 return self->he_selection;
631 }
632
633 static struct thread *hist_browser__selected_thread(struct hist_browser *self)
634 {
635 return self->he_selection->thread;
636 }
637
638 static int hist_browser__title(char *bf, size_t size, const char *ev_name,
639 const struct dso *dso, const struct thread *thread)
640 {
641 int printed = 0;
642
643 if (thread)
644 printed += snprintf(bf + printed, size - printed,
645 "Thread: %s(%d)",
646 (thread->comm_set ? thread->comm : ""),
647 thread->pid);
648 if (dso)
649 printed += snprintf(bf + printed, size - printed,
650 "%sDSO: %s", thread ? " " : "",
651 dso->short_name);
652 return printed ?: snprintf(bf, size, "Event: %s", ev_name);
653 }
654
655 int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
656 {
657 struct hist_browser *browser = hist_browser__new(self);
658 struct pstack *fstack;
659 const struct thread *thread_filter = NULL;
660 const struct dso *dso_filter = NULL;
661 struct newtExitStruct es;
662 char msg[160];
663 int key = -1;
664
665 if (browser == NULL)
666 return -1;
667
668 fstack = pstack__new(2);
669 if (fstack == NULL)
670 goto out;
671
672 ui_helpline__push(helpline);
673
674 hist_browser__title(msg, sizeof(msg), ev_name,
675 dso_filter, thread_filter);
676
677 while (1) {
678 const struct thread *thread;
679 const struct dso *dso;
680 char *options[16];
681 int nr_options = 0, choice = 0, i,
682 annotate = -2, zoom_dso = -2, zoom_thread = -2;
683
684 if (hist_browser__run(browser, msg, &es))
685 break;
686
687 thread = hist_browser__selected_thread(browser);
688 dso = browser->selection->map ? browser->selection->map->dso : NULL;
689
690 if (es.reason == NEWT_EXIT_HOTKEY) {
691 key = es.u.key;
692
693 switch (key) {
694 case NEWT_KEY_F1:
695 goto do_help;
696 case NEWT_KEY_TAB:
697 case NEWT_KEY_UNTAB:
698 /*
699 * Exit the browser, let hists__browser_tree
700 * go to the next or previous
701 */
702 goto out_free_stack;
703 default:;
704 }
705
706 key = toupper(key);
707 switch (key) {
708 case 'A':
709 if (browser->selection->map == NULL &&
710 browser->selection->map->dso->annotate_warned)
711 continue;
712 goto do_annotate;
713 case 'D':
714 goto zoom_dso;
715 case 'T':
716 goto zoom_thread;
717 case 'H':
718 case '?':
719 do_help:
720 ui__help_window("-> Zoom into DSO/Threads & Annotate current symbol\n"
721 "<- Zoom out\n"
722 "a Annotate current symbol\n"
723 "h/?/F1 Show this window\n"
724 "d Zoom into current DSO\n"
725 "t Zoom into current Thread\n"
726 "q/CTRL+C Exit browser");
727 continue;
728 default:;
729 }
730 if (is_exit_key(key)) {
731 if (key == NEWT_KEY_ESCAPE) {
732 if (dialog_yesno("Do you really want to exit?"))
733 break;
734 else
735 continue;
736 } else
737 break;
738 }
739
740 if (es.u.key == NEWT_KEY_LEFT) {
741 const void *top;
742
743 if (pstack__empty(fstack))
744 continue;
745 top = pstack__pop(fstack);
746 if (top == &dso_filter)
747 goto zoom_out_dso;
748 if (top == &thread_filter)
749 goto zoom_out_thread;
750 continue;
751 }
752 }
753
754 if (browser->selection->sym != NULL &&
755 !browser->selection->map->dso->annotate_warned &&
756 asprintf(&options[nr_options], "Annotate %s",
757 browser->selection->sym->name) > 0)
758 annotate = nr_options++;
759
760 if (thread != NULL &&
761 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
762 (thread_filter ? "out of" : "into"),
763 (thread->comm_set ? thread->comm : ""),
764 thread->pid) > 0)
765 zoom_thread = nr_options++;
766
767 if (dso != NULL &&
768 asprintf(&options[nr_options], "Zoom %s %s DSO",
769 (dso_filter ? "out of" : "into"),
770 (dso->kernel ? "the Kernel" : dso->short_name)) > 0)
771 zoom_dso = nr_options++;
772
773 options[nr_options++] = (char *)"Exit";
774
775 choice = popup_menu(nr_options, options);
776
777 for (i = 0; i < nr_options - 1; ++i)
778 free(options[i]);
779
780 if (choice == nr_options - 1)
781 break;
782
783 if (choice == -1)
784 continue;
785
786 if (choice == annotate) {
787 struct hist_entry *he;
788 do_annotate:
789 if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) {
790 browser->selection->map->dso->annotate_warned = 1;
791 ui_helpline__puts("No vmlinux file found, can't "
792 "annotate with just a "
793 "kallsyms file");
794 continue;
795 }
796
797 he = hist_browser__selected_entry(browser);
798 if (he == NULL)
799 continue;
800
801 hist_entry__tui_annotate(he);
802 } else if (choice == zoom_dso) {
803 zoom_dso:
804 if (dso_filter) {
805 pstack__remove(fstack, &dso_filter);
806 zoom_out_dso:
807 ui_helpline__pop();
808 dso_filter = NULL;
809 } else {
810 if (dso == NULL)
811 continue;
812 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
813 dso->kernel ? "the Kernel" : dso->short_name);
814 dso_filter = dso;
815 pstack__push(fstack, &dso_filter);
816 }
817 hists__filter_by_dso(self, dso_filter);
818 hist_browser__title(msg, sizeof(msg), ev_name,
819 dso_filter, thread_filter);
820 hist_browser__reset(browser);
821 } else if (choice == zoom_thread) {
822 zoom_thread:
823 if (thread_filter) {
824 pstack__remove(fstack, &thread_filter);
825 zoom_out_thread:
826 ui_helpline__pop();
827 thread_filter = NULL;
828 } else {
829 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
830 thread->comm_set ? thread->comm : "",
831 thread->pid);
832 thread_filter = thread;
833 pstack__push(fstack, &thread_filter);
834 }
835 hists__filter_by_thread(self, thread_filter);
836 hist_browser__title(msg, sizeof(msg), ev_name,
837 dso_filter, thread_filter);
838 hist_browser__reset(browser);
839 }
840 }
841 out_free_stack:
842 pstack__delete(fstack);
843 out:
844 hist_browser__delete(browser);
845 return key;
846 }
847
848 int hists__tui_browse_tree(struct rb_root *self, const char *help)
849 {
850 struct rb_node *first = rb_first(self), *nd = first, *next;
851 int key = 0;
852
853 while (nd) {
854 struct hists *hists = rb_entry(nd, struct hists, rb_node);
855 const char *ev_name = __event_name(hists->type, hists->config);
856
857 key = hists__browse(hists, help, ev_name);
858
859 if (is_exit_key(key))
860 break;
861
862 switch (key) {
863 case NEWT_KEY_TAB:
864 next = rb_next(nd);
865 if (next)
866 nd = next;
867 break;
868 case NEWT_KEY_UNTAB:
869 if (nd == first)
870 continue;
871 nd = rb_prev(nd);
872 default:
873 break;
874 }
875 }
876
877 return key;
878 }
879
880 static struct newtPercentTreeColors {
881 const char *topColorFg, *topColorBg;
882 const char *mediumColorFg, *mediumColorBg;
883 const char *normalColorFg, *normalColorBg;
884 const char *selColorFg, *selColorBg;
885 const char *codeColorFg, *codeColorBg;
886 } defaultPercentTreeColors = {
887 "red", "lightgray",
888 "green", "lightgray",
889 "black", "lightgray",
890 "lightgray", "magenta",
891 "blue", "lightgray",
892 };
893
894 void setup_browser(void)
895 {
896 struct newtPercentTreeColors *c = &defaultPercentTreeColors;
897
898 if (!isatty(1) || !use_browser || dump_trace) {
899 use_browser = 0;
900 setup_pager();
901 return;
902 }
903
904 use_browser = 1;
905 newtInit();
906 newtCls();
907 ui_helpline__puts(" ");
908 sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg);
909 sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg);
910 sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg);
911 sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg);
912 sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg);
913 }
914
915 void exit_browser(bool wait_for_ok)
916 {
917 if (use_browser > 0) {
918 if (wait_for_ok) {
919 char title[] = "Fatal Error", ok[] = "Ok";
920 newtWinMessage(title, ok, browser__last_msg);
921 }
922 newtFinished();
923 }
924 }
925
926 static void hist_browser__refresh_dimensions(struct hist_browser *self)
927 {
928 /* 3 == +/- toggle symbol before actual hist_entry rendering */
929 self->b.width = 3 + (hists__sort_list_width(self->hists) +
930 sizeof("[k]"));
931 }
932
933 static void hist_browser__reset(struct hist_browser *self)
934 {
935 self->b.nr_entries = self->hists->nr_entries;
936 hist_browser__refresh_dimensions(self);
937 ui_browser__reset_index(&self->b);
938 }
939
940 static char tree__folded_sign(bool unfolded)
941 {
942 return unfolded ? '-' : '+';
943 }
944
945 static char map_symbol__folded(const struct map_symbol *self)
946 {
947 return self->has_children ? tree__folded_sign(self->unfolded) : ' ';
948 }
949
950 static char hist_entry__folded(const struct hist_entry *self)
951 {
952 return map_symbol__folded(&self->ms);
953 }
954
955 static char callchain_list__folded(const struct callchain_list *self)
956 {
957 return map_symbol__folded(&self->ms);
958 }
959
960 static bool map_symbol__toggle_fold(struct map_symbol *self)
961 {
962 if (!self->has_children)
963 return false;
964
965 self->unfolded = !self->unfolded;
966 return true;
967 }
968
969 #define LEVEL_OFFSET_STEP 3
970
971 static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
972 struct callchain_node *chain_node,
973 u64 total, int level,
974 unsigned short row,
975 off_t *row_offset,
976 bool *is_current_entry)
977 {
978 struct rb_node *node;
979 int first_row = row, width, offset = level * LEVEL_OFFSET_STEP;
980 u64 new_total, remaining;
981
982 if (callchain_param.mode == CHAIN_GRAPH_REL)
983 new_total = chain_node->children_hit;
984 else
985 new_total = total;
986
987 remaining = new_total;
988 node = rb_first(&chain_node->rb_root);
989 while (node) {
990 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
991 struct rb_node *next = rb_next(node);
992 u64 cumul = cumul_hits(child);
993 struct callchain_list *chain;
994 char folded_sign = ' ';
995 int first = true;
996 int extra_offset = 0;
997
998 remaining -= cumul;
999
1000 list_for_each_entry(chain, &child->val, list) {
1001 char ipstr[BITS_PER_LONG / 4 + 1], *alloc_str;
1002 const char *str;
1003 int color;
1004 bool was_first = first;
1005
1006 if (first) {
1007 first = false;
1008 chain->ms.has_children = chain->list.next != &child->val ||
1009 rb_first(&child->rb_root) != NULL;
1010 } else {
1011 extra_offset = LEVEL_OFFSET_STEP;
1012 chain->ms.has_children = chain->list.next == &child->val &&
1013 rb_first(&child->rb_root) != NULL;
1014 }
1015
1016 folded_sign = callchain_list__folded(chain);
1017 if (*row_offset != 0) {
1018 --*row_offset;
1019 goto do_next;
1020 }
1021
1022 alloc_str = NULL;
1023 str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
1024 if (was_first) {
1025 double percent = cumul * 100.0 / new_total;
1026
1027 if (asprintf(&alloc_str, "%2.2f%% %s", percent, str) < 0)
1028 str = "Not enough memory!";
1029 else
1030 str = alloc_str;
1031 }
1032
1033 color = HE_COLORSET_NORMAL;
1034 width = self->b.width - (offset + extra_offset + 2);
1035 if (ui_browser__is_current_entry(&self->b, row)) {
1036 self->selection = &chain->ms;
1037 color = HE_COLORSET_SELECTED;
1038 *is_current_entry = true;
1039 }
1040
1041 SLsmg_set_color(color);
1042 SLsmg_gotorc(self->b.top + row, self->b.left);
1043 slsmg_write_nstring(" ", offset + extra_offset);
1044 slsmg_printf("%c ", folded_sign);
1045 slsmg_write_nstring(str, width);
1046 free(alloc_str);
1047
1048 if (++row == self->b.height)
1049 goto out;
1050 do_next:
1051 if (folded_sign == '+')
1052 break;
1053 }
1054
1055 if (folded_sign == '-') {
1056 const int new_level = level + (extra_offset ? 2 : 1);
1057 row += hist_browser__show_callchain_node_rb_tree(self, child, new_total,
1058 new_level, row, row_offset,
1059 is_current_entry);
1060 }
1061 if (row == self->b.height)
1062 goto out;
1063 node = next;
1064 }
1065 out:
1066 return row - first_row;
1067 }
1068
1069 static int hist_browser__show_callchain_node(struct hist_browser *self,
1070 struct callchain_node *node,
1071 int level, unsigned short row,
1072 off_t *row_offset,
1073 bool *is_current_entry)
1074 {
1075 struct callchain_list *chain;
1076 int first_row = row,
1077 offset = level * LEVEL_OFFSET_STEP,
1078 width = self->b.width - offset;
1079 char folded_sign = ' ';
1080
1081 list_for_each_entry(chain, &node->val, list) {
1082 char ipstr[BITS_PER_LONG / 4 + 1], *s;
1083 int color;
1084 /*
1085 * FIXME: This should be moved to somewhere else,
1086 * probably when the callchain is created, so as not to
1087 * traverse it all over again
1088 */
1089 chain->ms.has_children = rb_first(&node->rb_root) != NULL;
1090 folded_sign = callchain_list__folded(chain);
1091
1092 if (*row_offset != 0) {
1093 --*row_offset;
1094 continue;
1095 }
1096
1097 color = HE_COLORSET_NORMAL;
1098 if (ui_browser__is_current_entry(&self->b, row)) {
1099 self->selection = &chain->ms;
1100 color = HE_COLORSET_SELECTED;
1101 *is_current_entry = true;
1102 }
1103
1104 s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
1105 SLsmg_gotorc(self->b.top + row, self->b.left);
1106 SLsmg_set_color(color);
1107 slsmg_write_nstring(" ", offset);
1108 slsmg_printf("%c ", folded_sign);
1109 slsmg_write_nstring(s, width - 2);
1110
1111 if (++row == self->b.height)
1112 goto out;
1113 }
1114
1115 if (folded_sign == '-')
1116 row += hist_browser__show_callchain_node_rb_tree(self, node,
1117 self->hists->stats.total_period,
1118 level + 1, row,
1119 row_offset,
1120 is_current_entry);
1121 out:
1122 return row - first_row;
1123 }
1124
1125 static int hist_browser__show_callchain(struct hist_browser *self,
1126 struct rb_root *chain,
1127 int level, unsigned short row,
1128 off_t *row_offset,
1129 bool *is_current_entry)
1130 {
1131 struct rb_node *nd;
1132 int first_row = row;
1133
1134 for (nd = rb_first(chain); nd; nd = rb_next(nd)) {
1135 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
1136
1137 row += hist_browser__show_callchain_node(self, node, level,
1138 row, row_offset,
1139 is_current_entry);
1140 if (row == self->b.height)
1141 break;
1142 }
1143
1144 return row - first_row;
1145 }
1146
1147 static int hist_browser__show_entry(struct hist_browser *self,
1148 struct hist_entry *entry,
1149 unsigned short row)
1150 {
1151 char s[256];
1152 double percent;
1153 int printed = 0;
1154 int color, width = self->b.width;
1155 char folded_sign = ' ';
1156 bool current_entry = ui_browser__is_current_entry(&self->b, row);
1157 off_t row_offset = entry->row_offset;
1158
1159 if (current_entry) {
1160 self->he_selection = entry;
1161 self->selection = &entry->ms;
1162 }
1163
1164 if (symbol_conf.use_callchain) {
1165 entry->ms.has_children = !RB_EMPTY_ROOT(&entry->sorted_chain);
1166 folded_sign = hist_entry__folded(entry);
1167 }
1168
1169 if (row_offset == 0) {
1170 hist_entry__snprintf(entry, s, sizeof(s), self->hists, NULL, false,
1171 0, false, self->hists->stats.total_period);
1172 percent = (entry->period * 100.0) / self->hists->stats.total_period;
1173
1174 color = HE_COLORSET_SELECTED;
1175 if (!current_entry) {
1176 if (percent >= MIN_RED)
1177 color = HE_COLORSET_TOP;
1178 else if (percent >= MIN_GREEN)
1179 color = HE_COLORSET_MEDIUM;
1180 else
1181 color = HE_COLORSET_NORMAL;
1182 }
1183
1184 SLsmg_set_color(color);
1185 SLsmg_gotorc(self->b.top + row, self->b.left);
1186 if (symbol_conf.use_callchain) {
1187 slsmg_printf("%c ", folded_sign);
1188 width -= 2;
1189 }
1190 slsmg_write_nstring(s, width);
1191 ++row;
1192 ++printed;
1193 } else
1194 --row_offset;
1195
1196 if (folded_sign == '-' && row != self->b.height) {
1197 printed += hist_browser__show_callchain(self, &entry->sorted_chain,
1198 1, row, &row_offset,
1199 &current_entry);
1200 if (current_entry)
1201 self->he_selection = entry;
1202 }
1203
1204 return printed;
1205 }
1206
1207 static unsigned int hist_browser__refresh_entries(struct ui_browser *self)
1208 {
1209 unsigned row = 0;
1210 struct rb_node *nd;
1211 struct hist_browser *hb = container_of(self, struct hist_browser, b);
1212
1213 if (self->first_visible_entry == NULL)
1214 self->first_visible_entry = rb_first(&hb->hists->entries);
1215
1216 for (nd = self->first_visible_entry; nd; nd = rb_next(nd)) {
1217 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1218
1219 if (h->filtered)
1220 continue;
1221
1222 row += hist_browser__show_entry(hb, h, row);
1223 if (row == self->height)
1224 break;
1225 }
1226
1227 return row;
1228 }
1229
1230 static void callchain_node__init_have_children_rb_tree(struct callchain_node *self)
1231 {
1232 struct rb_node *nd = rb_first(&self->rb_root);
1233
1234 for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) {
1235 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
1236 struct callchain_list *chain;
1237 int first = true;
1238
1239 list_for_each_entry(chain, &child->val, list) {
1240 if (first) {
1241 first = false;
1242 chain->ms.has_children = chain->list.next != &child->val ||
1243 rb_first(&child->rb_root) != NULL;
1244 } else
1245 chain->ms.has_children = chain->list.next == &child->val &&
1246 rb_first(&child->rb_root) != NULL;
1247 }
1248
1249 callchain_node__init_have_children_rb_tree(child);
1250 }
1251 }
1252
1253 static void callchain_node__init_have_children(struct callchain_node *self)
1254 {
1255 struct callchain_list *chain;
1256
1257 list_for_each_entry(chain, &self->val, list)
1258 chain->ms.has_children = rb_first(&self->rb_root) != NULL;
1259
1260 callchain_node__init_have_children_rb_tree(self);
1261 }
1262
1263 static void callchain__init_have_children(struct rb_root *self)
1264 {
1265 struct rb_node *nd;
1266
1267 for (nd = rb_first(self); nd; nd = rb_next(nd)) {
1268 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
1269 callchain_node__init_have_children(node);
1270 }
1271 }
1272
1273 static void hist_entry__init_have_children(struct hist_entry *self)
1274 {
1275 if (!self->init_have_children) {
1276 callchain__init_have_children(&self->sorted_chain);
1277 self->init_have_children = true;
1278 }
1279 }
1280
1281 static struct rb_node *hists__filter_entries(struct rb_node *nd)
1282 {
1283 while (nd != NULL) {
1284 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1285 if (!h->filtered)
1286 return nd;
1287
1288 nd = rb_next(nd);
1289 }
1290
1291 return NULL;
1292 }
1293
1294 static struct rb_node *hists__filter_prev_entries(struct rb_node *nd)
1295 {
1296 while (nd != NULL) {
1297 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1298 if (!h->filtered)
1299 return nd;
1300
1301 nd = rb_prev(nd);
1302 }
1303
1304 return NULL;
1305 }
1306
1307 static void ui_browser__hists_seek(struct ui_browser *self,
1308 off_t offset, int whence)
1309 {
1310 struct hist_entry *h;
1311 struct rb_node *nd;
1312 bool first = true;
1313
1314 switch (whence) {
1315 case SEEK_SET:
1316 nd = hists__filter_entries(rb_first(self->entries));
1317 break;
1318 case SEEK_CUR:
1319 nd = self->first_visible_entry;
1320 goto do_offset;
1321 case SEEK_END:
1322 nd = hists__filter_prev_entries(rb_last(self->entries));
1323 first = false;
1324 break;
1325 default:
1326 return;
1327 }
1328
1329 /*
1330 * Moves not relative to the first visible entry invalidates its
1331 * row_offset:
1332 */
1333 h = rb_entry(self->first_visible_entry, struct hist_entry, rb_node);
1334 h->row_offset = 0;
1335
1336 /*
1337 * Here we have to check if nd is expanded (+), if it is we can't go
1338 * the next top level hist_entry, instead we must compute an offset of
1339 * what _not_ to show and not change the first visible entry.
1340 *
1341 * This offset increments when we are going from top to bottom and
1342 * decreases when we're going from bottom to top.
1343 *
1344 * As we don't have backpointers to the top level in the callchains
1345 * structure, we need to always print the whole hist_entry callchain,
1346 * skipping the first ones that are before the first visible entry
1347 * and stop when we printed enough lines to fill the screen.
1348 */
1349 do_offset:
1350 if (offset > 0) {
1351 do {
1352 h = rb_entry(nd, struct hist_entry, rb_node);
1353 if (h->ms.unfolded) {
1354 u16 remaining = h->nr_rows - h->row_offset;
1355 if (offset > remaining) {
1356 offset -= remaining;
1357 h->row_offset = 0;
1358 } else {
1359 h->row_offset += offset;
1360 offset = 0;
1361 self->first_visible_entry = nd;
1362 break;
1363 }
1364 }
1365 nd = hists__filter_entries(rb_next(nd));
1366 if (nd == NULL)
1367 break;
1368 --offset;
1369 self->first_visible_entry = nd;
1370 } while (offset != 0);
1371 } else if (offset < 0) {
1372 while (1) {
1373 h = rb_entry(nd, struct hist_entry, rb_node);
1374 if (h->ms.unfolded) {
1375 if (first) {
1376 if (-offset > h->row_offset) {
1377 offset += h->row_offset;
1378 h->row_offset = 0;
1379 } else {
1380 h->row_offset += offset;
1381 offset = 0;
1382 self->first_visible_entry = nd;
1383 break;
1384 }
1385 } else {
1386 if (-offset > h->nr_rows) {
1387 offset += h->nr_rows;
1388 h->row_offset = 0;
1389 } else {
1390 h->row_offset = h->nr_rows + offset;
1391 offset = 0;
1392 self->first_visible_entry = nd;
1393 break;
1394 }
1395 }
1396 }
1397
1398 nd = hists__filter_prev_entries(rb_prev(nd));
1399 if (nd == NULL)
1400 break;
1401 ++offset;
1402 self->first_visible_entry = nd;
1403 if (offset == 0) {
1404 /*
1405 * Last unfiltered hist_entry, check if it is
1406 * unfolded, if it is then we should have
1407 * row_offset at its last entry.
1408 */
1409 h = rb_entry(nd, struct hist_entry, rb_node);
1410 if (h->ms.unfolded)
1411 h->row_offset = h->nr_rows;
1412 break;
1413 }
1414 first = false;
1415 }
1416 } else {
1417 self->first_visible_entry = nd;
1418 h = rb_entry(nd, struct hist_entry, rb_node);
1419 h->row_offset = 0;
1420 }
1421 }
1422
1423 static int callchain_node__count_rows_rb_tree(struct callchain_node *self)
1424 {
1425 int n = 0;
1426 struct rb_node *nd;
1427
1428 for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) {
1429 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
1430 struct callchain_list *chain;
1431 char folded_sign = ' '; /* No children */
1432
1433 list_for_each_entry(chain, &child->val, list) {
1434 ++n;
1435 /* We need this because we may not have children */
1436 folded_sign = callchain_list__folded(chain);
1437 if (folded_sign == '+')
1438 break;
1439 }
1440
1441 if (folded_sign == '-') /* Have children and they're unfolded */
1442 n += callchain_node__count_rows_rb_tree(child);
1443 }
1444
1445 return n;
1446 }
1447
1448 static int callchain_node__count_rows(struct callchain_node *node)
1449 {
1450 struct callchain_list *chain;
1451 bool unfolded = false;
1452 int n = 0;
1453
1454 list_for_each_entry(chain, &node->val, list) {
1455 ++n;
1456 unfolded = chain->ms.unfolded;
1457 }
1458
1459 if (unfolded)
1460 n += callchain_node__count_rows_rb_tree(node);
1461
1462 return n;
1463 }
1464
1465 static int callchain__count_rows(struct rb_root *chain)
1466 {
1467 struct rb_node *nd;
1468 int n = 0;
1469
1470 for (nd = rb_first(chain); nd; nd = rb_next(nd)) {
1471 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
1472 n += callchain_node__count_rows(node);
1473 }
1474
1475 return n;
1476 }
1477
1478 static bool hist_browser__toggle_fold(struct hist_browser *self)
1479 {
1480 if (map_symbol__toggle_fold(self->selection)) {
1481 struct hist_entry *he = self->he_selection;
1482
1483 hist_entry__init_have_children(he);
1484 self->hists->nr_entries -= he->nr_rows;
1485
1486 if (he->ms.unfolded)
1487 he->nr_rows = callchain__count_rows(&he->sorted_chain);
1488 else
1489 he->nr_rows = 0;
1490 self->hists->nr_entries += he->nr_rows;
1491 self->b.nr_entries = self->hists->nr_entries;
1492
1493 return true;
1494 }
1495
1496 /* If it doesn't have children, no toggling performed */
1497 return false;
1498 }
1499
1500 static int hist_browser__run(struct hist_browser *self, const char *title,
1501 struct newtExitStruct *es)
1502 {
1503 char str[256], unit;
1504 unsigned long nr_events = self->hists->stats.nr_events[PERF_RECORD_SAMPLE];
1505
1506 self->b.entries = &self->hists->entries;
1507 self->b.nr_entries = self->hists->nr_entries;
1508
1509 hist_browser__refresh_dimensions(self);
1510
1511 nr_events = convert_unit(nr_events, &unit);
1512 snprintf(str, sizeof(str), "Events: %lu%c ",
1513 nr_events, unit);
1514 newtDrawRootText(0, 0, str);
1515
1516 if (ui_browser__show(&self->b, title) < 0)
1517 return -1;
1518
1519 newtFormAddHotKey(self->b.form, 'A');
1520 newtFormAddHotKey(self->b.form, 'a');
1521 newtFormAddHotKey(self->b.form, '?');
1522 newtFormAddHotKey(self->b.form, 'h');
1523 newtFormAddHotKey(self->b.form, 'H');
1524 newtFormAddHotKey(self->b.form, 'd');
1525
1526 newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
1527 newtFormAddHotKey(self->b.form, NEWT_KEY_RIGHT);
1528 newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
1529
1530 while (1) {
1531 ui_browser__run(&self->b, es);
1532
1533 if (es->reason != NEWT_EXIT_HOTKEY)
1534 break;
1535 switch (es->u.key) {
1536 case 'd': { /* Debug */
1537 static int seq;
1538 struct hist_entry *h = rb_entry(self->b.first_visible_entry,
1539 struct hist_entry, rb_node);
1540 ui_helpline__pop();
1541 ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
1542 seq++, self->b.nr_entries,
1543 self->hists->nr_entries,
1544 self->b.height,
1545 self->b.index,
1546 self->b.first_visible_entry_idx,
1547 h->row_offset, h->nr_rows);
1548 }
1549 continue;
1550 case NEWT_KEY_ENTER:
1551 if (hist_browser__toggle_fold(self))
1552 break;
1553 /* fall thru */
1554 default:
1555 return 0;
1556 }
1557 }
1558 return 0;
1559 }
This page took 0.445327 seconds and 5 git commands to generate.