mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-19 07:36:16 +00:00
Up and down on the download list working.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@250 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -50,4 +50,5 @@ AC_OUTPUT([
|
|||||||
src/core/Makefile
|
src/core/Makefile
|
||||||
src/display/Makefile
|
src/display/Makefile
|
||||||
src/input/Makefile
|
src/input/Makefile
|
||||||
|
src/ui/Makefile
|
||||||
])
|
])
|
||||||
|
|||||||
+3
-1
@@ -1,11 +1,13 @@
|
|||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
core \
|
core \
|
||||||
display \
|
display \
|
||||||
input
|
input \
|
||||||
|
ui
|
||||||
|
|
||||||
bin_PROGRAMS = rtorrent
|
bin_PROGRAMS = rtorrent
|
||||||
|
|
||||||
rtorrent_LDADD = \
|
rtorrent_LDADD = \
|
||||||
|
$(top_srcdir)/src/ui/libsub_ui.a \
|
||||||
$(top_srcdir)/src/core/libsub_core.a \
|
$(top_srcdir)/src/core/libsub_core.a \
|
||||||
$(top_srcdir)/src/display/libsub_display.a \
|
$(top_srcdir)/src/display/libsub_display.a \
|
||||||
$(top_srcdir)/src/input/libsub_input.a
|
$(top_srcdir)/src/input/libsub_input.a
|
||||||
|
|||||||
+7
-2
@@ -1,6 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <sigc++/bind.h>
|
#include <sigc++/bind.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
@@ -34,9 +35,13 @@ Poll::poll() {
|
|||||||
|
|
||||||
m_maxFd = select(m_maxFd, &m_readSet, &m_writeSet, &m_exceptSet, &timeout);
|
m_maxFd = select(m_maxFd, &m_readSet, &m_writeSet, &m_exceptSet, &timeout);
|
||||||
|
|
||||||
if (m_maxFd == EINTR)
|
if (m_maxFd >= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
else if (errno == EINTR)
|
||||||
m_slotSelectInterrupted();
|
m_slotSelectInterrupted();
|
||||||
else if (m_maxFd < 0)
|
|
||||||
|
else if (errno < 0)
|
||||||
throw std::runtime_error("Poll::work(): select error");
|
throw std::runtime_error("Poll::work(): select error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,16 @@ _accumulate<Type, Ftor> accumulate(Type& t, Ftor f) {
|
|||||||
return _accumulate<Type, Ftor>(t, f);
|
return _accumulate<Type, Ftor>(t, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Manager::iterator
|
||||||
|
Manager::erase(Window* w) {
|
||||||
|
iterator itr = std::find(begin(), end(), w);
|
||||||
|
|
||||||
|
if (itr == end())
|
||||||
|
throw std::logic_error("Manager::erase(...) did not find the window");
|
||||||
|
|
||||||
|
return Base::erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Manager::adjust_layout() {
|
Manager::adjust_layout() {
|
||||||
int countDynamic = 0;
|
int countDynamic = 0;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#ifndef RTORRENT_DISPLAY_MANAGER_H
|
#ifndef RTORRENT_DISPLAY_MANAGER_H
|
||||||
#define RTORRENT_DISPLAY_MANAGER_H
|
#define RTORRENT_DISPLAY_MANAGER_H
|
||||||
|
|
||||||
#include <vector>
|
#include <list>
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
|
|
||||||
class Manager : private std::vector<Window*> {
|
class Manager : private std::list<Window*> {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<Window*> Base;
|
typedef std::list<Window*> Base;
|
||||||
|
|
||||||
using Base::iterator;
|
using Base::iterator;
|
||||||
using Base::const_iterator;
|
using Base::const_iterator;
|
||||||
@@ -23,8 +23,11 @@ public:
|
|||||||
|
|
||||||
using Base::insert;
|
using Base::insert;
|
||||||
using Base::erase;
|
using Base::erase;
|
||||||
|
using Base::push_front;
|
||||||
using Base::push_back;
|
using Base::push_back;
|
||||||
|
|
||||||
|
iterator erase(Window* w);
|
||||||
|
|
||||||
void adjust_layout();
|
void adjust_layout();
|
||||||
void do_update();
|
void do_update();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ public:
|
|||||||
|
|
||||||
WindowDownloadList(List* d);
|
WindowDownloadList(List* d);
|
||||||
|
|
||||||
List::iterator get_focus() { return m_focus; }
|
List* get_list() { return m_downloads; }
|
||||||
|
|
||||||
|
List::iterator get_focus() { return m_focus; }
|
||||||
void set_focus(core::DownloadList::iterator itr) { m_focus = itr; }
|
void set_focus(core::DownloadList::iterator itr) { m_focus = itr; }
|
||||||
|
|
||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowTitle::WindowTitle() :
|
WindowTitle::WindowTitle() :
|
||||||
Window(new Canvas, false, 1) {
|
Window(new Canvas, false, 1),
|
||||||
|
m_counter(0) {
|
||||||
|
|
||||||
m_title += "rtorrent " VERSION " - ";
|
m_title += "rtorrent " VERSION " - ";
|
||||||
m_title += torrent::get(torrent::LIBRARY_NAME);
|
m_title += torrent::get(torrent::LIBRARY_NAME);
|
||||||
@@ -16,10 +17,11 @@ WindowTitle::WindowTitle() :
|
|||||||
|
|
||||||
void
|
void
|
||||||
WindowTitle::redraw() {
|
WindowTitle::redraw() {
|
||||||
|
m_counter++;
|
||||||
|
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
|
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
|
||||||
"*** %s ***", m_title.c_str());
|
"*** %s *** %i", m_title.c_str(), m_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef RTORRENT_DISPLAY_WINDOW_TITLE_H
|
#ifndef RTORRENT_DISPLAY_WINDOW_TITLE_H
|
||||||
#define RTORRENT_DISPLAY_WINDOW_TITLE_H
|
#define RTORRENT_DISPLAY_WINDOW_TITLE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
@@ -13,6 +14,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_title;
|
std::string m_title;
|
||||||
|
|
||||||
|
int m_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ namespace input {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Bindings::pressed(int key) {
|
Bindings::pressed(int key) {
|
||||||
|
if (!m_active)
|
||||||
|
return false;
|
||||||
|
|
||||||
const_iterator itr = find(key);
|
const_iterator itr = find(key);
|
||||||
|
|
||||||
if (itr != end())
|
if (itr != end())
|
||||||
|
|||||||
+10
-1
@@ -2,6 +2,7 @@
|
|||||||
#define RTORRENT_INPUT_BINDINGS_H
|
#define RTORRENT_INPUT_BINDINGS_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ncurses.h>
|
||||||
#include <sigc++/slot.h>
|
#include <sigc++/slot.h>
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
@@ -23,7 +24,15 @@ public:
|
|||||||
|
|
||||||
using Base::operator[];
|
using Base::operator[];
|
||||||
|
|
||||||
bool pressed(int key);
|
Bindings() : m_active(true) {}
|
||||||
|
|
||||||
|
void activate() { m_active = true; }
|
||||||
|
void disable() { m_active = false; }
|
||||||
|
|
||||||
|
bool pressed(int key);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,23 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
#include "bindings.h"
|
#include "bindings.h"
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
|
|
||||||
|
void
|
||||||
|
Manager::erase(Bindings* b) {
|
||||||
|
iterator itr = std::find(begin(), end(), b);
|
||||||
|
|
||||||
|
if (itr == end())
|
||||||
|
throw std::logic_error("Manager::erase(...) could not find binding");
|
||||||
|
|
||||||
|
Base::erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Manager::pressed(int key) {
|
Manager::pressed(int key) {
|
||||||
std::find_if(begin(), end(), std::bind2nd(std::mem_fun(&Bindings::pressed), key));
|
std::find_if(begin(), end(), std::bind2nd(std::mem_fun(&Bindings::pressed), key));
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public:
|
|||||||
using Base::push_back;
|
using Base::push_back;
|
||||||
using Base::push_front;
|
using Base::push_front;
|
||||||
|
|
||||||
|
void erase(Bindings* b);
|
||||||
|
|
||||||
void pressed(int key);
|
void pressed(int key);
|
||||||
|
|
||||||
// Slot for unreacted keys.
|
// Slot for unreacted keys.
|
||||||
|
|||||||
+9
-14
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include "input/bindings.h"
|
#include "input/bindings.h"
|
||||||
#include "input/manager.h"
|
#include "input/manager.h"
|
||||||
|
#include "ui/control.h"
|
||||||
|
#include "ui/download_list.h"
|
||||||
|
|
||||||
#include "signal_handler.h"
|
#include "signal_handler.h"
|
||||||
|
|
||||||
@@ -24,9 +26,6 @@ bool is_shutting_down = false;
|
|||||||
core::Poll poll;
|
core::Poll poll;
|
||||||
core::DownloadList downloads;
|
core::DownloadList downloads;
|
||||||
|
|
||||||
display::Manager displayManager;
|
|
||||||
input::Manager inputManager;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_shutdown() {
|
set_shutdown() {
|
||||||
start_shutdown = true;
|
start_shutdown = true;
|
||||||
@@ -51,16 +50,14 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
display::Canvas::init();
|
display::Canvas::init();
|
||||||
|
|
||||||
inputManager.push_back(new input::Bindings);
|
ui::Control uiControl;
|
||||||
|
ui::DownloadList uiDownloadList(&downloads, &uiControl);
|
||||||
|
|
||||||
poll.slot_read_stdin(sigc::mem_fun(inputManager, &input::Manager::pressed));
|
uiDownloadList.activate();
|
||||||
|
|
||||||
|
poll.slot_read_stdin(sigc::mem_fun(uiControl.get_input(), &input::Manager::pressed));
|
||||||
poll.register_http();
|
poll.register_http();
|
||||||
|
|
||||||
display::WindowDownloadList* wdl = new display::WindowDownloadList(&downloads);
|
|
||||||
|
|
||||||
displayManager.push_back(new display::WindowTitle);
|
|
||||||
displayManager.push_back(wdl);
|
|
||||||
|
|
||||||
torrent::initialize();
|
torrent::initialize();
|
||||||
torrent::listen_open(6880, 6999);
|
torrent::listen_open(6880, 6999);
|
||||||
|
|
||||||
@@ -71,8 +68,6 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
itr->open();
|
itr->open();
|
||||||
itr->hash_check();
|
itr->hash_check();
|
||||||
|
|
||||||
wdl->set_focus(itr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalHandler::set_handler(SIGINT, sigc::ptr_fun(&set_shutdown));
|
SignalHandler::set_handler(SIGINT, sigc::ptr_fun(&set_shutdown));
|
||||||
@@ -81,8 +76,8 @@ main(int argc, char** argv) {
|
|||||||
if (start_shutdown && !is_shutting_down)
|
if (start_shutdown && !is_shutting_down)
|
||||||
do_shutdown();
|
do_shutdown();
|
||||||
|
|
||||||
displayManager.adjust_layout();
|
uiControl.get_display().adjust_layout();
|
||||||
displayManager.do_update();
|
uiControl.get_display().do_update();
|
||||||
|
|
||||||
poll.poll();
|
poll.poll();
|
||||||
poll.work();
|
poll.work();
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef RTORRENT_UI_CONTROL_H
|
||||||
|
#define RTORRENT_UI_CONTROL_H
|
||||||
|
|
||||||
|
#include "display/manager.h"
|
||||||
|
#include "input/manager.h"
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
class Control {
|
||||||
|
public:
|
||||||
|
|
||||||
|
display::Manager& get_display() { return m_display; }
|
||||||
|
input::Manager& get_input() { return m_input; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
display::Manager m_display;
|
||||||
|
input::Manager m_input;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user