HackStudioWidget.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  4. * Copyright (c) 2020-2021, the SerenityOS developers.
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include "ClassViewWidget.h"
  10. #include "Debugger/DebugInfoWidget.h"
  11. #include "Debugger/DisassemblyWidget.h"
  12. #include "EditorWrapper.h"
  13. #include "FindInFilesWidget.h"
  14. #include "Git/DiffViewer.h"
  15. #include "Git/GitWidget.h"
  16. #include "Locator.h"
  17. #include "Project.h"
  18. #include "ProjectFile.h"
  19. #include "TerminalWrapper.h"
  20. #include "ToDoEntriesWidget.h"
  21. #include <LibGUI/ActionGroup.h>
  22. #include <LibGUI/Scrollbar.h>
  23. #include <LibGUI/Splitter.h>
  24. #include <LibGUI/Widget.h>
  25. #include <LibThreading/Thread.h>
  26. namespace HackStudio {
  27. class HackStudioWidget : public GUI::Widget {
  28. C_OBJECT(HackStudioWidget)
  29. public:
  30. virtual ~HackStudioWidget() override;
  31. bool open_file(const String& filename);
  32. void update_actions();
  33. Project& project();
  34. GUI::TextEditor& current_editor();
  35. EditorWrapper& current_editor_wrapper();
  36. void set_current_editor_wrapper(RefPtr<EditorWrapper>);
  37. const String& active_file() const { return m_current_editor_wrapper->filename(); }
  38. void initialize_menubar(GUI::Menubar&);
  39. Locator& locator()
  40. {
  41. VERIFY(m_locator);
  42. return *m_locator;
  43. }
  44. enum class ContinueDecision {
  45. No,
  46. Yes
  47. };
  48. ContinueDecision warn_unsaved_changes(const String& prompt);
  49. private:
  50. static String get_full_path_of_serenity_source(const String& file);
  51. Vector<String> selected_file_paths() const;
  52. HackStudioWidget(const String& path_to_project);
  53. void open_project(const String& root_path);
  54. enum class EditMode {
  55. Text,
  56. Diff,
  57. };
  58. void set_edit_mode(EditMode);
  59. NonnullRefPtr<GUI::Menu> create_project_tree_view_context_menu();
  60. NonnullRefPtr<GUI::Action> create_new_file_action();
  61. NonnullRefPtr<GUI::Action> create_new_directory_action();
  62. NonnullRefPtr<GUI::Action> create_open_selected_action();
  63. NonnullRefPtr<GUI::Action> create_delete_action();
  64. NonnullRefPtr<GUI::Action> create_new_project_action();
  65. NonnullRefPtr<GUI::Action> create_switch_to_next_editor_action();
  66. NonnullRefPtr<GUI::Action> create_switch_to_previous_editor_action();
  67. NonnullRefPtr<GUI::Action> create_remove_current_editor_action();
  68. NonnullRefPtr<GUI::Action> create_open_action();
  69. NonnullRefPtr<GUI::Action> create_save_action();
  70. NonnullRefPtr<GUI::Action> create_show_in_file_manager_action();
  71. NonnullRefPtr<GUI::Action> create_add_editor_action();
  72. NonnullRefPtr<GUI::Action> create_add_terminal_action();
  73. NonnullRefPtr<GUI::Action> create_remove_current_terminal_action();
  74. NonnullRefPtr<GUI::Action> create_debug_action();
  75. NonnullRefPtr<GUI::Action> create_build_action();
  76. NonnullRefPtr<GUI::Action> create_run_action();
  77. NonnullRefPtr<GUI::Action> create_stop_action();
  78. void add_new_editor(GUI::Widget& parent);
  79. RefPtr<EditorWrapper> get_editor_of_file(const String& filename);
  80. String get_project_executable_path() const;
  81. void on_action_tab_change();
  82. void reveal_action_tab(GUI::Widget&);
  83. void initialize_debugger();
  84. void handle_external_file_deletion(const String& filepath);
  85. void create_open_files_view(GUI::Widget& parent);
  86. void create_toolbar(GUI::Widget& parent);
  87. void create_action_tab(GUI::Widget& parent);
  88. void create_file_menubar(GUI::Menubar&);
  89. void create_project_menubar(GUI::Menubar&);
  90. void create_edit_menubar(GUI::Menubar&);
  91. void create_build_menubar(GUI::Menubar&);
  92. void create_view_menubar(GUI::Menubar&);
  93. void create_help_menubar(GUI::Menubar&);
  94. void create_project_tab(GUI::Widget& parent);
  95. void configure_project_tree_view();
  96. void run(TerminalWrapper& wrapper);
  97. void build(TerminalWrapper& wrapper);
  98. void hide_action_tabs();
  99. bool any_document_is_dirty() const;
  100. NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
  101. RefPtr<EditorWrapper> m_current_editor_wrapper;
  102. HashMap<String, NonnullRefPtr<ProjectFile>> m_open_files;
  103. RefPtr<Core::FileWatcher> m_file_watcher;
  104. Vector<String> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
  105. OwnPtr<Project> m_project;
  106. RefPtr<GUI::TreeView> m_project_tree_view;
  107. RefPtr<GUI::ListView> m_open_files_view;
  108. RefPtr<GUI::VerticalSplitter> m_right_hand_splitter;
  109. RefPtr<GUI::StackWidget> m_right_hand_stack;
  110. RefPtr<GUI::Splitter> m_editors_splitter;
  111. RefPtr<DiffViewer> m_diff_viewer;
  112. RefPtr<GitWidget> m_git_widget;
  113. RefPtr<ClassViewWidget> m_class_view;
  114. RefPtr<GUI::Menu> m_project_tree_view_context_menu;
  115. RefPtr<GUI::TabWidget> m_action_tab_widget;
  116. RefPtr<GUI::TabWidget> m_project_tab;
  117. RefPtr<TerminalWrapper> m_terminal_wrapper;
  118. RefPtr<Locator> m_locator;
  119. RefPtr<FindInFilesWidget> m_find_in_files_widget;
  120. RefPtr<ToDoEntriesWidget> m_todo_entries_widget;
  121. RefPtr<DebugInfoWidget> m_debug_info_widget;
  122. RefPtr<DisassemblyWidget> m_disassembly_widget;
  123. RefPtr<Threading::Thread> m_debugger_thread;
  124. RefPtr<EditorWrapper> m_current_editor_in_execution;
  125. RefPtr<GUI::Action> m_new_file_action;
  126. RefPtr<GUI::Action> m_new_directory_action;
  127. RefPtr<GUI::Action> m_open_selected_action;
  128. RefPtr<GUI::Action> m_show_in_file_manager_action;
  129. RefPtr<GUI::Action> m_delete_action;
  130. RefPtr<GUI::Action> m_new_project_action;
  131. RefPtr<GUI::Action> m_switch_to_next_editor;
  132. RefPtr<GUI::Action> m_switch_to_previous_editor;
  133. RefPtr<GUI::Action> m_remove_current_editor_action;
  134. RefPtr<GUI::Action> m_open_action;
  135. RefPtr<GUI::Action> m_save_action;
  136. RefPtr<GUI::Action> m_add_editor_action;
  137. RefPtr<GUI::Action> m_add_terminal_action;
  138. RefPtr<GUI::Action> m_remove_current_terminal_action;
  139. RefPtr<GUI::Action> m_stop_action;
  140. RefPtr<GUI::Action> m_debug_action;
  141. RefPtr<GUI::Action> m_build_action;
  142. RefPtr<GUI::Action> m_run_action;
  143. GUI::ActionGroup m_wrapping_mode_actions;
  144. RefPtr<GUI::Action> m_no_wrapping_action;
  145. RefPtr<GUI::Action> m_wrap_anywhere_action;
  146. RefPtr<GUI::Action> m_wrap_at_words_action;
  147. };
  148. }