diff --git a/DevTools/HackStudio/Debugger/VariablesModel.cpp b/DevTools/HackStudio/Debugger/VariablesModel.cpp index 7c8e914d30..8f63a2b0e5 100644 --- a/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -68,7 +68,7 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const return node->members.size(); } -String variable_value_as_string(const DebugInfo::VariableInfo& variable) +static String variable_value_as_string(const DebugInfo::VariableInfo& variable) { if (variable.location_type != DebugInfo::VariableInfo::LocationType::Address) return "N/A"; diff --git a/DevTools/HackStudio/EditorWrapper.cpp b/DevTools/HackStudio/EditorWrapper.cpp index 1ee9eefb68..dae1c2b49a 100644 --- a/DevTools/HackStudio/EditorWrapper.cpp +++ b/DevTools/HackStudio/EditorWrapper.cpp @@ -26,15 +26,13 @@ #include "EditorWrapper.h" #include "Editor.h" +#include "HackStudio.h" #include #include #include #include #include -extern RefPtr g_current_editor_wrapper; -extern Function g_open_file; - EditorWrapper::EditorWrapper(BreakpointChangeCallback breakpoint_change_callback) { set_layout(); @@ -69,7 +67,7 @@ EditorWrapper::EditorWrapper(BreakpointChangeCallback breakpoint_change_callback g_current_editor_wrapper = this; }; - m_editor->on_open = [this](String path) { + m_editor->on_open = [](String path) { g_open_file(path); }; diff --git a/DevTools/HackStudio/FindInFilesWidget.cpp b/DevTools/HackStudio/FindInFilesWidget.cpp index ecc70acc97..be64bc8d38 100644 --- a/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/DevTools/HackStudio/FindInFilesWidget.cpp @@ -25,6 +25,7 @@ */ #include "FindInFilesWidget.h" +#include "HackStudio.h" #include "Project.h" #include #include @@ -32,10 +33,6 @@ #include #include -extern GUI::TextEditor& current_editor(); -extern void open_file(const String&); -extern OwnPtr g_project; - struct Match { String filename; GUI::TextRange range; diff --git a/DevTools/HackStudio/HackStudio.h b/DevTools/HackStudio/HackStudio.h new file mode 100644 index 0000000000..cc66517ae0 --- /dev/null +++ b/DevTools/HackStudio/HackStudio.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "EditorWrapper.h" +#include "Project.h" +#include +#include + +GUI::TextEditor& current_editor(); +void open_file(const String&); + +extern RefPtr g_current_editor_wrapper; +extern Function g_open_file; +extern OwnPtr g_project; +extern String g_currently_open_file; diff --git a/DevTools/HackStudio/Locator.cpp b/DevTools/HackStudio/Locator.cpp index 2a9cc5205a..f944772a62 100644 --- a/DevTools/HackStudio/Locator.cpp +++ b/DevTools/HackStudio/Locator.cpp @@ -25,14 +25,13 @@ */ #include "Locator.h" +#include "HackStudio.h" #include "Project.h" #include #include #include #include -extern RefPtr g_project; -extern void open_file(const String&); static RefPtr s_file_icon; static RefPtr s_cplusplus_icon; static RefPtr s_header_icon; diff --git a/DevTools/HackStudio/Project.cpp b/DevTools/HackStudio/Project.cpp index 8eeae3e418..c247d21fb1 100644 --- a/DevTools/HackStudio/Project.cpp +++ b/DevTools/HackStudio/Project.cpp @@ -25,6 +25,7 @@ */ #include "Project.h" +#include "HackStudio.h" #include #include #include @@ -117,7 +118,6 @@ public: return m_project.m_file_icon; } if (role == Role::Font) { - extern String g_currently_open_file; if (node->name == g_currently_open_file) return Gfx::Font::default_bold_font(); return {}; diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 82075b0c31..aa7d91a3ea 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -32,6 +32,7 @@ #include "FindInFilesWidget.h" #include "FormEditorWidget.h" #include "FormWidget.h" +#include "HackStudio.h" #include "Locator.h" #include "Project.h" #include "TerminalWrapper.h" @@ -91,7 +92,7 @@ RefPtr g_form_editor_widget; static RefPtr s_action_tab_widget; -void add_new_editor(GUI::Widget& parent) +static void add_new_editor(GUI::Widget& parent) { auto wrapper = EditorWrapper::construct(Debugger::on_breakpoint_change); if (s_action_tab_widget) { @@ -109,7 +110,7 @@ enum class EditMode { Form, }; -void set_edit_mode(EditMode mode) +static void set_edit_mode(EditMode mode) { if (mode == EditMode::Text) { g_right_hand_stack->set_active_widget(g_text_inner_splitter); @@ -118,18 +119,18 @@ void set_edit_mode(EditMode mode) } } -EditorWrapper& current_editor_wrapper() +static EditorWrapper& current_editor_wrapper() { ASSERT(g_current_editor_wrapper); return *g_current_editor_wrapper; } -Editor& current_editor() +GUI::TextEditor& current_editor() { return current_editor_wrapper().editor(); } -NonnullRefPtr get_editor_of_file(const String& file) +static NonnullRefPtr get_editor_of_file(const String& file) { for (auto& wrapper : g_all_editor_wrappers) { String wrapper_file = wrapper.filename_label().text(); @@ -140,7 +141,7 @@ NonnullRefPtr get_editor_of_file(const String& file) ASSERT_NOT_REACHED(); } -String get_project_executable_path() +static String get_project_executable_path() { // e.g /my/project.hackstudio => /my/project // TODO: Perhaps a Makefile rule for getting the value of $(PROGRAM) would be better?