mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
Work on an input field.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@272 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -11,6 +11,8 @@ libsub_display_a_SOURCES = \
|
||||
window_download_statusbar.h \
|
||||
window_download_list.cc \
|
||||
window_download_list.h \
|
||||
window_input.cc \
|
||||
window_input.h \
|
||||
window_peer_info.cc \
|
||||
window_peer_info.h \
|
||||
window_peer_list.cc \
|
||||
|
||||
+12
-9
@@ -23,6 +23,7 @@ public:
|
||||
int get_y() { int x, y; getyx(m_window, y, x); return y; }
|
||||
int get_width() { int x, y; getmaxyx(m_window, y, x); return x; }
|
||||
int get_height() { int x, y; getmaxyx(m_window, y, x); return y; }
|
||||
|
||||
chtype get_background() { return getbkgd(m_window); }
|
||||
void set_background(chtype c) { return wbkgdset(m_window, c); }
|
||||
|
||||
@@ -33,15 +34,6 @@ public:
|
||||
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>
|
||||
@@ -66,6 +58,17 @@ public:
|
||||
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); }
|
||||
|
||||
void set_attr(int x, int y, int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
|
||||
|
||||
// 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(); }
|
||||
|
||||
private:
|
||||
Canvas(const Canvas&);
|
||||
void operator = (const Canvas&);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace display {
|
||||
|
||||
WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
|
||||
Window(new Canvas, false, 2),
|
||||
Window(new Canvas, false, 3),
|
||||
m_download(d) {
|
||||
}
|
||||
|
||||
@@ -36,7 +36,14 @@ WindowDownloadStatusbar::redraw() {
|
||||
(double)m_download->get_download().get_rate_down() / 1024.0,
|
||||
(double)m_download->get_download().get_bytes_up() / (double)(1 << 20));
|
||||
|
||||
m_canvas->print(0, 1, "Tracker: [%c:%i] %s",
|
||||
m_canvas->print(0, 1, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i",
|
||||
(int)m_download->get_download().get_peers_connected(),
|
||||
(int)m_download->get_download().get_peers_not_connected(),
|
||||
(int)m_download->get_download().get_peers_min(),
|
||||
(int)m_download->get_download().get_peers_max(),
|
||||
(int)m_download->get_download().get_uploads_max());
|
||||
|
||||
m_canvas->print(0, 2, "Tracker: [%c:%i] %s",
|
||||
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
|
||||
(int)(m_download->get_download().get_tracker_timeout() / 1000000),
|
||||
m_download->get_tracker_msg().c_str());
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "canvas.h"
|
||||
#include "window_input.h"
|
||||
|
||||
#include "input/text_input.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowInput::WindowInput(input::TextInput* input) :
|
||||
Window(new Canvas, false, 1),
|
||||
m_input(input),
|
||||
m_focus(false) {
|
||||
}
|
||||
|
||||
void
|
||||
WindowInput::redraw() {
|
||||
if (!is_dirty())
|
||||
return;
|
||||
|
||||
m_lastDraw = Timer::cache();
|
||||
m_canvas->erase();
|
||||
|
||||
m_canvas->print(0, 0, "> %s", m_input->c_str());
|
||||
|
||||
if (m_focus)
|
||||
m_canvas->set_attr(m_input->get_pos() + 2, 0, 1, A_REVERSE, COLOR_PAIR(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_INPUT_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_INPUT_H
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace input {
|
||||
class TextInput;
|
||||
}
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowInput : public Window {
|
||||
public:
|
||||
WindowInput(input::TextInput* input);
|
||||
|
||||
input::TextInput* get_input() { return m_input; }
|
||||
|
||||
bool get_focus() { return m_focus; }
|
||||
void set_focus(bool f) { mark_dirty(); m_focus = f; }
|
||||
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
input::TextInput* m_input;
|
||||
bool m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -33,14 +33,14 @@ WindowPeerInfo::redraw() {
|
||||
m_download->get_download().get_chunks_total(),
|
||||
m_download->get_download().get_chunks_size());
|
||||
|
||||
y++;
|
||||
|
||||
if (*m_focus == m_list->end()) {
|
||||
m_canvas->print(0, y++, "No peer in focus");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
y++;
|
||||
|
||||
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->get_dns().c_str(), (*m_focus)->get_port());
|
||||
m_canvas->print(0, y++, "Id: %s" , escape_string((*m_focus)->get_id()).c_str());
|
||||
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->get_snubbed() ? "Yes" : "No");
|
||||
|
||||
@@ -12,7 +12,12 @@ WindowTitle::WindowTitle(const std::string& s) :
|
||||
|
||||
void
|
||||
WindowTitle::redraw() {
|
||||
if (Timer::cache() - m_lastDraw < 10000000)
|
||||
return;
|
||||
|
||||
m_lastDraw = Timer::cache();
|
||||
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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user