aboutsummaryrefslogtreecommitdiff
path: root/src/filebrowserformaction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/filebrowserformaction.cpp')
-rw-r--r--src/filebrowserformaction.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/filebrowserformaction.cpp b/src/filebrowserformaction.cpp
index f55debf7..5968823f 100644
--- a/src/filebrowserformaction.cpp
+++ b/src/filebrowserformaction.cpp
@@ -1,5 +1,3 @@
-#define ENABLE_IMPLICIT_FILEPATH_CONVERSIONS
-
#include "filebrowserformaction.h"
#include <algorithm>
@@ -201,25 +199,25 @@ void FileBrowserFormAction::update_title(const Filepath& working_directory)
FmtStrFormatter fmt;
fmt.register_fmt('N', PROGRAM_NAME);
fmt.register_fmt('V', utils::program_version());
- fmt.register_fmt('f', working_directory);
+ fmt.register_fmt('f', working_directory.display());
set_title(fmt.do_format(
cfg->get_configvalue("filebrowser-title-format"), width));
}
-std::vector<std::string> get_sorted_filelist()
+std::vector<Filepath> get_sorted_filelist()
{
- std::vector<std::string> ret;
+ std::vector<Filepath> ret;
- const std::string cwdtmp = utils::getcwd();
+ const auto cwdtmp = utils::getcwd();
- DIR* dirp = ::opendir(cwdtmp.c_str());
+ DIR* dirp = ::opendir(cwdtmp.to_locale_string().c_str());
if (dirp) {
struct dirent* de = ::readdir(dirp);
while (de) {
if (strcmp(de->d_name, ".") != 0 &&
strcmp(de->d_name, "..") != 0) {
- ret.push_back(de->d_name);
+ ret.push_back(Filepath::from_locale_string(de->d_name));
}
de = ::readdir(dirp);
}
@@ -228,8 +226,8 @@ std::vector<std::string> get_sorted_filelist()
std::sort(ret.begin(), ret.end());
- if (cwdtmp != "/") {
- ret.insert(ret.begin(), "..");
+ if (cwdtmp != Filepath::from_locale_string("/")) {
+ ret.emplace(ret.begin(), Filepath::from_locale_string(".."));
}
return ret;
@@ -243,18 +241,14 @@ void FileBrowserFormAction::prepare()
* in the current directory.
*/
if (do_redraw) {
- const std::string cwdtmp = utils::getcwd();
- update_title(cwdtmp);
-
- std::vector<std::string> files = get_sorted_filelist();
+ update_title(utils::getcwd());
id_at_position.clear();
lines.clear();
- for (std::string filename : files) {
+ for (auto filename : get_sorted_filelist()) {
add_file(id_at_position, filename);
}
-
auto render_line = [this](std::uint32_t line, std::uint32_t width) -> StflRichText {
(void)width;
return lines[line];
@@ -295,7 +289,7 @@ void FileBrowserFormAction::init()
const int status = ::chdir(save_path.c_str());
LOG(Level::DEBUG, "view::filebrowser: chdir(%s) = %i", save_path, status);
- set_value("filenametext", default_filename);
+ set_value("filenametext", default_filename.to_locale_string());
// Set position to 0 and back to ensure that the text is visible
draw_form();