mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-03 14:14:11 +00:00
Improve aspect of tab-completion in navigate
This commit is contained in:
parent
76388be56e
commit
76a289df62
5 changed files with 21 additions and 2 deletions
|
@ -45,6 +45,9 @@ namespace dinlib {
|
|||
static std::size_t list_index;
|
||||
static std::vector<std::string> possible_values;
|
||||
|
||||
//see: https://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC28
|
||||
rl_completion_suppress_append = 1;
|
||||
|
||||
if (not parState) {
|
||||
list_index = 0;
|
||||
possible_values = g_current_wrapper->matches(parText);
|
||||
|
|
|
@ -156,7 +156,14 @@ namespace din {
|
|||
|
||||
std::vector<std::string> DBSource::paths_starting_by (uint32_t parGroupID, uint16_t parLevel, boost::string_ref parPath) {
|
||||
std::ostringstream oss;
|
||||
oss << "SELECT \"path\" FROM \"files\" WHERE \"group_id\"=$1 AND \"level\"=$2 AND str_begins_with(\"path\", COALESCE($3, '')) ORDER BY \"is_directory\" DESC, \"path\" ASC LIMIT " << g_files_query_limit << ';';
|
||||
oss << "SELECT \"path\" ||\n" <<
|
||||
"(SELECT CASE \"is_directory\"\n" <<
|
||||
"WHEN TRUE THEN '/'\n" <<
|
||||
"ELSE ''\n" <<
|
||||
"END) as path FROM \"files\" WHERE \"group_id\"=$1 AND " <<
|
||||
"\"level\"=$2 AND str_begins_with(\"path\", COALESCE($3, '')) " <<
|
||||
"ORDER BY \"is_directory\" DESC, \"path\" ASC LIMIT " <<
|
||||
g_files_query_limit << ';';
|
||||
|
||||
auto& conn = get_conn();
|
||||
auto result = conn.query(
|
||||
|
|
|
@ -69,6 +69,10 @@ namespace din {
|
|||
}
|
||||
} //unnamed namespace
|
||||
|
||||
EntryPath::EntryPath (const std::string& parPiece) {
|
||||
this->push_piece(parPiece);
|
||||
}
|
||||
|
||||
void EntryPath::push_piece (const std::string& parPiece) {
|
||||
using boost::spirit::qi::parse;
|
||||
|
||||
|
@ -119,7 +123,7 @@ namespace din {
|
|||
}
|
||||
|
||||
const std::string& EntryPath::operator[] (std::size_t parIndex) const {
|
||||
assert(parIndex < level());
|
||||
assert(parIndex < m_stack.size());
|
||||
return m_stack[parIndex];
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace din {
|
|||
class EntryPath {
|
||||
public:
|
||||
EntryPath ( void ) = default;
|
||||
explicit EntryPath ( const std::string& parPiece );
|
||||
|
||||
void push_piece ( const std::string& parPiece );
|
||||
std::string to_string ( void ) const;
|
||||
|
|
|
@ -99,6 +99,7 @@ namespace din {
|
|||
}
|
||||
|
||||
auto ListDirContent::ls ( EntryPath parDir, const std::string& parStartWith ) const -> const ListType& {
|
||||
const auto return_level = parDir.level();
|
||||
parDir.push_piece(parStartWith);
|
||||
const std::string curr_path = parDir.to_string();
|
||||
|
||||
|
@ -115,6 +116,9 @@ namespace din {
|
|||
const auto set_id = parDir.group_id();
|
||||
const auto path_prefix = parDir.file_path();
|
||||
auto file_list = m_db->paths_starting_by(set_id, parDir.level(), path_prefix);
|
||||
for (auto& file_item : file_list) {
|
||||
file_item = EntryPath(file_item)[return_level];
|
||||
}
|
||||
m_cache.push_back(std::make_pair(curr_path, file_list));
|
||||
}
|
||||
return last_cached_item(curr_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue