1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

HackStudio: Add "Go Back" and "Go Forward" navigation actions

These actions allow the user to move backwards & forwards between
previous project locations they were at.
This commit is contained in:
Itamar 2021-08-27 16:26:18 +03:00 committed by Andreas Kling
parent 8fc9ec942e
commit 11832544e5
2 changed files with 123 additions and 4 deletions

View file

@ -41,7 +41,9 @@ public:
void update_actions();
Project& project();
GUI::TextEditor& current_editor();
GUI::TextEditor const& current_editor() const;
EditorWrapper& current_editor_wrapper();
EditorWrapper const& current_editor_wrapper() const;
void set_current_editor_wrapper(RefPtr<EditorWrapper>);
const String& active_file() const { return m_current_editor_wrapper->filename(); }
@ -93,6 +95,7 @@ private:
NonnullRefPtr<GUI::Action> create_build_action();
NonnullRefPtr<GUI::Action> create_run_action();
NonnullRefPtr<GUI::Action> create_stop_action();
void create_location_history_actions();
void add_new_editor(GUI::Widget& parent);
RefPtr<EditorWrapper> get_editor_of_file(const String& filename);
@ -128,6 +131,16 @@ private:
void update_gml_preview();
void update_tree_view();
void update_window_title();
void on_cursor_change();
struct ProjectLocation {
String filename;
size_t line { 0 };
size_t column { 0 };
};
ProjectLocation current_project_location() const;
void update_history_actions();
NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
RefPtr<EditorWrapper> m_current_editor_wrapper;
@ -138,6 +151,12 @@ private:
OwnPtr<Project> m_project;
Vector<ProjectLocation> m_locations_history;
// This index is the boundary between the "Go Back" and "Go Forward" locations.
// It always points at one past the current location in the list.
size_t m_locations_history_end_index { 0 };
bool m_locations_history_disabled { false };
RefPtr<GUI::TreeView> m_project_tree_view;
RefPtr<GUI::ListView> m_open_files_view;
RefPtr<GUI::VerticalSplitter> m_right_hand_splitter;
@ -181,6 +200,8 @@ private:
RefPtr<GUI::Action> m_debug_action;
RefPtr<GUI::Action> m_build_action;
RefPtr<GUI::Action> m_run_action;
RefPtr<GUI::Action> m_locations_history_back_action;
RefPtr<GUI::Action> m_locations_history_forward_action;
GUI::ActionGroup m_wrapping_mode_actions;
RefPtr<GUI::Action> m_no_wrapping_action;