diff --git a/src/rrr/content/content.cpp b/src/rrr/content/content.cpp index e5d8177..9b5d5c9 100644 --- a/src/rrr/content/content.cpp +++ b/src/rrr/content/content.cpp @@ -74,6 +74,7 @@ namespace rrr void content::set_history_cursor_position() { + history_cursor_position = 0; tbb::parallel_for(tbb::blocked_range(0, his.data.size()), [&](tbb::blocked_range r) { for (int i = r.begin(); i < r.end(); ++i) @@ -88,6 +89,7 @@ namespace rrr return; auto pwd = nav.data.at(navigation_cursor_position).path; + preview_cursor_position = 0; if (buffer::state.contains(pwd)) { @@ -115,9 +117,8 @@ namespace rrr void content::check_cursor_position() { - if (navigation_cursor_position == (int)nav.data.size()) navigation_cursor_position = (int)nav.data.size() - 1; + if (navigation_cursor_position >= (int)nav.data.size()) navigation_cursor_position = (int)nav.data.size() - 1; else if (navigation_cursor_position < 0) navigation_cursor_position = 0; - else if (navigation_cursor_position > (int)nav.data.size()) navigation_cursor_position = 0; } void content::navigation_right() diff --git a/src/rrr/layers/gui/browser/navigation/navigation.cpp b/src/rrr/layers/gui/browser/navigation/navigation.cpp index a53a292..7f8ea5f 100644 --- a/src/rrr/layers/gui/browser/navigation/navigation.cpp +++ b/src/rrr/layers/gui/browser/navigation/navigation.cpp @@ -178,6 +178,36 @@ namespace rrr::layers::gui if (key.get_keycode() == try_engine::key::LEFTSHIFT || key.get_keycode() == try_engine::key::RIGHTSHIFT) shift = true; + if (shift) + { + // удаление + if (shift && key.get_keycode() == try_engine::key::D) + { + em->execute(types::event_type::SHOW_DELETE_ONE_FILE_DIALOG, selected_file); + freeze = true; + } + + // создание файла/директории + if (shift && key.get_keycode() == try_engine::key::A) + { + em->execute(types::event_type::SHOW_CREATE_FILE_DIALOG, nullptr); + freeze = true; + } + + // перемещение в конец списка + if (shift && key.get_keycode() == try_engine::key::G) + { + cnt->increment_position(data->size()); + selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION); + em->execute(types::event_type::NAVIGATION_DOWN, nullptr); + set_delta(MOVE_DIRECTION::DOWN); + set_scroll(); + } + + return; + } + + if (key.get_keycode() == try_engine::key::J) { cnt->increment_position(STEP_DOWN); @@ -212,18 +242,17 @@ namespace rrr::layers::gui set_scroll(); } - // удаление - if (shift && key.get_keycode() == try_engine::key::D) + // двойное нажатие перемещение в начало списка + if (key.get_keycode() == try_engine::key::G) { - em->execute(types::event_type::SHOW_DELETE_ONE_FILE_DIALOG, selected_file); - freeze = true; - } - - // создание файла/директории - if (shift && key.get_keycode() == try_engine::key::A) - { - em->execute(types::event_type::SHOW_CREATE_FILE_DIALOG, nullptr); - freeze = true; + ++g_coutn; + if (g_coutn != 2) return; + cnt->increment_position(-data->size()); + selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION); + em->execute(types::event_type::NAVIGATION_UP, nullptr); + set_delta(MOVE_DIRECTION::UP); + set_scroll(); + g_coutn = 0; } } @@ -295,6 +324,7 @@ namespace rrr::layers::gui if (big_content) { + // как бы прокручиваем с начала списка for (const auto& f : *data) { if (f.path != selected_file.path) diff --git a/src/rrr/layers/gui/browser/navigation/navigation.hpp b/src/rrr/layers/gui/browser/navigation/navigation.hpp index 0e94149..f9b3aa6 100644 --- a/src/rrr/layers/gui/browser/navigation/navigation.hpp +++ b/src/rrr/layers/gui/browser/navigation/navigation.hpp @@ -42,7 +42,10 @@ namespace rrr::layers::gui const int STEP_UP = -1; const int STEP_DOWN = 1; file selected_file; + + // key options bool shift = false; + int g_coutn = 0; // все что нужно для установки курсора при длинных списках int current_position = 0; // позиция курсора относительно списка diff --git a/src/rrr/layers/gui/browser/preview/preview.cpp b/src/rrr/layers/gui/browser/preview/preview.cpp index 8dc9b93..4a60849 100644 --- a/src/rrr/layers/gui/browser/preview/preview.cpp +++ b/src/rrr/layers/gui/browser/preview/preview.cpp @@ -52,6 +52,7 @@ namespace rrr::layers::gui TR_PUSH_FONT(SEMI_BOLD, 18); ImGui::TextUnformatted(">"); ImGui::SameLine(22.f); + current_position = it - data->begin(); } else { @@ -98,6 +99,9 @@ namespace rrr::layers::gui case types::event_type::NAVIGATION_LEFT: case types::event_type::NAVIGATION_RIGHT: selected_file = cnt->get_selected_file(TYPE_WIN::PREVIEW); + cursor_position = 0; + current_position = 0; + delta = 0; set_scroll(); break; default: