summarylogtreecommitdiffstats
path: root/ui_pyroscope.patch
blob: ca58e860eb39510421ec4567b6d2b83c60cd3f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--- a/src/command_helpers.cc
+++ b/src/command_helpers.cc
@@ -57,6 +57,7 @@ void initialize_command_throttle();
 void initialize_command_tracker();
 void initialize_command_scheduler();
 void initialize_command_ui();
+void initialize_command_ui_pyroscope();
 
 void
 initialize_commands() {
@@ -75,4 +76,5 @@ initialize_commands() {
   initialize_command_throttle();
   initialize_command_tracker();
   initialize_command_scheduler();
+  initialize_command_ui_pyroscope();
 }
--- a/src/display/canvas.cc
+++ b/src/display/canvas.cc
@@ -47,6 +47,8 @@
 
 namespace display {
 
+extern void ui_pyroscope_canvas_init();
+
 bool Canvas::m_isInitialized = false;
 bool Canvas::m_isDaemon = false;
 
@@ -111,6 +113,7 @@ Canvas::initialize() {
 
   if (!m_isDaemon) {
     initscr();
+    ui_pyroscope_canvas_init();
     raw();
     noecho();
     nodelay(stdscr, TRUE);
--- a/src/display/canvas.h
+++ b/src/display/canvas.h
@@ -137,8 +137,10 @@ Canvas::print(unsigned int x, unsigned i
 
   if (!m_isDaemon) {
     va_start(arglist, str);
-    wmove(m_window, y, x);
-    vw_printw(m_window, const_cast<char*>(str), arglist);
+    if (y < height()) {
+      wmove(m_window, y, x);
+      vw_printw(m_window, const_cast<char*>(str), arglist);
+    }
     va_end(arglist);
   }
 }
--- a/src/display/window_download_list.cc
+++ b/src/display/window_download_list.cc
@@ -49,6 +49,10 @@
 
 namespace display {
 
+typedef std::pair<core::View::iterator, core::View::iterator> Range;
+bool ui_pyroscope_download_list_redraw(Window* window, display::Canvas* canvas, core::View* view);
+void ui_pyroscope_download_list_redraw_item(Window* window, display::Canvas* canvas, core::View* view, int pos, Range& range);
+
 WindowDownloadList::WindowDownloadList() :
   Window(new Canvas, 0, 120, 1, extent_full, extent_full),
   m_view(NULL) {
@@ -83,6 +87,8 @@ WindowDownloadList::redraw() {
 
   m_canvas->print(0, 0, "%s", ("[View: " + m_view->name() + (m_view->get_filter_temp().is_empty() ? "" : " (filtered)") + "]").c_str());
 
+  if (ui_pyroscope_download_list_redraw(this, m_canvas, m_view))
+    return;
   if (m_view->empty_visible() || m_canvas->width() < 5 || m_canvas->height() < 2)
     return;
 
@@ -107,8 +113,6 @@ WindowDownloadList::redraw() {
     return;
   }
 
-  typedef std::pair<core::View::iterator, core::View::iterator> Range;
-
   Range range = rak::advance_bidirectional(m_view->begin_visible(),
                                            m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(),
                                            m_view->end_visible(),
@@ -141,6 +145,7 @@ WindowDownloadList::redraw() {
       print_download_status(buffer, last, *range.first);
       m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
 
+      ui_pyroscope_download_list_redraw_item(this, m_canvas, m_view, pos, range);
       range.first++;
     }
 
@@ -150,6 +155,7 @@ WindowDownloadList::redraw() {
       m_canvas->set_default_attributes(range.first == m_view->focus() ? A_REVERSE : A_NORMAL);
       m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
 
+      ui_pyroscope_download_list_redraw_item(this, m_canvas, m_view, pos, range);
       range.first++;
     }
   }
--- a/src/display/window_statusbar.cc
+++ b/src/display/window_statusbar.cc
@@ -46,6 +46,8 @@
 
 namespace display {
 
+void ui_pyroscope_statusbar_redraw(Window* window, display::Canvas* canvas);
+
 void
 WindowStatusbar::redraw() {
   m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(1)).round_seconds());
@@ -67,6 +69,7 @@ WindowStatusbar::redraw() {
     m_canvas->print(m_canvas->width() - (position - buffer), 0, "%s", buffer);
   }
 
+  ui_pyroscope_statusbar_redraw(this, m_canvas);
   m_lastTick = control->tick();
 }
 
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -189,6 +189,7 @@ libsub_root_a_SOURCES = \
 	thread_base.cc \
 	thread_base.h \
 	thread_worker.cc \
-	thread_worker.h
+	thread_worker.h \
+	ui_pyroscope.cc
 
 AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir)