HackStudioWidget.h 7.1 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, the SerenityOS developers
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #pragma once
  29. #include "Debugger/DebugInfoWidget.h"
  30. #include "Debugger/DisassemblyWidget.h"
  31. #include "EditorWrapper.h"
  32. #include "FindInFilesWidget.h"
  33. #include "FormEditorWidget.h"
  34. #include "Git/DiffViewer.h"
  35. #include "Git/GitWidget.h"
  36. #include "Locator.h"
  37. #include "Project.h"
  38. #include "ProjectFile.h"
  39. #include "TerminalWrapper.h"
  40. #include <LibGUI/ActionGroup.h>
  41. #include <LibGUI/ScrollBar.h>
  42. #include <LibGUI/Splitter.h>
  43. #include <LibGUI/Widget.h>
  44. #include <LibThread/Thread.h>
  45. namespace HackStudio {
  46. class HackStudioWidget : public GUI::Widget {
  47. C_OBJECT(HackStudioWidget)
  48. public:
  49. virtual ~HackStudioWidget() override;
  50. void open_file(const String& filename);
  51. void update_actions();
  52. Project& project();
  53. GUI::TextEditor& current_editor();
  54. EditorWrapper& current_editor_wrapper();
  55. void set_current_editor_wrapper(RefPtr<EditorWrapper>);
  56. String currently_open_file() const { return m_currently_open_file; }
  57. void initialize_menubar(GUI::MenuBar&);
  58. Locator& locator()
  59. {
  60. VERIFY(m_locator);
  61. return *m_locator;
  62. }
  63. private:
  64. static String get_full_path_of_serenity_source(const String& file);
  65. Vector<String> selected_file_paths() const;
  66. HackStudioWidget(const String& path_to_project);
  67. void open_project(const String& root_path);
  68. enum class EditMode {
  69. Text,
  70. Form,
  71. Diff,
  72. };
  73. void set_edit_mode(EditMode);
  74. NonnullRefPtr<GUI::Menu> create_project_tree_view_context_menu();
  75. NonnullRefPtr<GUI::Action> create_new_file_action();
  76. NonnullRefPtr<GUI::Action> create_new_directory_action();
  77. NonnullRefPtr<GUI::Action> create_open_selected_action();
  78. NonnullRefPtr<GUI::Action> create_delete_action();
  79. NonnullRefPtr<GUI::Action> create_new_project_action();
  80. NonnullRefPtr<GUI::Action> create_switch_to_next_editor_action();
  81. NonnullRefPtr<GUI::Action> create_switch_to_previous_editor_action();
  82. NonnullRefPtr<GUI::Action> create_remove_current_editor_action();
  83. NonnullRefPtr<GUI::Action> create_open_action();
  84. NonnullRefPtr<GUI::Action> create_save_action();
  85. NonnullRefPtr<GUI::Action> create_add_editor_action();
  86. NonnullRefPtr<GUI::Action> create_add_terminal_action();
  87. NonnullRefPtr<GUI::Action> create_remove_current_terminal_action();
  88. NonnullRefPtr<GUI::Action> create_debug_action();
  89. NonnullRefPtr<GUI::Action> create_build_action();
  90. NonnullRefPtr<GUI::Action> create_run_action();
  91. NonnullRefPtr<GUI::Action> create_stop_action();
  92. NonnullRefPtr<GUI::Action> create_set_autocomplete_mode_action();
  93. void add_new_editor(GUI::Widget& parent);
  94. NonnullRefPtr<EditorWrapper> get_editor_of_file(const String& file_name);
  95. String get_project_executable_path() const;
  96. void on_action_tab_change();
  97. void reveal_action_tab(GUI::Widget&);
  98. void initialize_debugger();
  99. void create_project_tree_view(GUI::Widget& parent);
  100. void create_open_files_view(GUI::Widget& parent);
  101. void create_form_editor(GUI::Widget& parent);
  102. void create_toolbar(GUI::Widget& parent);
  103. void create_action_tab(GUI::Widget& parent);
  104. void create_app_menubar(GUI::MenuBar&);
  105. void create_project_menubar(GUI::MenuBar&);
  106. void create_edit_menubar(GUI::MenuBar&);
  107. void create_build_menubar(GUI::MenuBar&);
  108. void create_view_menubar(GUI::MenuBar&);
  109. void create_help_menubar(GUI::MenuBar&);
  110. void run(TerminalWrapper& wrapper);
  111. void build(TerminalWrapper& wrapper);
  112. void hide_action_tabs();
  113. NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
  114. RefPtr<EditorWrapper> m_current_editor_wrapper;
  115. // FIXME: This doesn't seem compatible with multiple split editors
  116. String m_currently_open_file;
  117. HashMap<String, NonnullRefPtr<ProjectFile>> m_open_files;
  118. Vector<String> m_open_files_vector; // NOTE: This contains the keys from m_open_files
  119. OwnPtr<Project> m_project;
  120. RefPtr<GUI::TreeView> m_project_tree_view;
  121. RefPtr<GUI::ListView> m_open_files_view;
  122. RefPtr<GUI::VerticalSplitter> m_right_hand_splitter;
  123. RefPtr<GUI::StackWidget> m_right_hand_stack;
  124. RefPtr<GUI::Splitter> m_editors_splitter;
  125. RefPtr<GUI::Widget> m_form_inner_container;
  126. RefPtr<FormEditorWidget> m_form_editor_widget;
  127. RefPtr<GUI::TreeView> m_form_widget_tree_view;
  128. RefPtr<DiffViewer> m_diff_viewer;
  129. RefPtr<GitWidget> m_git_widget;
  130. RefPtr<GUI::Menu> m_project_tree_view_context_menu;
  131. RefPtr<GUI::TabWidget> m_action_tab_widget;
  132. RefPtr<TerminalWrapper> m_terminal_wrapper;
  133. RefPtr<Locator> m_locator;
  134. RefPtr<FindInFilesWidget> m_find_in_files_widget;
  135. RefPtr<DebugInfoWidget> m_debug_info_widget;
  136. RefPtr<DisassemblyWidget> m_disassembly_widget;
  137. RefPtr<LibThread::Thread> m_debugger_thread;
  138. RefPtr<EditorWrapper> m_current_editor_in_execution;
  139. RefPtr<GUI::Action> m_new_file_action;
  140. RefPtr<GUI::Action> m_new_directory_action;
  141. RefPtr<GUI::Action> m_open_selected_action;
  142. RefPtr<GUI::Action> m_delete_action;
  143. RefPtr<GUI::Action> m_new_project_action;
  144. RefPtr<GUI::Action> m_switch_to_next_editor;
  145. RefPtr<GUI::Action> m_switch_to_previous_editor;
  146. RefPtr<GUI::Action> m_remove_current_editor_action;
  147. RefPtr<GUI::Action> m_open_action;
  148. RefPtr<GUI::Action> m_save_action;
  149. RefPtr<GUI::Action> m_add_editor_action;
  150. RefPtr<GUI::Action> m_add_terminal_action;
  151. RefPtr<GUI::Action> m_remove_current_terminal_action;
  152. RefPtr<GUI::Action> m_stop_action;
  153. RefPtr<GUI::Action> m_debug_action;
  154. RefPtr<GUI::Action> m_build_action;
  155. RefPtr<GUI::Action> m_run_action;
  156. GUI::ActionGroup m_wrapping_mode_actions;
  157. RefPtr<GUI::Action> m_no_wrapping_action;
  158. RefPtr<GUI::Action> m_wrap_anywhere_action;
  159. RefPtr<GUI::Action> m_wrap_at_words_action;
  160. };
  161. }