diff options
Diffstat (limited to '')
-rw-r--r-- | src/breadcrumb_curses.hh | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/breadcrumb_curses.hh b/src/breadcrumb_curses.hh index 06218c3..93733d6 100644 --- a/src/breadcrumb_curses.hh +++ b/src/breadcrumb_curses.hh @@ -40,15 +40,9 @@ class breadcrumb_curses : public view_curses { public: - breadcrumb_curses(); - - void set_y(int y) - { - this->bc_y = y; - this->bc_match_view.set_y(y + 1); - } + using action = std::function<void(breadcrumb_curses&)>; - int get_y() const { return this->bc_y; } + breadcrumb_curses(); void set_window(WINDOW* win) { @@ -61,23 +55,29 @@ public: this->bc_line_source = std::move(ls); } + bool handle_mouse(mouse_event& me) override; + void focus(); void blur(); bool handle_key(int ch); - void do_update() override; + bool do_update() override; void reload_data(); + static void no_op_action(breadcrumb_curses&); + + action on_focus{no_op_action}; + action on_blur{no_op_action}; + private: class search_overlay_source : public list_overlay_source { public: - bool list_value_for_overlay(const listview_curses& lv, - int y, - int bottom, - vis_line_t line, - attr_line_t& value_out) override; + bool list_static_overlay(const listview_curses& lv, + int y, + int bottom, + attr_line_t& value_out) override; breadcrumb_curses* sos_parent{nullptr}; }; @@ -91,7 +91,6 @@ private: WINDOW* bc_window{nullptr}; std::function<std::vector<breadcrumb::crumb>()> bc_line_source; - int bc_y{0}; std::vector<breadcrumb::crumb> bc_focused_crumbs; nonstd::optional<size_t> bc_selected_crumb; nonstd::optional<size_t> bc_last_selected_crumb; @@ -102,6 +101,19 @@ private: plain_text_source bc_match_source; search_overlay_source bc_match_search_overlay; textview_curses bc_match_view; + + struct displayed_crumb { + displayed_crumb(line_range range, size_t index) + : dc_range(range), dc_index(index) + { + } + + line_range dc_range; + size_t dc_index{0}; + }; + + std::vector<displayed_crumb> bc_displayed_crumbs; + bool bc_initial_mouse_event{true}; }; #endif |