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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
diff --git a/src/command_network.cc b/src/command_network.cc
index 2494988..7b105ca 100644
--- a/src/command_network.cc
+++ b/src/command_network.cc
@@ -560,4 +560,8 @@ initialize_command_network() {
// Not really network stuff:
ADD_VARIABLE_BOOL ("handshake_log", false);
ADD_VARIABLE_STRING("log.tracker", "");
+ ADD_COMMAND_VALUE_TRI("done_fg_color", rak::make_mem_fun(control->ui(), &ui::Root::set_done_fg_color), rak::make_mem_fun(control->ui(), &ui::Root::get_done_fg_color));
+ ADD_COMMAND_VALUE_TRI("done_bg_color", rak::make_mem_fun(control->ui(), &ui::Root::set_done_bg_color), rak::make_mem_fun(control->ui(), &ui::Root::get_done_bg_color));
+ ADD_COMMAND_VALUE_TRI("active_fg_color", rak::make_mem_fun(control->ui(), &ui::Root::set_active_fg_color), rak::make_mem_fun(control->ui(), &ui::Root::get_active_fg_color));
+ ADD_COMMAND_VALUE_TRI("active_bg_color", rak::make_mem_fun(control->ui(), &ui::Root::set_active_bg_color), rak::make_mem_fun(control->ui(), &ui::Root::get_active_bg_color));
}
diff --git a/src/display/canvas.cc b/src/display/canvas.cc
index 4e621df..0c97eea 100644
--- a/src/display/canvas.cc
+++ b/src/display/canvas.cc
@@ -92,6 +92,10 @@ Canvas::initialize() {
m_isInitialized = true;
initscr();
+ start_color();
+ use_default_colors();
+ init_pair(2, -1, -1);
+ init_pair(1, -1, -1);
raw();
noecho();
nodelay(stdscr, TRUE);
diff --git a/src/display/window_download_list.cc b/src/display/window_download_list.cc
index 71efec0..06e7cd4 100644
--- a/src/display/window_download_list.cc
+++ b/src/display/window_download_list.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include <rak/algorithm.h>
+#include <torrent/rate.h>
#include "core/download.h"
#include "core/view.h"
@@ -96,12 +97,30 @@ WindowDownloadList::redraw() {
char* position;
char* last = buffer + m_canvas->width() - 2 + 1;
+ if( pos >= m_canvas->height() ) break;
position = print_download_title(buffer, last, *range.first);
- m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
+ m_canvas->print(0, pos, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
+ if( (*range.first)->is_done() ) {
+ if( (*range.first)->download()->up_rate()->rate() != 0 ) {
+ m_canvas->set_attr(0, pos, m_canvas->width()-1, A_BOLD, 2);
+ } else {
+ m_canvas->set_attr(0, pos, m_canvas->width()-1, A_NORMAL, 2);
+ }
+ } else if( (*range.first)->download()->is_active() ) {
+ if( (*range.first)->download()->down_rate()->rate() != 0 ) {
+ m_canvas->set_attr(0, pos, m_canvas->width()-1, A_BOLD, 1);
+ } else {
+ m_canvas->set_attr(0, pos, m_canvas->width()-1, A_NORMAL, 1);
+ }
+ }
+ pos++;
+ if( pos >= m_canvas->height() ) break;
+
position = print_download_info(buffer, last, *range.first);
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
+ if( pos >= m_canvas->height() ) break;
position = print_download_status(buffer, last, *range.first);
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
@@ -109,4 +128,40 @@ WindowDownloadList::redraw() {
}
}
+void
+WindowDownloadList::set_done_fg_color(int64_t color) {
+ short fg, bg;
+ pair_content(2, &fg, &bg);
+ if( color < 0 ) color = -1;
+ color = color % 8;
+ init_pair(2, (short)color, bg);
+}
+
+void
+WindowDownloadList::set_done_bg_color(int64_t color) {
+ short fg, bg;
+ pair_content(2, &fg, &bg);
+ if( color < 0 ) color = -1;
+ color = color % 8;
+ init_pair(2, fg, (short)color);
+}
+
+void
+WindowDownloadList::set_active_fg_color(int64_t color) {
+ short fg, bg;
+ pair_content(1, &fg, &bg);
+ if( color < 0 ) color = -1;
+ color = color % 8;
+ init_pair(1, (short)color, bg);
+}
+
+void
+WindowDownloadList::set_active_bg_color(int64_t color) {
+ short fg, bg;
+ pair_content(1, &fg, &bg);
+ if( color < 0 ) color = -1;
+ color = color % 8;
+ init_pair(1, fg, (short)color);
+}
+
}
diff --git a/src/display/window_download_list.h b/src/display/window_download_list.h
index 4ce5ea1..313e87b 100644
--- a/src/display/window_download_list.h
+++ b/src/display/window_download_list.h
@@ -59,6 +59,10 @@ public:
virtual void redraw();
void set_view(core::View* l);
+ void set_done_fg_color(int64_t color);
+ void set_done_bg_color(int64_t color);
+ void set_active_fg_color(int64_t color);
+ void set_active_bg_color(int64_t color);
private:
core::View* m_view;
diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc
index b7d6983..e72bff6 100644
--- a/src/ui/download_list.cc
+++ b/src/ui/download_list.cc
@@ -137,6 +137,11 @@ DownloadList::unfocus_download(core::Download* d) {
current_view()->next_focus();
}
+display::WindowDownloadList*
+DownloadList::current_window_list() {
+ return dynamic_cast<ElementDownloadList*>(m_uiArray[DISPLAY_DOWNLOAD_LIST])->window();
+}
+
void
DownloadList::activate_display(Display displayType) {
if (!is_active())
diff --git a/src/ui/download_list.h b/src/ui/download_list.h
index dda1b34..11137fa 100644
--- a/src/ui/download_list.h
+++ b/src/ui/download_list.h
@@ -101,6 +101,7 @@ public:
void activate_display(Display d);
core::View* current_view();
+ display::WindowDownloadList* current_window_list();
void set_current_view(const std::string& name);
void slot_open_uri(SlotOpenUri s) { m_slotOpenUri = s; }
diff --git a/src/ui/element_download_list.h b/src/ui/element_download_list.h
index ed5de30..7c0fb9d 100644
--- a/src/ui/element_download_list.h
+++ b/src/ui/element_download_list.h
@@ -60,6 +60,7 @@ public:
void disable();
core::View* view() { return m_view; }
+ WDownloadList* window() { return m_window; }
void set_view(core::View* l);
void receive_command(const char* cmd);
diff --git a/src/ui/root.cc b/src/ui/root.cc
index b01f4ed..d344718 100644
--- a/src/ui/root.cc
+++ b/src/ui/root.cc
@@ -44,6 +44,7 @@
#include "core/manager.h"
#include "display/frame.h"
+#include "display/window_download_list.h"
#include "display/window_http_queue.h"
#include "display/window_title.h"
#include "display/window_input.h"
@@ -65,7 +66,11 @@ Root::Root() :
m_windowTitle(NULL),
m_windowHttpQueue(NULL),
m_windowInput(NULL),
- m_windowStatusbar(NULL) {
+ m_windowStatusbar(NULL),
+ done_fg_color(-1),
+ done_bg_color(-1),
+ active_fg_color(-1),
+ active_bg_color(-1) {
}
void
@@ -97,6 +102,10 @@ Root::init(Control* c) {
setup_keys();
m_downloadList->activate(rootFrame->frame(1));
+ m_downloadList->current_window_list()->set_done_fg_color(done_fg_color);
+ m_downloadList->current_window_list()->set_done_bg_color(done_bg_color);
+ m_downloadList->current_window_list()->set_active_fg_color(active_fg_color);
+ m_downloadList->current_window_list()->set_active_bg_color(active_bg_color);
}
void
@@ -219,6 +228,46 @@ Root::set_up_throttle(unsigned int throttle) {
torrent::set_max_unchoked(maxUnchoked);
}
+int
+Root::get_done_fg_color() {
+ return done_fg_color;
+}
+
+void
+Root::set_done_fg_color(int64_t color) {
+ done_fg_color = color;
+}
+
+int
+Root::get_done_bg_color() {
+ return done_bg_color;
+}
+
+void
+Root::set_done_bg_color(int64_t color) {
+ done_bg_color = color;
+}
+
+int
+Root::get_active_fg_color() {
+ return active_fg_color;
+}
+
+void
+Root::set_active_fg_color(int64_t color) {
+ active_fg_color = color;
+}
+
+int
+Root::get_active_bg_color() {
+ return active_bg_color;
+}
+
+void
+Root::set_active_bg_color(int64_t color) {
+ active_bg_color = color;
+}
+
void
Root::adjust_down_throttle(int throttle) {
set_down_throttle(std::max<int>(torrent::down_throttle_global()->max_rate() / 1024 + throttle, 0));
diff --git a/src/ui/root.h b/src/ui/root.h
index e9a7907..4eef1df 100644
--- a/src/ui/root.h
+++ b/src/ui/root.h
@@ -83,6 +83,15 @@ public:
void set_down_throttle_i64(int64_t throttle) { set_down_throttle(throttle >> 10); }
void set_up_throttle_i64(int64_t throttle) { set_up_throttle(throttle >> 10); }
+ int get_done_fg_color();
+ void set_done_fg_color(int64_t color);
+ int get_done_bg_color();
+ void set_done_bg_color(int64_t color);
+ int get_active_fg_color();
+ void set_active_fg_color(int64_t color);
+ int get_active_bg_color();
+ void set_active_bg_color(int64_t color);
+
void adjust_down_throttle(int throttle);
void adjust_up_throttle(int throttle);
@@ -105,6 +114,10 @@ private:
WStatusbar* m_windowStatusbar;
input::Bindings m_bindings;
+ int64_t done_fg_color;
+ int64_t done_bg_color;
+ int64_t active_fg_color;
+ int64_t active_bg_color;
};
}
|