mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-16 23:22:31 +00:00
Signal handler with cleaner shutdown.
Window title and stuff. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@248 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -8,6 +8,8 @@ libsub_display_a_SOURCES = \
|
||||
window.cc \
|
||||
window.h \
|
||||
window_download_list.cc \
|
||||
window_download_list.h
|
||||
window_download_list.h \
|
||||
window_title.cc \
|
||||
window_title.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
|
||||
+20
-12
@@ -27,6 +27,20 @@ public:
|
||||
|
||||
void erase() { werase(m_window); }
|
||||
|
||||
void print_border(chtype ls, chtype rs,
|
||||
chtype ts, chtype bs,
|
||||
chtype tl, chtype tr,
|
||||
chtype bl, chtype br) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); }
|
||||
|
||||
// Initialize stdscr.
|
||||
static void init();
|
||||
static void cleanup();
|
||||
|
||||
static int get_screen_width() { int x, y; getmaxyx(stdscr, y, x); return x; }
|
||||
static int get_screen_height() { int x, y; getmaxyx(stdscr, y, x); return y; }
|
||||
|
||||
static void do_update() { doupdate(); }
|
||||
|
||||
void print(int x, int y, const char* str) { mvwprintw(m_window, y, x, str); }
|
||||
|
||||
template <typename A1>
|
||||
@@ -43,19 +57,13 @@ public:
|
||||
void print(int x, int y, const char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4); }
|
||||
|
||||
void print_border(chtype ls, chtype rs,
|
||||
chtype ts, chtype bs,
|
||||
chtype tl, chtype tr,
|
||||
chtype bl, chtype br) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); }
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
void print(int x, int y, const char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5); }
|
||||
|
||||
// Initialize stdscr.
|
||||
static void init();
|
||||
static void cleanup();
|
||||
|
||||
static int get_screen_width() { int x, y; getmaxyx(stdscr, y, x); return x; }
|
||||
static int get_screen_height() { int x, y; getmaxyx(stdscr, y, x); return y; }
|
||||
|
||||
static void do_update() { doupdate(); }
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
void print(int x, int y, const char* str,
|
||||
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6); }
|
||||
|
||||
private:
|
||||
WINDOW* m_window;
|
||||
|
||||
@@ -38,10 +38,13 @@ Manager::adjust_layout() {
|
||||
int height = 0, h;
|
||||
|
||||
for (iterator itr = begin(); itr != end(); ++itr, height += h) {
|
||||
h = (*itr)->is_dynamic() ? ((dynamic + countDynamic - 1) / countDynamic) : 0;
|
||||
|
||||
countDynamic--;
|
||||
dynamic -= h;
|
||||
if ((*itr)->is_dynamic()) {
|
||||
dynamic -= h = (dynamic + countDynamic - 1) / countDynamic;
|
||||
countDynamic--;
|
||||
} else {
|
||||
h = 0;
|
||||
}
|
||||
|
||||
h += (*itr)->get_min_height();
|
||||
|
||||
|
||||
@@ -19,12 +19,36 @@ WindowDownloadList::redraw() {
|
||||
|
||||
int pos = 1;
|
||||
|
||||
for (engine::DownloadList::iterator itr = m_downloads->begin(); itr != m_downloads->end(); ++itr, ++pos)
|
||||
m_canvas->print(1, pos, "Download: %s Open: %c Tracker: %c Active: %c",
|
||||
itr->get_download().get_name().c_str(),
|
||||
itr->get_download().is_open() ? 'Y' : 'N',
|
||||
itr->get_download().is_tracker_busy() ? 'Y' : 'N',
|
||||
itr->get_download().is_active() ? 'Y' : 'N');
|
||||
// Remember to check for end of screen too.
|
||||
|
||||
for (engine::DownloadList::iterator itr = m_downloads->begin(); itr != m_downloads->end(); ++itr) {
|
||||
m_canvas->print(0, pos++, "%c %s",
|
||||
false ? '*' : ' ',
|
||||
itr->get_download().get_name().c_str());
|
||||
|
||||
if (itr->get_download().get_chunks_done() != itr->get_download().get_chunks_total() || !itr->get_download().is_open())
|
||||
m_canvas->print(0, pos++, "%c Torrent: %.1f / %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
|
||||
false ? '*' : ' ',
|
||||
(double)itr->get_download().get_bytes_done() / (double)(1 << 20),
|
||||
(double)itr->get_download().get_bytes_total() / (double)(1 << 20),
|
||||
(double)itr->get_download().get_rate_up() / 1024.0,
|
||||
(double)itr->get_download().get_rate_down() / 1024.0,
|
||||
(double)itr->get_download().get_bytes_up() / (double)(1 << 20));
|
||||
|
||||
else
|
||||
m_canvas->print(0, pos++, "%c Torrent: Done %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
|
||||
false ? '*' : ' ',
|
||||
(double)itr->get_download().get_bytes_total() / (double)(1 << 20),
|
||||
(double)itr->get_download().get_rate_up() / 1024.0,
|
||||
(double)itr->get_download().get_rate_down() / 1024.0,
|
||||
(double)itr->get_download().get_bytes_up() / (double)(1 << 20));
|
||||
|
||||
m_canvas->print(0, pos++, "%c Tracker: [%c:%i] %s",
|
||||
false ? '*' : ' ',
|
||||
itr->get_download().is_tracker_busy() ? 'C' : ' ',
|
||||
(int)(itr->get_download().get_tracker_timeout() / 1000000),
|
||||
"");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class WindowDownloadList : public Window {
|
||||
public:
|
||||
WindowDownloadList(engine::DownloadList* d);
|
||||
|
||||
virtual void redraw();
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
engine::DownloadList* m_downloads;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "canvas.h"
|
||||
#include "window_title.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowTitle::WindowTitle() :
|
||||
Window(new Canvas, false, 1) {
|
||||
|
||||
m_title += "rtorrent " VERSION " - ";
|
||||
m_title += torrent::get(torrent::LIBRARY_NAME);
|
||||
}
|
||||
|
||||
void
|
||||
WindowTitle::redraw() {
|
||||
m_canvas->erase();
|
||||
|
||||
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
|
||||
"*** %s ***", m_title.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_TITLE_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_TITLE_H
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowTitle : public Window {
|
||||
public:
|
||||
WindowTitle();
|
||||
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
std::string m_title;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user