From 1f58b0074ba04b3a303a3f0580213b1f713e9792 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Mon, 14 Feb 2005 18:24:21 +0000 Subject: [PATCH] Hooked the input to the torrent loader. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@274 e378c898-3ddf-0310-93e7-cc216c733640 --- configure.ac | 4 ++-- src/input/text_input.cc | 42 +++++++++++++++++++++++++---------------- src/input/text_input.h | 8 +++++--- src/main.cc | 1 + src/ui/download_list.cc | 2 ++ src/ui/download_list.h | 22 ++++++++++++++------- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index 7956e8da..44a724b9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(rtorrent, 0.0.0, jaris@ifi.uio.no) +AC_INIT(rtorrent, 0.0.1, jaris@ifi.uio.no) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) @@ -39,7 +39,7 @@ TORRENT_CHECK_EXECINFO() TORRENT_CHECK_CURL() TORRENT_OTFD() -PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.4.8, +PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.4.9, CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS"; LIBS="$LIBS $STUFF_LIBS $CURL_LIBS") diff --git a/src/input/text_input.cc b/src/input/text_input.cc index 9b9206ca..1e24b72e 100644 --- a/src/input/text_input.cc +++ b/src/input/text_input.cc @@ -9,13 +9,19 @@ namespace input { bool TextInput::pressed(int key) { +// std::stringstream str; + if (m_alt) { m_alt = false; switch (key) { - case 'p': - Base::insert(m_pos, "M^p"); - break; +// case 'b': +// Base::insert(m_pos, "M^b"); +// break; + +// case 'f': +// Base::insert(m_pos, "M^f"); +// break; default: return false; @@ -52,8 +58,25 @@ TextInput::pressed(int key) { break; + case 0x1B: + m_alt = true; + + break; + default: return false; + + // Testcode. +// if (key == KEY_ENTER || key == '\n') +// return false; + +// str << "\\x" << std::hex << key; + +// Base::insert(m_pos, str.str()); + +// m_pos += str.str().length(); + +// return true; } } @@ -61,19 +84,6 @@ TextInput::pressed(int key) { return true; - // Testcode. -// if (key == KEY_ENTER || key == '\n') -// return false; - -// std::stringstream str; - -// str << "\\x" << std::hex << key; - -// Base::insert(m_pos, str.str()); - -// m_pos += str.str().length(); - -// return true; } } diff --git a/src/input/text_input.h b/src/input/text_input.h index 099c6416..41b09ee9 100644 --- a/src/input/text_input.h +++ b/src/input/text_input.h @@ -17,13 +17,15 @@ public: TextInput() : m_pos(0), m_alt(false) {} - size_type get_pos() { return m_pos; } + size_type get_pos() { return m_pos; } bool pressed(int key); - void clear() { m_pos = 0; m_alt = false; Base::clear(); } + void clear() { m_pos = 0; m_alt = false; Base::clear(); } - void slot_dirty(SlotDirty s) { m_slotDirty = s; } + void slot_dirty(SlotDirty s) { m_slotDirty = s; } + + const std::string& str() { return *this; } private: size_type m_pos; diff --git a/src/main.cc b/src/main.cc index 13519cd6..72fe0cc0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -110,6 +110,7 @@ main(int argc, char** argv) { ui::DownloadList uiDownloadList(&coreManager.get_download_list(), &uiControl); uiDownloadList.activate(); + uiDownloadList.slot_open_uri(sigc::mem_fun(coreManager, &core::Manager::insert)); // Register main key events. input::Bindings inputMain; diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index e148e194..35c6430e 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -133,6 +133,8 @@ void DownloadList::receive_exit_input() { m_control->get_input().set_text_input(); + m_slotOpenUri(m_windowInput->get_input()->str()); + m_windowInput->get_input()->clear(); m_windowInput->set_focus(false); diff --git a/src/ui/download_list.h b/src/ui/download_list.h index 4fa488c3..d4e22e1a 100644 --- a/src/ui/download_list.h +++ b/src/ui/download_list.h @@ -1,6 +1,8 @@ #ifndef RTORRENT_UI_DOWNLOAD_LIST_H #define RTORRENT_UI_DOWNLOAD_LIST_H +#include + namespace display { class WindowTitle; class WindowDownloadList; @@ -15,22 +17,26 @@ class Download; class DownloadList { public: - typedef display::WindowDownloadList WList; - typedef display::WindowTitle WTitle; - typedef display::WindowStatusbar WStatus; - typedef display::WindowInput WInput; - typedef core::DownloadList DList; + typedef display::WindowDownloadList WList; + typedef display::WindowTitle WTitle; + typedef display::WindowStatusbar WStatus; + typedef display::WindowInput WInput; + typedef core::DownloadList DList; + + typedef sigc::slot1 SlotOpenUri; // We own 'window'. DownloadList(DList* l, Control* c); ~DownloadList(); - WList& get_window() { return *m_window; } - input::Bindings& get_bindings() { return *m_bindings; } + WList& get_window() { return *m_window; } + input::Bindings& get_bindings() { return *m_bindings; } void activate(); void disable(); + void slot_open_uri(SlotOpenUri s) { m_slotOpenUri = s; } + private: DownloadList(const DownloadList&); void operator = (const DownloadList&); @@ -62,6 +68,8 @@ private: Control* m_control; input::Bindings* m_bindings; + SlotOpenUri m_slotOpenUri; + // Test WInput* m_windowInput; };