Skip to content

Commit

Permalink
Add function get_file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
WSQS committed Jan 8, 2025
1 parent 7315c7c commit 6133424
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/folder_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ inline auto handle_path_existence(std::string &file_path) {
}
}

inline auto get_file_name(const std::string &file_path) {
return std::filesystem::path(file_path).filename().string();
}

inline auto handel_file(const std::shared_ptr<path_data> &input_path_data) {
run_command(input_path_data->file_path);
get_parent_directory(input_path_data->file_path);
input_path_data->tab_content =
std::filesystem::path(input_path_data->file_path).filename().string();
input_path_data->tab_content =get_file_name(input_path_data->file_path);
input_path_data->menu.build_entries(get_directory_content(input_path_data->file_path));
}

Expand Down Expand Up @@ -84,7 +87,7 @@ inline auto get_menu(const std::shared_ptr<path_data> &input_path_data) {
directory = directory.append(input_data->menu.entries[*input_data->menu.selected]())
.lexically_normal();
input_data->file_path = directory.string();
input_data->tab_content = directory.filename().string();
input_data->tab_content = get_file_name(input_data->file_path);
handel_file_type(input_data);
};
return multiselect_menu(&input_path_data->menu.entries, input_path_data->menu.selected.get(),
Expand All @@ -110,7 +113,7 @@ inline auto get_input(const std::shared_ptr<path_data> &input_path_data) {
input_option.on_enter = [input_data = input_path_data]() mutable {
handle_path_existence(input_data->file_path);
std::filesystem::path directory{input_data->file_path};
input_data->tab_content = directory.filename().string();
input_data->tab_content = get_file_name(input_data->file_path);
handel_file_type(input_data);
};
input_option.transform = input_transform;
Expand All @@ -134,7 +137,7 @@ inline auto handle_input(const Event &event) {

inline auto FileMenu(std::shared_ptr<path_data> &input_data) {
input_data->menu.build_entries(get_directory_content(input_data->file_path));
input_data->tab_content = std::filesystem::path(input_data->file_path).filename().string();
input_data->tab_content = get_file_name(input_data->file_path);
auto menu = get_menu(input_data);
auto input = get_input(input_data);
auto container = Container::Vertical({input, menu}) | CatchEvent(handle_input);
Expand Down

0 comments on commit 6133424

Please sign in to comment.