HackStudioWidget.cpp 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  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. #include "HackStudioWidget.h"
  29. #include "CursorTool.h"
  30. #include "Debugger/DebugInfoWidget.h"
  31. #include "Debugger/Debugger.h"
  32. #include "Debugger/DisassemblyWidget.h"
  33. #include "Dialogs/NewProjectDialog.h"
  34. #include "Editor.h"
  35. #include "EditorWrapper.h"
  36. #include "FindInFilesWidget.h"
  37. #include "FormEditorWidget.h"
  38. #include "FormWidget.h"
  39. #include "Git/DiffViewer.h"
  40. #include "Git/GitWidget.h"
  41. #include "HackStudio.h"
  42. #include "HackStudioWidget.h"
  43. #include "Locator.h"
  44. #include "Project.h"
  45. #include "TerminalWrapper.h"
  46. #include "WidgetTool.h"
  47. #include "WidgetTreeModel.h"
  48. #include <AK/LexicalPath.h>
  49. #include <AK/StringBuilder.h>
  50. #include <LibCore/ArgsParser.h>
  51. #include <LibCore/Event.h>
  52. #include <LibCore/EventLoop.h>
  53. #include <LibCore/File.h>
  54. #include <LibDebug/DebugSession.h>
  55. #include <LibGUI/Action.h>
  56. #include <LibGUI/ActionGroup.h>
  57. #include <LibGUI/Application.h>
  58. #include <LibGUI/BoxLayout.h>
  59. #include <LibGUI/Button.h>
  60. #include <LibGUI/Dialog.h>
  61. #include <LibGUI/EditingEngine.h>
  62. #include <LibGUI/FilePicker.h>
  63. #include <LibGUI/InputBox.h>
  64. #include <LibGUI/ItemListModel.h>
  65. #include <LibGUI/Label.h>
  66. #include <LibGUI/Menu.h>
  67. #include <LibGUI/MenuBar.h>
  68. #include <LibGUI/MessageBox.h>
  69. #include <LibGUI/RegularEditingEngine.h>
  70. #include <LibGUI/Splitter.h>
  71. #include <LibGUI/StackWidget.h>
  72. #include <LibGUI/TabWidget.h>
  73. #include <LibGUI/TableView.h>
  74. #include <LibGUI/TextBox.h>
  75. #include <LibGUI/TextEditor.h>
  76. #include <LibGUI/ToolBar.h>
  77. #include <LibGUI/ToolBarContainer.h>
  78. #include <LibGUI/TreeView.h>
  79. #include <LibGUI/VimEditingEngine.h>
  80. #include <LibGUI/Widget.h>
  81. #include <LibGUI/Window.h>
  82. #include <LibGfx/FontDatabase.h>
  83. #include <LibGfx/Palette.h>
  84. #include <LibThread/Lock.h>
  85. #include <LibThread/Thread.h>
  86. #include <LibVT/TerminalWidget.h>
  87. #include <fcntl.h>
  88. #include <spawn.h>
  89. #include <stdio.h>
  90. #include <sys/types.h>
  91. #include <sys/wait.h>
  92. #include <unistd.h>
  93. namespace HackStudio {
  94. HackStudioWidget::HackStudioWidget(const String& path_to_project)
  95. {
  96. set_fill_with_background_color(true);
  97. set_layout<GUI::VerticalBoxLayout>();
  98. layout()->set_spacing(2);
  99. open_project(path_to_project);
  100. auto& toolbar_container = add<GUI::ToolBarContainer>();
  101. auto& outer_splitter = add<GUI::HorizontalSplitter>();
  102. auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>();
  103. left_hand_splitter.set_fixed_width(150);
  104. create_project_tree_view(left_hand_splitter);
  105. m_project_tree_view_context_menu = create_project_tree_view_context_menu();
  106. create_open_files_view(left_hand_splitter);
  107. m_right_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>();
  108. m_right_hand_stack = m_right_hand_splitter->add<GUI::StackWidget>();
  109. // Put a placeholder widget front & center since we don't have a file open yet.
  110. m_right_hand_stack->add<GUI::Widget>();
  111. create_form_editor(*m_right_hand_stack);
  112. m_diff_viewer = m_right_hand_stack->add<DiffViewer>();
  113. m_editors_splitter = m_right_hand_stack->add<GUI::VerticalSplitter>();
  114. m_editors_splitter->layout()->set_margins({ 0, 3, 0, 0 });
  115. add_new_editor(*m_editors_splitter);
  116. m_switch_to_next_editor = create_switch_to_next_editor_action();
  117. m_switch_to_previous_editor = create_switch_to_previous_editor_action();
  118. m_remove_current_editor_action = create_remove_current_editor_action();
  119. m_open_action = create_open_action();
  120. m_save_action = create_save_action();
  121. m_new_project_action = create_new_project_action();
  122. create_action_tab(*m_right_hand_splitter);
  123. m_add_editor_action = create_add_editor_action();
  124. m_add_terminal_action = create_add_terminal_action();
  125. m_remove_current_terminal_action = create_remove_current_terminal_action();
  126. m_locator = add<Locator>();
  127. m_terminal_wrapper->on_command_exit = [this] {
  128. m_stop_action->set_enabled(false);
  129. };
  130. m_build_action = create_build_action();
  131. m_run_action = create_run_action();
  132. m_stop_action = create_stop_action();
  133. m_debug_action = create_debug_action();
  134. initialize_debugger();
  135. create_toolbar(toolbar_container);
  136. }
  137. void HackStudioWidget::update_actions()
  138. {
  139. auto is_remove_terminal_enabled = [this]() {
  140. auto widget = m_action_tab_widget->active_widget();
  141. if (!widget)
  142. return false;
  143. if (StringView { "TerminalWrapper" } != widget->class_name())
  144. return false;
  145. if (!reinterpret_cast<TerminalWrapper*>(widget)->user_spawned())
  146. return false;
  147. return true;
  148. };
  149. m_remove_current_editor_action->set_enabled(m_all_editor_wrappers.size() > 1);
  150. m_remove_current_terminal_action->set_enabled(is_remove_terminal_enabled());
  151. }
  152. void HackStudioWidget::on_action_tab_change()
  153. {
  154. update_actions();
  155. auto git_widget = m_action_tab_widget->active_widget();
  156. if (!git_widget)
  157. return;
  158. if (StringView { "GitWidget" } != git_widget->class_name())
  159. return;
  160. reinterpret_cast<GitWidget*>(git_widget)->refresh();
  161. }
  162. void HackStudioWidget::open_project(const String& root_path)
  163. {
  164. if (chdir(root_path.characters()) < 0) {
  165. perror("chdir");
  166. exit(1);
  167. }
  168. m_project = Project::open_with_root_path(root_path);
  169. VERIFY(m_project);
  170. if (m_project_tree_view) {
  171. m_project_tree_view->set_model(m_project->model());
  172. m_project_tree_view->update();
  173. }
  174. if (Debugger::is_initialized()) {
  175. Debugger::the().reset_breakpoints();
  176. }
  177. }
  178. Vector<String> HackStudioWidget::selected_file_names() const
  179. {
  180. Vector<String> files;
  181. m_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) {
  182. files.append(index.data().as_string());
  183. });
  184. return files;
  185. }
  186. void HackStudioWidget::open_file(const String& full_filename)
  187. {
  188. String filename = full_filename;
  189. if (full_filename.starts_with(project().root_path())) {
  190. filename = LexicalPath::relative_path(full_filename, project().root_path());
  191. }
  192. dbgln("HackStudio is opening {}", filename);
  193. if (Core::File::is_directory(filename))
  194. return;
  195. if (!currently_open_file().is_empty()) {
  196. // Since the file is previously open, it should always be in m_open_files.
  197. VERIFY(m_open_files.find(currently_open_file()) != m_open_files.end());
  198. auto previous_open_project_file = m_open_files.get(currently_open_file()).value();
  199. // Update the scrollbar values of the previous_open_project_file and save them to m_open_files.
  200. previous_open_project_file->vertical_scroll_value(current_editor().vertical_scrollbar().value());
  201. previous_open_project_file->horizontal_scroll_value(current_editor().horizontal_scrollbar().value());
  202. m_open_files.set(currently_open_file(), previous_open_project_file);
  203. }
  204. RefPtr<ProjectFile> new_project_file = nullptr;
  205. if (auto it = m_open_files.find(filename); it != m_open_files.end()) {
  206. new_project_file = it->value;
  207. } else {
  208. new_project_file = m_project->get_file(filename);
  209. m_open_files.set(filename, *new_project_file);
  210. m_open_files_vector.append(filename);
  211. m_open_files_view->model()->update();
  212. }
  213. current_editor().set_document(const_cast<GUI::TextDocument&>(new_project_file->document()));
  214. if (new_project_file->could_render_text()) {
  215. current_editor_wrapper().set_mode_displayable();
  216. } else {
  217. current_editor_wrapper().set_mode_non_displayable();
  218. }
  219. current_editor().horizontal_scrollbar().set_value(new_project_file->horizontal_scroll_value());
  220. current_editor().vertical_scrollbar().set_value(new_project_file->vertical_scroll_value());
  221. current_editor().set_editing_engine(make<GUI::RegularEditingEngine>());
  222. if (filename.ends_with(".frm")) {
  223. set_edit_mode(EditMode::Form);
  224. } else {
  225. set_edit_mode(EditMode::Text);
  226. }
  227. m_currently_open_file = filename;
  228. String relative_file_path = m_currently_open_file;
  229. if (m_currently_open_file.starts_with(m_project->root_path()))
  230. relative_file_path = m_currently_open_file.substring(m_project->root_path().length() + 1);
  231. window()->set_title(String::formatted("{} - {} - Hack Studio", relative_file_path, m_project->name()));
  232. m_project_tree_view->update();
  233. current_editor_wrapper().filename_label().set_text(filename);
  234. current_editor().set_focus(true);
  235. }
  236. EditorWrapper& HackStudioWidget::current_editor_wrapper()
  237. {
  238. VERIFY(m_current_editor_wrapper);
  239. return *m_current_editor_wrapper;
  240. }
  241. GUI::TextEditor& HackStudioWidget::current_editor()
  242. {
  243. return current_editor_wrapper().editor();
  244. }
  245. void HackStudioWidget::set_edit_mode(EditMode mode)
  246. {
  247. if (mode == EditMode::Text) {
  248. m_right_hand_stack->set_active_widget(m_editors_splitter);
  249. } else if (mode == EditMode::Form) {
  250. m_right_hand_stack->set_active_widget(m_form_inner_container);
  251. } else if (mode == EditMode::Diff) {
  252. m_right_hand_stack->set_active_widget(m_diff_viewer);
  253. } else {
  254. VERIFY_NOT_REACHED();
  255. }
  256. m_right_hand_stack->active_widget()->update();
  257. }
  258. NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu()
  259. {
  260. m_open_selected_action = create_open_selected_action();
  261. m_new_file_action = create_new_file_action();
  262. m_new_directory_action = create_new_directory_action();
  263. m_delete_action = create_delete_action();
  264. auto project_tree_view_context_menu = GUI::Menu::construct("Project Files");
  265. project_tree_view_context_menu->add_action(*m_open_selected_action);
  266. // TODO: Rename, cut, copy, duplicate with new name, show containing folder ...
  267. project_tree_view_context_menu->add_separator();
  268. project_tree_view_context_menu->add_action(*m_new_file_action);
  269. project_tree_view_context_menu->add_action(*m_new_directory_action);
  270. project_tree_view_context_menu->add_action(*m_delete_action);
  271. return project_tree_view_context_menu;
  272. }
  273. NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action()
  274. {
  275. return GUI::Action::create("New file...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
  276. String filename;
  277. if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK)
  278. return;
  279. auto file = Core::File::construct(filename);
  280. if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
  281. GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filename), "Error", GUI::MessageBox::Type::Error);
  282. return;
  283. }
  284. open_file(filename);
  285. });
  286. }
  287. NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
  288. {
  289. return GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) {
  290. String directory_name;
  291. if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK)
  292. return;
  293. auto formatted_dir_name = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_project->model().root_path(), directory_name));
  294. int rc = mkdir(formatted_dir_name.characters(), 0755);
  295. if (rc < 0) {
  296. GUI::MessageBox::show(window(), "Failed to create new directory", "Error", GUI::MessageBox::Type::Error);
  297. return;
  298. }
  299. });
  300. }
  301. NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_selected_action()
  302. {
  303. auto open_selected_action = GUI::Action::create("Open", [this](const GUI::Action&) {
  304. auto files = selected_file_names();
  305. for (auto& file : files)
  306. open_file(file);
  307. });
  308. open_selected_action->set_enabled(true);
  309. return open_selected_action;
  310. }
  311. NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
  312. {
  313. auto delete_action = GUI::CommonActions::make_delete_action([this](const GUI::Action&) {
  314. auto files = selected_file_names();
  315. if (files.is_empty())
  316. return;
  317. String message;
  318. if (files.size() == 1) {
  319. message = String::formatted("Really remove {} from disk?", LexicalPath(files[0]).basename());
  320. } else {
  321. message = String::formatted("Really remove {} files from disk?", files.size());
  322. }
  323. auto result = GUI::MessageBox::show(window(),
  324. message,
  325. "Confirm deletion",
  326. GUI::MessageBox::Type::Warning,
  327. GUI::MessageBox::InputType::OKCancel);
  328. if (result == GUI::MessageBox::ExecCancel)
  329. return;
  330. for (auto& file : files) {
  331. struct stat st;
  332. if (lstat(file.characters(), &st) < 0) {
  333. GUI::MessageBox::show(window(),
  334. String::formatted("lstat ({}) failed: {}", file, strerror(errno)),
  335. "Removal failed",
  336. GUI::MessageBox::Type::Error);
  337. break;
  338. }
  339. bool is_directory = S_ISDIR(st.st_mode);
  340. auto result = Core::File::remove(file, Core::File::RecursionMode::Allowed, false);
  341. if (result.is_error()) {
  342. auto& error = result.error();
  343. if (is_directory) {
  344. GUI::MessageBox::show(window(),
  345. String::formatted("Removing directory {} from the project failed: {}", error.file, error.error_code),
  346. "Removal failed",
  347. GUI::MessageBox::Type::Error);
  348. } else {
  349. GUI::MessageBox::show(window(),
  350. String::formatted("Removing file {} from the project failed: {}", error.file, error.error_code),
  351. "Removal failed",
  352. GUI::MessageBox::Type::Error);
  353. }
  354. break;
  355. }
  356. }
  357. });
  358. delete_action->set_enabled(false);
  359. return delete_action;
  360. }
  361. NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action()
  362. {
  363. return GUI::Action::create("New project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/hackstudio-project.png"), [this](const GUI::Action&) {
  364. auto dialog = NewProjectDialog::construct(window());
  365. dialog->set_icon(window()->icon());
  366. auto result = dialog->exec();
  367. if (result == GUI::Dialog::ExecResult::ExecOK && dialog->created_project_path().has_value())
  368. open_project(dialog->created_project_path().value());
  369. });
  370. }
  371. void HackStudioWidget::add_new_editor(GUI::Widget& parent)
  372. {
  373. auto wrapper = EditorWrapper::construct();
  374. if (m_action_tab_widget) {
  375. parent.insert_child_before(wrapper, *m_action_tab_widget);
  376. } else {
  377. parent.add_child(wrapper);
  378. }
  379. m_current_editor_wrapper = wrapper;
  380. m_all_editor_wrappers.append(wrapper);
  381. wrapper->editor().set_focus(true);
  382. }
  383. NonnullRefPtr<GUI::Action> HackStudioWidget::create_switch_to_next_editor_action()
  384. {
  385. return GUI::Action::create("Switch to next editor", { Mod_Ctrl, Key_E }, [this](auto&) {
  386. if (m_all_editor_wrappers.size() <= 1)
  387. return;
  388. Vector<EditorWrapper*> wrappers;
  389. m_editors_splitter->for_each_child_of_type<EditorWrapper>([this, &wrappers](auto& child) {
  390. wrappers.append(&child);
  391. return IterationDecision::Continue;
  392. });
  393. for (size_t i = 0; i < wrappers.size(); ++i) {
  394. if (m_current_editor_wrapper.ptr() == wrappers[i]) {
  395. if (i == wrappers.size() - 1)
  396. wrappers[0]->editor().set_focus(true);
  397. else
  398. wrappers[i + 1]->editor().set_focus(true);
  399. }
  400. }
  401. });
  402. }
  403. NonnullRefPtr<GUI::Action> HackStudioWidget::create_switch_to_previous_editor_action()
  404. {
  405. return GUI::Action::create("Switch to previous editor", { Mod_Ctrl | Mod_Shift, Key_E }, [this](auto&) {
  406. if (m_all_editor_wrappers.size() <= 1)
  407. return;
  408. Vector<EditorWrapper*> wrappers;
  409. m_editors_splitter->for_each_child_of_type<EditorWrapper>([this, &wrappers](auto& child) {
  410. wrappers.append(&child);
  411. return IterationDecision::Continue;
  412. });
  413. for (int i = wrappers.size() - 1; i >= 0; --i) {
  414. if (m_current_editor_wrapper.ptr() == wrappers[i]) {
  415. if (i == 0)
  416. wrappers.last()->editor().set_focus(true);
  417. else
  418. wrappers[i - 1]->editor().set_focus(true);
  419. }
  420. }
  421. });
  422. }
  423. NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_editor_action()
  424. {
  425. return GUI::Action::create("Remove current editor", { Mod_Alt | Mod_Shift, Key_E }, [this](auto&) {
  426. if (m_all_editor_wrappers.size() <= 1)
  427. return;
  428. auto wrapper = m_current_editor_wrapper;
  429. m_switch_to_next_editor->activate();
  430. m_editors_splitter->remove_child(*wrapper);
  431. m_all_editor_wrappers.remove_first_matching([&wrapper](auto& entry) { return entry == wrapper.ptr(); });
  432. update_actions();
  433. });
  434. }
  435. NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_action()
  436. {
  437. return GUI::Action::create("Open project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [this](auto&) {
  438. auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project");
  439. if (!open_path.has_value())
  440. return;
  441. open_project(open_path.value());
  442. update_actions();
  443. });
  444. }
  445. NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_action()
  446. {
  447. return GUI::Action::create("Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [this](auto&) {
  448. if (m_currently_open_file.is_empty())
  449. return;
  450. current_editor().write_to_file(m_currently_open_file);
  451. if (m_git_widget->initialized())
  452. m_git_widget->refresh();
  453. });
  454. }
  455. NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_terminal_action()
  456. {
  457. return GUI::Action::create("Remove current Terminal", { Mod_Alt | Mod_Shift, Key_T }, [this](auto&) {
  458. auto widget = m_action_tab_widget->active_widget();
  459. if (!widget)
  460. return;
  461. if (!is<TerminalWrapper>(widget))
  462. return;
  463. auto& terminal = *static_cast<TerminalWrapper*>(widget);
  464. if (!terminal.user_spawned())
  465. return;
  466. m_action_tab_widget->remove_tab(terminal);
  467. update_actions();
  468. });
  469. }
  470. NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action()
  471. {
  472. return GUI::Action::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E },
  473. Gfx::Bitmap::load_from_file("/res/icons/16x16/app-text-editor.png"),
  474. [this](auto&) {
  475. add_new_editor(*m_editors_splitter);
  476. update_actions();
  477. });
  478. }
  479. NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action()
  480. {
  481. return GUI::Action::create("Add new Terminal", { Mod_Ctrl | Mod_Alt, Key_T },
  482. Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"),
  483. [this](auto&) {
  484. auto& terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Terminal");
  485. reveal_action_tab(terminal_wrapper);
  486. update_actions();
  487. terminal_wrapper.terminal().set_focus(true);
  488. });
  489. }
  490. void HackStudioWidget::reveal_action_tab(GUI::Widget& widget)
  491. {
  492. if (m_action_tab_widget->min_height() < 200)
  493. m_action_tab_widget->set_fixed_height(200);
  494. m_action_tab_widget->set_active_widget(&widget);
  495. }
  496. NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
  497. {
  498. return GUI::Action::create("Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) {
  499. if (!Core::File::exists(get_project_executable_path())) {
  500. GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error);
  501. return;
  502. }
  503. if (Debugger::the().session()) {
  504. GUI::MessageBox::show(window(), "Debugger is already running", "Error", GUI::MessageBox::Type::Error);
  505. return;
  506. }
  507. Debugger::the().set_executable_path(get_project_executable_path());
  508. m_debugger_thread = LibThread::Thread::construct(Debugger::start_static);
  509. m_debugger_thread->start();
  510. });
  511. }
  512. void HackStudioWidget::initialize_debugger()
  513. {
  514. Debugger::initialize(
  515. m_project->root_path(),
  516. [this](const PtraceRegisters& regs) {
  517. VERIFY(Debugger::the().session());
  518. const auto& debug_session = *Debugger::the().session();
  519. auto source_position = debug_session.get_source_position(regs.eip);
  520. if (!source_position.has_value()) {
  521. dbgln("Could not find source position for address: {:p}", regs.eip);
  522. return Debugger::HasControlPassedToUser::No;
  523. }
  524. dbgln("Debugger stopped at source position: {}:{}", source_position.value().file_path, source_position.value().line_number);
  525. Core::EventLoop::main().post_event(
  526. *window(),
  527. make<Core::DeferredInvocationEvent>(
  528. [this, source_position, &regs](auto&) {
  529. m_current_editor_in_execution = get_editor_of_file(source_position.value().file_path);
  530. m_current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1);
  531. m_debug_info_widget->update_state(*Debugger::the().session(), regs);
  532. m_debug_info_widget->set_debug_actions_enabled(true);
  533. m_disassembly_widget->update_state(*Debugger::the().session(), regs);
  534. HackStudioWidget::reveal_action_tab(*m_debug_info_widget);
  535. }));
  536. Core::EventLoop::wake();
  537. return Debugger::HasControlPassedToUser::Yes;
  538. },
  539. [this]() {
  540. Core::EventLoop::main().post_event(*window(), make<Core::DeferredInvocationEvent>([this](auto&) {
  541. m_debug_info_widget->set_debug_actions_enabled(false);
  542. if (m_current_editor_in_execution) {
  543. m_current_editor_in_execution->editor().clear_execution_position();
  544. }
  545. }));
  546. Core::EventLoop::wake();
  547. },
  548. [this]() {
  549. Core::EventLoop::main().post_event(*window(), make<Core::DeferredInvocationEvent>([this](auto&) {
  550. m_debug_info_widget->program_stopped();
  551. m_disassembly_widget->program_stopped();
  552. HackStudioWidget::hide_action_tabs();
  553. GUI::MessageBox::show(window(), "Program Exited", "Debugger", GUI::MessageBox::Type::Information);
  554. }));
  555. Core::EventLoop::wake();
  556. });
  557. }
  558. String HackStudioWidget::get_full_path_of_serenity_source(const String& file)
  559. {
  560. auto path_parts = LexicalPath(file).parts();
  561. VERIFY(path_parts[0] == "..");
  562. path_parts.remove(0);
  563. StringBuilder relative_path_builder;
  564. relative_path_builder.join("/", path_parts);
  565. constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
  566. LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
  567. return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
  568. }
  569. NonnullRefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& file_name)
  570. {
  571. String file_path = file_name;
  572. // TODO: We can probably do a more specific condition here, something like
  573. // "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
  574. if (file_name.starts_with("../")) {
  575. file_path = get_full_path_of_serenity_source(file_name);
  576. }
  577. open_file(file_path);
  578. return current_editor_wrapper();
  579. }
  580. String HackStudioWidget::get_project_executable_path() const
  581. {
  582. // FIXME: Dumb heuristic ahead!
  583. // e.g /my/project => /my/project/project
  584. // TODO: Perhaps a Makefile rule for getting the value of $(PROGRAM) would be better?
  585. return String::formatted("{}/{}", m_project->root_path(), LexicalPath(m_project->root_path()).basename());
  586. }
  587. void HackStudioWidget::build(TerminalWrapper& wrapper)
  588. {
  589. if (m_currently_open_file.ends_with(".js"))
  590. wrapper.run_command(String::formatted("js -A {}", m_currently_open_file));
  591. else
  592. wrapper.run_command("make");
  593. }
  594. void HackStudioWidget::run(TerminalWrapper& wrapper)
  595. {
  596. if (m_currently_open_file.ends_with(".js"))
  597. wrapper.run_command(String::formatted("js {}", m_currently_open_file));
  598. else
  599. wrapper.run_command("make run");
  600. }
  601. void HackStudioWidget::hide_action_tabs()
  602. {
  603. m_action_tab_widget->set_fixed_height(24);
  604. };
  605. Project& HackStudioWidget::project()
  606. {
  607. return *m_project;
  608. }
  609. void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_wrapper)
  610. {
  611. m_current_editor_wrapper = editor_wrapper;
  612. }
  613. void HackStudioWidget::create_project_tree_view(GUI::Widget& parent)
  614. {
  615. m_project_tree_view = parent.add<GUI::TreeView>();
  616. m_project_tree_view->set_model(m_project->model());
  617. m_project_tree_view->set_selection_mode(GUI::AbstractView::SelectionMode::MultiSelection);
  618. for (int column_index = 0; column_index < m_project->model().column_count(); ++column_index)
  619. m_project_tree_view->set_column_hidden(column_index, true);
  620. m_project_tree_view->set_column_hidden(GUI::FileSystemModel::Column::Name, false);
  621. m_project_tree_view->on_context_menu_request = [this](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
  622. if (index.is_valid()) {
  623. m_project_tree_view_context_menu->popup(event.screen_position(), m_open_selected_action);
  624. }
  625. };
  626. m_project_tree_view->on_selection_change = [this] {
  627. m_open_selected_action->set_enabled(!m_project_tree_view->selection().is_empty());
  628. m_delete_action->set_enabled(!m_project_tree_view->selection().is_empty());
  629. };
  630. m_project_tree_view->on_activation = [this](auto& index) {
  631. auto full_path_to_file = m_project->model().full_path(index);
  632. open_file(full_path_to_file);
  633. };
  634. }
  635. void HackStudioWidget::create_open_files_view(GUI::Widget& parent)
  636. {
  637. m_open_files_view = parent.add<GUI::ListView>();
  638. auto open_files_model = GUI::ItemListModel<String>::create(m_open_files_vector);
  639. m_open_files_view->set_model(open_files_model);
  640. m_open_files_view->on_activation = [this](auto& index) {
  641. open_file(index.data().to_string());
  642. };
  643. }
  644. void HackStudioWidget::create_form_editor(GUI::Widget& parent)
  645. {
  646. m_form_inner_container = parent.add<GUI::Widget>();
  647. m_form_inner_container->set_layout<GUI::HorizontalBoxLayout>();
  648. auto& form_widgets_toolbar = m_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26);
  649. form_widgets_toolbar.set_fixed_width(38);
  650. GUI::ActionGroup tool_actions;
  651. tool_actions.set_exclusive(true);
  652. auto cursor_tool_action = GUI::Action::create_checkable("Cursor", Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Cursor.png"), [this](auto&) {
  653. m_form_editor_widget->set_tool(make<CursorTool>(*m_form_editor_widget));
  654. });
  655. cursor_tool_action->set_checked(true);
  656. tool_actions.add_action(cursor_tool_action);
  657. form_widgets_toolbar.add_action(cursor_tool_action);
  658. GUI::WidgetClassRegistration::for_each([&, this](const GUI::WidgetClassRegistration& reg) {
  659. constexpr size_t gui_namespace_prefix_length = sizeof("GUI::") - 1;
  660. auto icon_path = String::formatted("/res/icons/hackstudio/G{}.png",
  661. reg.class_name().substring(gui_namespace_prefix_length, reg.class_name().length() - gui_namespace_prefix_length));
  662. if (!Core::File::exists(icon_path))
  663. return;
  664. auto action = GUI::Action::create_checkable(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [&reg, this](auto&) {
  665. m_form_editor_widget->set_tool(make<WidgetTool>(*m_form_editor_widget, reg));
  666. auto widget = reg.construct();
  667. m_form_editor_widget->form_widget().add_child(widget);
  668. widget->set_relative_rect(30, 30, 30, 30);
  669. m_form_editor_widget->model().update();
  670. });
  671. action->set_checked(false);
  672. tool_actions.add_action(action);
  673. form_widgets_toolbar.add_action(move(action));
  674. });
  675. auto& form_editor_inner_splitter = m_form_inner_container->add<GUI::HorizontalSplitter>();
  676. m_form_editor_widget = form_editor_inner_splitter.add<FormEditorWidget>();
  677. auto& form_editing_pane_container = form_editor_inner_splitter.add<GUI::VerticalSplitter>();
  678. form_editing_pane_container.set_fixed_width(190);
  679. form_editing_pane_container.set_layout<GUI::VerticalBoxLayout>();
  680. auto add_properties_pane = [&](auto& text, auto& pane_widget) {
  681. auto& wrapper = form_editing_pane_container.add<GUI::Widget>();
  682. wrapper.set_layout<GUI::VerticalBoxLayout>();
  683. auto& label = wrapper.add<GUI::Label>(text);
  684. label.set_fill_with_background_color(true);
  685. label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
  686. label.set_font(Gfx::FontDatabase::default_bold_font());
  687. label.set_fixed_height(16);
  688. wrapper.add_child(pane_widget);
  689. };
  690. m_form_widget_tree_view = GUI::TreeView::construct();
  691. m_form_widget_tree_view->set_model(m_form_editor_widget->model());
  692. m_form_widget_tree_view->on_selection_change = [this] {
  693. m_form_editor_widget->selection().disable_hooks();
  694. m_form_editor_widget->selection().clear();
  695. m_form_widget_tree_view->selection().for_each_index([this](auto& index) {
  696. // NOTE: Make sure we don't add the FormWidget itself to the selection,
  697. // since that would allow you to drag-move the FormWidget.
  698. if (index.internal_data() != &m_form_editor_widget->form_widget())
  699. m_form_editor_widget->selection().add(*(GUI::Widget*)index.internal_data());
  700. });
  701. m_form_editor_widget->update();
  702. m_form_editor_widget->selection().enable_hooks();
  703. };
  704. m_form_editor_widget->selection().on_add = [this](auto& widget) {
  705. m_form_widget_tree_view->selection().add(m_form_editor_widget->model().index_for_widget(widget));
  706. };
  707. m_form_editor_widget->selection().on_remove = [this](auto& widget) {
  708. m_form_widget_tree_view->selection().remove(m_form_editor_widget->model().index_for_widget(widget));
  709. };
  710. m_form_editor_widget->selection().on_clear = [this] {
  711. m_form_widget_tree_view->selection().clear();
  712. };
  713. add_properties_pane("Form widget tree:", *m_form_widget_tree_view);
  714. add_properties_pane("Widget properties:", *GUI::TableView::construct());
  715. }
  716. void HackStudioWidget::create_toolbar(GUI::Widget& parent)
  717. {
  718. auto& toolbar = parent.add<GUI::ToolBar>();
  719. toolbar.add_action(*m_new_file_action);
  720. toolbar.add_action(*m_new_directory_action);
  721. toolbar.add_action(*m_save_action);
  722. toolbar.add_action(*m_delete_action);
  723. toolbar.add_separator();
  724. toolbar.add_action(GUI::CommonActions::make_cut_action([this](auto&) { current_editor().cut_action().activate(); }));
  725. toolbar.add_action(GUI::CommonActions::make_copy_action([this](auto&) { current_editor().copy_action().activate(); }));
  726. toolbar.add_action(GUI::CommonActions::make_paste_action([this](auto&) { current_editor().paste_action().activate(); }));
  727. toolbar.add_separator();
  728. toolbar.add_action(GUI::CommonActions::make_undo_action([this](auto&) { current_editor().undo_action().activate(); }));
  729. toolbar.add_action(GUI::CommonActions::make_redo_action([this](auto&) { current_editor().redo_action().activate(); }));
  730. toolbar.add_separator();
  731. toolbar.add_action(*m_build_action);
  732. toolbar.add_separator();
  733. toolbar.add_action(*m_run_action);
  734. toolbar.add_action(*m_stop_action);
  735. toolbar.add_separator();
  736. toolbar.add_action(*m_debug_action);
  737. }
  738. NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action()
  739. {
  740. return GUI::Action::create("Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::load_from_file("/res/icons/16x16/build.png"), [this](auto&) {
  741. reveal_action_tab(*m_terminal_wrapper);
  742. build(*m_terminal_wrapper);
  743. m_stop_action->set_enabled(true);
  744. });
  745. }
  746. NonnullRefPtr<GUI::Action> HackStudioWidget::create_run_action()
  747. {
  748. return GUI::Action::create("Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/program-run.png"), [this](auto&) {
  749. reveal_action_tab(*m_terminal_wrapper);
  750. run(*m_terminal_wrapper);
  751. m_stop_action->set_enabled(true);
  752. });
  753. }
  754. void HackStudioWidget::create_action_tab(GUI::Widget& parent)
  755. {
  756. m_action_tab_widget = parent.add<GUI::TabWidget>();
  757. m_action_tab_widget->set_fixed_height(24);
  758. m_action_tab_widget->on_change = [this](auto&) {
  759. on_action_tab_change();
  760. static bool first_time = true;
  761. if (!first_time)
  762. m_action_tab_widget->set_fixed_height(200);
  763. first_time = false;
  764. };
  765. m_find_in_files_widget = m_action_tab_widget->add_tab<FindInFilesWidget>("Find in files");
  766. m_terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Build", false);
  767. m_debug_info_widget = m_action_tab_widget->add_tab<DebugInfoWidget>("Debug");
  768. m_disassembly_widget = m_action_tab_widget->add_tab<DisassemblyWidget>("Disassembly");
  769. m_git_widget = m_action_tab_widget->add_tab<GitWidget>("Git", LexicalPath(m_project->root_path()));
  770. m_git_widget->set_view_diff_callback([this](const auto& original_content, const auto& diff) {
  771. m_diff_viewer->set_content(original_content, diff);
  772. set_edit_mode(EditMode::Diff);
  773. });
  774. }
  775. void HackStudioWidget::create_app_menubar(GUI::MenuBar& menubar)
  776. {
  777. auto& app_menu = menubar.add_menu("Hack Studio");
  778. app_menu.add_action(*m_new_project_action);
  779. app_menu.add_action(*m_open_action);
  780. app_menu.add_action(*m_save_action);
  781. app_menu.add_separator();
  782. app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
  783. GUI::Application::the()->quit();
  784. }));
  785. }
  786. void HackStudioWidget::create_project_menubar(GUI::MenuBar& menubar)
  787. {
  788. auto& project_menu = menubar.add_menu("Project");
  789. project_menu.add_action(*m_new_file_action);
  790. project_menu.add_action(*m_new_directory_action);
  791. project_menu.add_separator();
  792. project_menu.add_action(*create_set_autocomplete_mode_action());
  793. }
  794. void HackStudioWidget::create_edit_menubar(GUI::MenuBar& menubar)
  795. {
  796. auto& edit_menu = menubar.add_menu("Edit");
  797. edit_menu.add_action(GUI::Action::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [this](auto&) {
  798. reveal_action_tab(*m_find_in_files_widget);
  799. m_find_in_files_widget->focus_textbox_and_select_all();
  800. }));
  801. edit_menu.add_separator();
  802. auto vim_emulation_setting_action = GUI::Action::create_checkable("Vim emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [this](auto& action) {
  803. if (action.is_checked())
  804. current_editor().set_editing_engine(make<GUI::VimEditingEngine>());
  805. else
  806. current_editor().set_editing_engine(make<GUI::RegularEditingEngine>());
  807. });
  808. vim_emulation_setting_action->set_checked(false);
  809. edit_menu.add_action(vim_emulation_setting_action);
  810. }
  811. void HackStudioWidget::create_build_menubar(GUI::MenuBar& menubar)
  812. {
  813. auto& build_menu = menubar.add_menu("Build");
  814. build_menu.add_action(*m_build_action);
  815. build_menu.add_separator();
  816. build_menu.add_action(*m_run_action);
  817. build_menu.add_action(*m_stop_action);
  818. build_menu.add_separator();
  819. build_menu.add_action(*m_debug_action);
  820. }
  821. void HackStudioWidget::create_view_menubar(GUI::MenuBar& menubar)
  822. {
  823. auto hide_action_tabs_action = GUI::Action::create("Hide action tabs", { Mod_Ctrl | Mod_Shift, Key_X }, [this](auto&) {
  824. hide_action_tabs();
  825. });
  826. auto open_locator_action = GUI::Action::create("Open locator", { Mod_Ctrl, Key_K }, [this](auto&) {
  827. m_locator->open();
  828. });
  829. auto& view_menu = menubar.add_menu("View");
  830. view_menu.add_action(hide_action_tabs_action);
  831. view_menu.add_action(open_locator_action);
  832. view_menu.add_separator();
  833. m_wrapping_mode_actions.set_exclusive(true);
  834. auto& wrapping_mode_menu = view_menu.add_submenu("Wrapping mode");
  835. m_no_wrapping_action = GUI::Action::create_checkable("No wrapping", [&](auto&) {
  836. for (auto& wrapper : m_all_editor_wrappers)
  837. wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
  838. });
  839. m_wrap_anywhere_action = GUI::Action::create_checkable("Wrap anywhere", [&](auto&) {
  840. for (auto& wrapper : m_all_editor_wrappers)
  841. wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
  842. });
  843. m_wrap_at_words_action = GUI::Action::create_checkable("Wrap at words", [&](auto&) {
  844. for (auto& wrapper : m_all_editor_wrappers)
  845. wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
  846. });
  847. m_wrapping_mode_actions.add_action(*m_no_wrapping_action);
  848. m_wrapping_mode_actions.add_action(*m_wrap_anywhere_action);
  849. m_wrapping_mode_actions.add_action(*m_wrap_at_words_action);
  850. wrapping_mode_menu.add_action(*m_no_wrapping_action);
  851. wrapping_mode_menu.add_action(*m_wrap_anywhere_action);
  852. wrapping_mode_menu.add_action(*m_wrap_at_words_action);
  853. m_no_wrapping_action->set_checked(true);
  854. view_menu.add_separator();
  855. view_menu.add_action(*m_add_editor_action);
  856. view_menu.add_action(*m_remove_current_editor_action);
  857. view_menu.add_action(*m_add_terminal_action);
  858. view_menu.add_action(*m_remove_current_terminal_action);
  859. }
  860. void HackStudioWidget::create_help_menubar(GUI::MenuBar& menubar)
  861. {
  862. auto& help_menu = menubar.add_menu("Help");
  863. help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"), window()));
  864. }
  865. NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action()
  866. {
  867. auto action = GUI::Action::create("Stop", Gfx::Bitmap::load_from_file("/res/icons/16x16/program-stop.png"), [this](auto&) {
  868. m_terminal_wrapper->kill_running_command();
  869. });
  870. action->set_enabled(false);
  871. return action;
  872. }
  873. NonnullRefPtr<GUI::Action> HackStudioWidget::create_set_autocomplete_mode_action()
  874. {
  875. auto action = GUI::Action::create_checkable("AutoComplete C++ with Parser", [this](auto& action) {
  876. get_language_client<LanguageClients::Cpp::ServerConnection>(project().root_path())->set_autocomplete_mode(action.is_checked() ? "Parser" : "Lexer");
  877. });
  878. action->set_checked(true);
  879. return action;
  880. }
  881. void HackStudioWidget::initialize_menubar(GUI::MenuBar& menubar)
  882. {
  883. create_app_menubar(menubar);
  884. create_project_menubar(menubar);
  885. create_edit_menubar(menubar);
  886. create_build_menubar(menubar);
  887. create_view_menubar(menubar);
  888. create_help_menubar(menubar);
  889. }
  890. HackStudioWidget::~HackStudioWidget()
  891. {
  892. if (!m_debugger_thread.is_null()) {
  893. Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Exit);
  894. dbgln("Waiting for debugger thread to terminate");
  895. auto rc = m_debugger_thread->join();
  896. if (rc.is_error()) {
  897. warnln("pthread_join: {}", strerror(rc.error().value()));
  898. dbgln("error joining debugger thread");
  899. }
  900. }
  901. }
  902. }