HackStudioWidget.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 "GMLPreviewWidget.h"
  15. #include "Git/DiffViewer.h"
  16. #include "Git/GitWidget.h"
  17. #include "Locator.h"
  18. #include "Project.h"
  19. #include "ProjectFile.h"
  20. #include "TerminalWrapper.h"
  21. #include "ToDoEntriesWidget.h"
  22. #include <LibGUI/ActionGroup.h>
  23. #include <LibGUI/Scrollbar.h>
  24. #include <LibGUI/Splitter.h>
  25. #include <LibGUI/Widget.h>
  26. #include <LibThreading/Thread.h>
  27. namespace HackStudio {
  28. class HackStudioWidget : public GUI::Widget {
  29. C_OBJECT(HackStudioWidget)
  30. public:
  31. virtual ~HackStudioWidget() override;
  32. bool open_file(const String& filename);
  33. void close_file_in_all_editors(String const& filename);
  34. void update_actions();
  35. Project& project();
  36. GUI::TextEditor& current_editor();
  37. EditorWrapper& current_editor_wrapper();
  38. void set_current_editor_wrapper(RefPtr<EditorWrapper>);
  39. const String& active_file() const { return m_current_editor_wrapper->filename(); }
  40. void initialize_menubar(GUI::Window&);
  41. Locator& locator()
  42. {
  43. VERIFY(m_locator);
  44. return *m_locator;
  45. }
  46. enum class ContinueDecision {
  47. No,
  48. Yes
  49. };
  50. ContinueDecision warn_unsaved_changes(const String& prompt);
  51. private:
  52. static String get_full_path_of_serenity_source(const String& file);
  53. Vector<String> selected_file_paths() const;
  54. HackStudioWidget(const String& path_to_project);
  55. void open_project(const String& root_path);
  56. enum class EditMode {
  57. Text,
  58. Diff,
  59. };
  60. void set_edit_mode(EditMode);
  61. NonnullRefPtr<GUI::Menu> create_project_tree_view_context_menu();
  62. NonnullRefPtr<GUI::Action> create_new_file_action();
  63. NonnullRefPtr<GUI::Action> create_new_directory_action();
  64. NonnullRefPtr<GUI::Action> create_open_selected_action();
  65. NonnullRefPtr<GUI::Action> create_delete_action();
  66. NonnullRefPtr<GUI::Action> create_new_project_action();
  67. NonnullRefPtr<GUI::Action> create_switch_to_next_editor_action();
  68. NonnullRefPtr<GUI::Action> create_switch_to_previous_editor_action();
  69. NonnullRefPtr<GUI::Action> create_remove_current_editor_action();
  70. NonnullRefPtr<GUI::Action> create_open_action();
  71. NonnullRefPtr<GUI::Action> create_save_action();
  72. NonnullRefPtr<GUI::Action> create_save_as_action();
  73. NonnullRefPtr<GUI::Action> create_show_in_file_manager_action();
  74. NonnullRefPtr<GUI::Action> create_add_editor_action();
  75. NonnullRefPtr<GUI::Action> create_add_terminal_action();
  76. NonnullRefPtr<GUI::Action> create_remove_current_terminal_action();
  77. NonnullRefPtr<GUI::Action> create_debug_action();
  78. NonnullRefPtr<GUI::Action> create_build_action();
  79. NonnullRefPtr<GUI::Action> create_run_action();
  80. NonnullRefPtr<GUI::Action> create_stop_action();
  81. void add_new_editor(GUI::Widget& parent);
  82. RefPtr<EditorWrapper> get_editor_of_file(const String& filename);
  83. String get_project_executable_path() const;
  84. void on_action_tab_change();
  85. void reveal_action_tab(GUI::Widget&);
  86. void initialize_debugger();
  87. void update_statusbar();
  88. void handle_external_file_deletion(const String& filepath);
  89. void stop_debugger_if_running();
  90. void close_current_project();
  91. void create_open_files_view(GUI::Widget& parent);
  92. void create_toolbar(GUI::Widget& parent);
  93. void create_action_tab(GUI::Widget& parent);
  94. void create_file_menu(GUI::Window&);
  95. void create_project_menu(GUI::Window&);
  96. void create_edit_menu(GUI::Window&);
  97. void create_build_menu(GUI::Window&);
  98. void create_view_menu(GUI::Window&);
  99. void create_help_menu(GUI::Window&);
  100. void create_project_tab(GUI::Widget& parent);
  101. void configure_project_tree_view();
  102. void run(TerminalWrapper& wrapper);
  103. void build(TerminalWrapper& wrapper);
  104. void hide_action_tabs();
  105. bool any_document_is_dirty() const;
  106. void update_gml_preview();
  107. void update_window_title();
  108. NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
  109. RefPtr<EditorWrapper> m_current_editor_wrapper;
  110. HashMap<String, NonnullRefPtr<ProjectFile>> m_open_files;
  111. RefPtr<Core::FileWatcher> m_file_watcher;
  112. Vector<String> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
  113. OwnPtr<Project> m_project;
  114. RefPtr<GUI::TreeView> m_project_tree_view;
  115. RefPtr<GUI::ListView> m_open_files_view;
  116. RefPtr<GUI::VerticalSplitter> m_right_hand_splitter;
  117. RefPtr<GUI::StackWidget> m_right_hand_stack;
  118. RefPtr<GUI::Splitter> m_editors_splitter;
  119. RefPtr<DiffViewer> m_diff_viewer;
  120. RefPtr<GitWidget> m_git_widget;
  121. RefPtr<GMLPreviewWidget> m_gml_preview_widget;
  122. RefPtr<ClassViewWidget> m_class_view;
  123. RefPtr<GUI::Menu> m_project_tree_view_context_menu;
  124. RefPtr<GUI::Statusbar> m_statusbar;
  125. RefPtr<GUI::TabWidget> m_action_tab_widget;
  126. RefPtr<GUI::TabWidget> m_project_tab;
  127. RefPtr<TerminalWrapper> m_terminal_wrapper;
  128. RefPtr<Locator> m_locator;
  129. RefPtr<FindInFilesWidget> m_find_in_files_widget;
  130. RefPtr<ToDoEntriesWidget> m_todo_entries_widget;
  131. RefPtr<DebugInfoWidget> m_debug_info_widget;
  132. RefPtr<DisassemblyWidget> m_disassembly_widget;
  133. RefPtr<Threading::Thread> m_debugger_thread;
  134. RefPtr<EditorWrapper> m_current_editor_in_execution;
  135. RefPtr<GUI::Action> m_new_file_action;
  136. RefPtr<GUI::Action> m_new_directory_action;
  137. RefPtr<GUI::Action> m_open_selected_action;
  138. RefPtr<GUI::Action> m_show_in_file_manager_action;
  139. RefPtr<GUI::Action> m_delete_action;
  140. RefPtr<GUI::Action> m_new_project_action;
  141. RefPtr<GUI::Action> m_switch_to_next_editor;
  142. RefPtr<GUI::Action> m_switch_to_previous_editor;
  143. RefPtr<GUI::Action> m_remove_current_editor_action;
  144. RefPtr<GUI::Action> m_open_action;
  145. RefPtr<GUI::Action> m_save_action;
  146. RefPtr<GUI::Action> m_save_as_action;
  147. RefPtr<GUI::Action> m_add_editor_action;
  148. RefPtr<GUI::Action> m_add_terminal_action;
  149. RefPtr<GUI::Action> m_remove_current_terminal_action;
  150. RefPtr<GUI::Action> m_stop_action;
  151. RefPtr<GUI::Action> m_debug_action;
  152. RefPtr<GUI::Action> m_build_action;
  153. RefPtr<GUI::Action> m_run_action;
  154. GUI::ActionGroup m_wrapping_mode_actions;
  155. RefPtr<GUI::Action> m_no_wrapping_action;
  156. RefPtr<GUI::Action> m_wrap_anywhere_action;
  157. RefPtr<GUI::Action> m_wrap_at_words_action;
  158. };
  159. }