Proper '/' on the end of directories in the find-file window.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@381 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-04-03 16:36:19 +00:00
parent fe11d1936d
commit 874e46fc64
15 changed files with 216 additions and 24 deletions
+2 -6
View File
@@ -24,10 +24,6 @@ Make accumulate return the value, no refs please...
> slow or broken or for various reasons you don't want to download it.
Const cast problems?
Make sure it gracefully handles torrents that fail to open files.
std::tm *u = std::localtime(&t.tval().tv_sec);
Let us see the torrent comment.
Why is the client lagging when downloading a http torrent? Looks like libcurl
Make throttle show off on 0 and up/down.
+1 -1
View File
@@ -1,4 +1,4 @@
AC_INIT(rtorrent, 0.1.4, jaris@ifi.uio.no)
AC_INIT(rtorrent, 0.1.5, jaris@ifi.uio.no)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
-1
View File
@@ -77,7 +77,6 @@ HashQueue::receive_hash_done(Base::iterator itr) {
Base::erase(itr);
s();
fill_queue();
}
+1
View File
@@ -94,6 +94,7 @@ Manager::start(Download* d) {
if (d->get_download().is_hash_checked())
d->start();
else
// This can cause infinit loops.
m_hashQueue.insert(d, sigc::mem_fun(d, &Download::start));
}
+1 -6
View File
@@ -57,9 +57,6 @@ WindowLog::redraw() {
int pos = 0;
//m_canvas->print(std::max(0, (int)m_canvas->get_width() / 2 - 5), pos++, "*** Log ***");
//m_canvas->print(0, 0, "___");
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_canvas->get_height(); ++itr)
m_canvas->print(0, pos++, "(%s) %s",
print_hhmmss(itr->first).c_str(),
@@ -69,9 +66,7 @@ WindowLog::redraw() {
void
WindowLog::receive_update() {
iterator itr = find_older();
int h = std::min(std::distance(m_log->begin(), itr),
(std::iterator_traits<iterator>::difference_type)10);
int h = std::min(std::distance(m_log->begin(), itr), (std::iterator_traits<iterator>::difference_type)10);
if (h != m_minHeight) {
set_active(h != 0);
+10 -2
View File
@@ -45,14 +45,18 @@ WindowStringList::redraw() {
size_t xpos = 1;
size_t width = 0;
for (iterator itr = m_first; itr != m_last; ++itr) {
iterator itr = m_first;
while (itr != m_last) {
if (ypos == (size_t)m_canvas->get_height()) {
ypos = 0;
xpos += width + 2;
if (xpos >= (size_t)m_canvas->get_width())
if (xpos + 20 >= (size_t)m_canvas->get_width())
break;
width = 0;
}
width = std::max(itr->size(), width);
@@ -61,7 +65,11 @@ WindowStringList::redraw() {
m_canvas->print(xpos, ypos++, "%s", itr->c_str());
else
m_canvas->print(xpos, ypos++, "%s", itr->substr(0, m_canvas->get_width() - xpos).c_str());
++itr;
}
m_drawEnd = itr;
}
}
+5 -1
View File
@@ -37,13 +37,17 @@ public:
WindowStringList();
~WindowStringList();
void set_range(iterator first, iterator last) { m_first = first; m_last = last; }
iterator get_draw_end() { return m_drawEnd; }
void set_range(iterator first, iterator last) { m_first = m_drawEnd = first; m_last = last; }
virtual void redraw();
private:
iterator m_first;
iterator m_last;
iterator m_drawEnd;
};
}
+36 -6
View File
@@ -26,22 +26,48 @@
#include <rak/algorithm.h>
#include "path_input.h"
#include "utils/file_stat.h"
namespace input {
PathInput::PathInput() {
PathInput::PathInput() :
m_showNext(false) {
}
bool
PathInput::pressed(int key) {
if (key == '\t')
receive_do_complete();
else
if (key != '\t') {
m_showNext = false;
return TextInput::pressed(key);
} else if (m_showNext) {
m_signalShowNext.emit();
} else {
receive_do_complete();
m_showNext = true;
}
return true;
}
struct _transform_filename {
_transform_filename(const std::string& base) : m_base(base) {}
void operator () (std::string& filename) {
utils::FileStat fs;
if (fs.update((m_base + filename).c_str()))
return;
else if (fs.is_directory())
filename += '/';
}
const std::string& m_base;
};
void
PathInput::receive_do_complete() {
size_type dirEnd = find_last_delim();
@@ -49,12 +75,13 @@ PathInput::receive_do_complete() {
utils::Directory dir(dirEnd != 0 ? str().substr(0, dirEnd) : "./");
if (!dir.update() || dir.empty()) {
str() += "!";
mark_dirty();
return;
}
std::for_each(dir.begin(), dir.end(), _transform_filename(str().substr(0, dirEnd)));
Range r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
if (r.first == r.second)
@@ -71,7 +98,10 @@ PathInput::receive_do_complete() {
set_pos(dirEnd + base.size());
mark_dirty();
m_signalShowRange.emit(r.first, r.second);
// Only emit if there are more than one option.
if (++utils::Directory::iterator(r.first) != r.second)
m_signalShowRange.emit(r.first, r.second);
}
PathInput::size_type
+6 -1
View File
@@ -34,12 +34,14 @@ namespace input {
class PathInput : public TextInput {
public:
typedef std::pair<utils::Directory::iterator, utils::Directory::iterator> Range;
typedef sigc::signal0<void> Signal;
typedef sigc::signal2<void, utils::Directory::iterator, utils::Directory::iterator> SignalShowRange;
PathInput();
virtual ~PathInput() {}
SignalShowRange& signal_show_range() { return m_signalShowRange; }
Signal& signal_show_next() { return m_signalShowNext; }
SignalShowRange& signal_show_range() { return m_signalShowRange; }
virtual bool pressed(int key);
@@ -49,6 +51,9 @@ private:
size_type find_last_delim();
Range find_incomplete(utils::Directory& d, const std::string& f);
bool m_showNext;
Signal m_signalShowNext;
SignalShowRange m_signalShowRange;
};
+4
View File
@@ -302,6 +302,10 @@ DownloadList::setup_input() {
m_windowTextInput = new WInput(p);
p->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
p->signal_show_next().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_STRING_LIST));
p->signal_show_next().connect(sigc::mem_fun(*esl, &ElementStringList::next_screen));
p->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_STRING_LIST))));
p->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
+10
View File
@@ -57,4 +57,14 @@ ElementStringList::disable(Control* c) {
m_window = NULL;
}
void
ElementStringList::next_screen() {
if (m_window->get_draw_end() != m_list.end())
m_window->set_range(m_window->get_draw_end(), m_list.end());
else
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
}
}
+2
View File
@@ -57,6 +57,8 @@ public:
m_window->mark_dirty();
}
void next_screen();
private:
WStringList* m_window;
List m_list;
+2
View File
@@ -3,6 +3,8 @@ noinst_LIBRARIES = libsub_utils.a
libsub_utils_a_SOURCES = \
directory.cc \
directory.h \
file_stat.cc \
file_stat.h \
list_focus.h \
parse.cc \
parse.h \
+70
View File
@@ -0,0 +1,70 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <stdexcept>
#include "file_stat.h"
namespace utils {
void
FileStat::update_throws(int fd) {
int r = update(fd);
if (r < 0)
throw std::runtime_error(error_string(r));
}
void
FileStat::update_throws(const char* filename) {
int r = update(filename);
if (r < 0)
throw std::runtime_error(error_string(r));
}
std::string
FileStat::error_string(int err) {
switch (err) {
case 0:
return "Success";
case EBADF:
return "Bad file descriptor";
case ENOENT:
return "Filename does not exist";
case ENOTDIR:
return "Path not a directory";
case EACCES:
return "Permission denied";
default:
return "Unknown error";
}
}
}
+66
View File
@@ -0,0 +1,66 @@
// libTorrent - BitTorrent library
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_UTILS_FILE_STAT_H
#define RTORRENT_UTILS_FILE_STAT_H
#include <string>
#include <inttypes.h>
#include <sys/stat.h>
namespace utils {
class FileStat {
public:
FileStat() {}
FileStat(const char* filename) { update_throws(filename); }
explicit FileStat(int fd) { update_throws(fd); }
int update(int fd) { return fstat(fd, &m_stat); }
int update(const char* filename) { return stat(filename, &m_stat); }
void update_throws(int fd);
void update_throws(const char* filename);
bool is_regular() const { return S_ISREG(m_stat.st_mode); }
bool is_directory() const { return S_ISDIR(m_stat.st_mode); }
bool is_character() const { return S_ISCHR(m_stat.st_mode); }
bool is_block() const { return S_ISBLK(m_stat.st_mode); }
bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); }
bool is_link() const { return S_ISLNK(m_stat.st_mode); }
bool is_sockt() const { return S_ISSOCK(m_stat.st_mode); }
off_t get_size() const { return m_stat.st_size; }
time_t get_atime() const { return m_stat.st_atime; }
time_t get_ctime() const { return m_stat.st_ctime; }
time_t get_mtime() const { return m_stat.st_mtime; }
static std::string error_string(int err);
private:
struct stat m_stat;
};
}
#endif