mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 02:32:32 +00:00
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:
+36
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user