1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

HackStudio: Move everything into the HackStudio namespace

This commit is contained in:
Andreas Kling 2020-08-17 15:22:30 +02:00
parent ce48de9845
commit c0462c65cf
40 changed files with 184 additions and 18 deletions

View file

@ -23,12 +23,16 @@
* 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.
*/
#include "CodeDocument.h"
namespace HackStudio {
NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
{
return adopt(*new CodeDocument(client));
}
CodeDocument::CodeDocument(Client* client)
: TextDocument(client)
{
@ -37,3 +41,5 @@ CodeDocument::CodeDocument(Client* client)
CodeDocument::~CodeDocument()
{
}
}

View file

@ -28,6 +28,8 @@
#include <LibGUI/TextDocument.h>
namespace HackStudio {
class CodeDocument final : public GUI::TextDocument {
public:
virtual ~CodeDocument() override;
@ -47,3 +49,5 @@ private:
Vector<size_t> m_breakpoint_lines;
Optional<size_t> m_execution_position;
};
}

View file

@ -31,6 +31,8 @@
#include <AK/LogStream.h>
#include <LibGfx/Palette.h>
namespace HackStudio {
void CursorTool::on_mousedown(GUI::MouseEvent& event)
{
dbg() << "CursorTool::on_mousedown";
@ -186,3 +188,5 @@ void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&)
painter.fill_rect(rect, m_editor.palette().rubber_band_fill());
painter.draw_rect(rect, m_editor.palette().rubber_band_border());
}
}

View file

@ -31,13 +31,15 @@
#include <LibGUI/Forward.h>
#include <LibGfx/Point.h>
namespace HackStudio {
class CursorTool final : public Tool {
public:
explicit CursorTool(FormEditorWidget& editor)
: Tool(editor)
{
}
virtual ~CursorTool() override {}
virtual ~CursorTool() override { }
private:
virtual const char* class_name() const override { return "CursorTool"; }
@ -58,3 +60,5 @@ private:
Gfx::IntPoint m_rubber_band_origin;
Gfx::IntPoint m_rubber_band_position;
};
}

View file

@ -27,6 +27,8 @@
#include "BacktraceModel.h"
#include "Debugger.h"
namespace HackStudio {
NonnullRefPtr<BacktraceModel> BacktraceModel::create(const DebugSession& debug_session, const PtraceRegisters& regs)
{
return adopt(*new BacktraceModel(create_backtrace(debug_session, regs)));
@ -66,3 +68,5 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const DebugSe
} while (current_ebp && current_instruction);
return frames;
}
}

View file

@ -33,6 +33,8 @@
class DebugSession;
namespace HackStudio {
class BacktraceModel final : public GUI::Model {
public:
static NonnullRefPtr<BacktraceModel> create(const DebugSession&, const PtraceRegisters& regs);
@ -47,7 +49,7 @@ public:
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual void update() override {}
virtual void update() override { }
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
struct FrameInfo {
@ -68,3 +70,5 @@ private:
Vector<FrameInfo> m_frames;
};
}

View file

@ -30,9 +30,13 @@
#include <AK/String.h>
#include <AK/Types.h>
namespace HackStudio {
enum class BreakpointChange {
Added,
Removed,
};
typedef Function<void(const String& file, size_t line, BreakpointChange)> BreakpointChangeCallback;
}

View file

@ -38,6 +38,8 @@
#include <LibGUI/Splitter.h>
#include <LibGUI/TreeView.h>
namespace HackStudio {
DebugInfoWidget::DebugInfoWidget()
{
set_layout<GUI::HorizontalBoxLayout>();
@ -108,3 +110,5 @@ void DebugInfoWidget::program_stopped()
{
m_variables_view->set_model({});
}
}

View file

@ -27,16 +27,18 @@
#pragma once
#include "Debugger.h"
#include "LibGUI/ListView.h"
#include <AK/NonnullOwnPtr.h>
#include <LibGUI/ListView.h>
#include <LibGUI/Model.h>
#include <LibGUI/Widget.h>
#include <sys/arch/i386/regs.h>
namespace HackStudio {
class DebugInfoWidget final : public GUI::Widget {
C_OBJECT(DebugInfoWidget)
public:
virtual ~DebugInfoWidget() override {}
virtual ~DebugInfoWidget() override { }
void update_state(const DebugSession&, const PtraceRegisters&);
void program_stopped();
@ -48,3 +50,5 @@ private:
RefPtr<GUI::ListView> m_backtrace_view;
RefPtr<GUI::Menu> m_variable_context_menu;
};
}

View file

@ -26,6 +26,8 @@
#include "Debugger.h"
namespace HackStudio {
static Debugger* s_the;
Debugger& Debugger::the()
@ -183,8 +185,11 @@ void Debugger::DebuggingState::set_single_stepping(DebugInfo::SourcePosition ori
m_state = State::SingleStepping;
m_original_source_position = original_source_position;
}
bool Debugger::DebuggingState::should_stop_single_stepping(const DebugInfo::SourcePosition& current_source_position) const
{
ASSERT(m_state == State::SingleStepping);
return m_original_source_position.value() != current_source_position;
}
}

View file

@ -33,6 +33,8 @@
#include <LibThread/Lock.h>
#include <LibThread/Thread.h>
namespace HackStudio {
class Debugger {
public:
static Debugger& the();
@ -110,3 +112,5 @@ private:
ContinueType m_continue_type { ContinueType::Continue };
};
}

View file

@ -28,6 +28,8 @@
#include <LibGUI/Application.h>
#include <LibGUI/MessageBox.h>
namespace HackStudio {
GUI::ModelIndex VariablesModel::index(int row, int column, const GUI::ModelIndex& parent_index) const
{
if (!parent_index.is_valid())
@ -184,3 +186,5 @@ RefPtr<VariablesModel> VariablesModel::create(const PtraceRegisters& regs)
auto variables = Debugger::the().session()->debug_info().get_variables_in_current_scope(regs);
return adopt(*new VariablesModel(move(variables), regs));
}
}

View file

@ -32,6 +32,8 @@
#include <LibGUI/TreeView.h>
#include <sys/arch/i386/regs.h>
namespace HackStudio {
class VariablesModel final : public GUI::Model {
public:
static RefPtr<VariablesModel> create(const PtraceRegisters& regs);
@ -57,3 +59,5 @@ private:
GUI::Icon m_variable_icon;
};
}

View file

@ -44,6 +44,8 @@
// #define EDITOR_DEBUG
namespace HackStudio {
Editor::Editor()
{
m_documentation_tooltip_window = GUI::Window::construct();
@ -417,3 +419,5 @@ void Editor::set_document(GUI::TextDocument& doc)
ASSERT(doc.is_code_document());
GUI::TextEditor::set_document(doc);
}
}

View file

@ -32,6 +32,8 @@
#include <LibGUI/TextEditor.h>
#include <LibWeb/Forward.h>
namespace HackStudio {
class EditorWrapper;
class Editor final : public GUI::TextEditor {
@ -86,3 +88,5 @@ private:
bool m_hovering_link { false };
bool m_holding_ctrl { false };
};
}

View file

@ -33,6 +33,8 @@
#include <LibGUI/Label.h>
#include <LibGfx/Font.h>
namespace HackStudio {
EditorWrapper::EditorWrapper(BreakpointChangeCallback breakpoint_change_callback)
{
set_layout<GUI::VerticalBoxLayout>();
@ -82,3 +84,5 @@ void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus)
{
m_filename_label->set_font(focus ? Gfx::Font::default_bold_font() : Gfx::Font::default_font());
}
}

View file

@ -32,6 +32,8 @@
#include <LibGUI/Widget.h>
#include <string.h>
namespace HackStudio {
class Editor;
class EditorWrapper : public GUI::Widget {
@ -55,6 +57,8 @@ private:
RefPtr<Editor> m_editor;
};
AK_BEGIN_TYPE_TRAITS(EditorWrapper)
}
AK_BEGIN_TYPE_TRAITS(HackStudio::EditorWrapper)
static bool is_type(const Core::Object& object) { return !strcmp(object.class_name(), "EditorWrapper"); }
AK_END_TYPE_TRAITS()

View file

@ -33,6 +33,8 @@
#include <LibGUI/TableView.h>
#include <LibGUI/TextBox.h>
namespace HackStudio {
struct Match {
String filename;
GUI::TextRange range;
@ -162,3 +164,5 @@ void FindInFilesWidget::focus_textbox_and_select_all()
m_textbox->select_all();
m_textbox->set_focus(true);
}
}

View file

@ -28,10 +28,12 @@
#include <LibGUI/Widget.h>
namespace HackStudio {
class FindInFilesWidget final : public GUI::Widget {
C_OBJECT(FindInFilesWidget)
public:
virtual ~FindInFilesWidget() override {}
virtual ~FindInFilesWidget() override { }
void focus_textbox_and_select_all();
@ -42,3 +44,5 @@ private:
RefPtr<GUI::Button> m_button;
RefPtr<GUI::TableView> m_result_view;
};
}

View file

@ -30,6 +30,8 @@
#include "WidgetTreeModel.h"
#include <LibGUI/Painter.h>
namespace HackStudio {
FormEditorWidget::FormEditorWidget()
: m_tool(make<CursorTool>(*this))
{
@ -63,3 +65,5 @@ WidgetTreeModel& FormEditorWidget::model()
{
return *m_widget_tree_model;
}
}

View file

@ -29,6 +29,8 @@
#include <AK/HashTable.h>
#include <LibGUI/ScrollableWidget.h>
namespace HackStudio {
class FormWidget;
class Tool;
class WidgetTreeModel;
@ -112,7 +114,7 @@ public:
}
}
WidgetSelection() {}
WidgetSelection() { }
private:
HashTable<GUI::Widget*> m_widgets;
@ -131,3 +133,5 @@ private:
NonnullOwnPtr<Tool> m_tool;
WidgetSelection m_selection;
};
}

View file

@ -29,6 +29,8 @@
#include "Tool.h"
#include <LibGUI/Painter.h>
namespace HackStudio {
FormWidget::FormWidget()
{
set_fill_with_background_color(true);
@ -99,3 +101,5 @@ void FormWidget::keydown_event(GUI::KeyEvent& event)
{
editor().tool().on_keydown(event);
}
}

View file

@ -29,6 +29,8 @@
#include <AK/Badge.h>
#include <LibGUI/Widget.h>
namespace HackStudio {
class CursorTool;
class FormEditorWidget;
@ -57,3 +59,5 @@ private:
int m_grid_size { 5 };
};
}

View file

@ -31,6 +31,8 @@
#include <AK/String.h>
#include <LibGUI/TextEditor.h>
namespace HackStudio {
GUI::TextEditor& current_editor();
void open_file(const String&);
@ -38,3 +40,5 @@ extern RefPtr<EditorWrapper> g_current_editor_wrapper;
extern Function<void(String)> g_open_file;
extern OwnPtr<Project> g_project;
extern String g_currently_open_file;
}

View file

@ -32,6 +32,8 @@
#include <LibGUI/TextBox.h>
#include <LibGUI/Window.h>
namespace HackStudio {
static RefPtr<Gfx::Bitmap> s_file_icon;
static RefPtr<Gfx::Bitmap> s_cplusplus_icon;
static RefPtr<Gfx::Bitmap> s_header_icon;
@ -187,3 +189,5 @@ void Locator::update_suggestions()
dbg() << "Popup rect: " << m_popup_window->rect();
m_popup_window->show();
}
}

View file

@ -28,6 +28,8 @@
#include <LibGUI/Widget.h>
namespace HackStudio {
class Locator final : public GUI::Widget {
C_OBJECT(Locator)
public:
@ -46,3 +48,5 @@ private:
RefPtr<GUI::Window> m_popup_window;
RefPtr<GUI::TableView> m_suggestion_view;
};
}

View file

@ -32,6 +32,8 @@
#include <LibGfx/Font.h>
#include <unistd.h>
namespace HackStudio {
ProcessStateWidget::ProcessStateWidget()
{
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
@ -96,3 +98,5 @@ void ProcessStateWidget::set_tty_fd(int tty_fd)
set_visible(true);
refresh();
}
}

View file

@ -28,6 +28,8 @@
#include <LibGUI/Widget.h>
namespace HackStudio {
class ProcessStateWidget final : public GUI::Widget {
C_OBJECT(ProcessStateWidget)
public:
@ -49,3 +51,5 @@ private:
int m_tty_fd { -1 };
};
}

View file

@ -36,6 +36,8 @@
#include <sys/stat.h>
#include <unistd.h>
namespace HackStudio {
struct Project::ProjectTreeNode : public RefCounted<ProjectTreeNode> {
enum class Type {
Invalid,
@ -358,3 +360,5 @@ void Project::rebuild_tree()
m_root_node = move(root);
m_model->update();
}
}

View file

@ -33,6 +33,8 @@
#include <LibGUI/Icon.h>
#include <LibGUI/Model.h>
namespace HackStudio {
enum class ProjectType {
Unknown,
Cpp,
@ -88,3 +90,5 @@ private:
GUI::Icon m_header_icon;
GUI::Icon m_project_icon;
};
}

View file

@ -28,6 +28,8 @@
#include <LibCore/File.h>
#include <string.h>
namespace HackStudio {
ProjectFile::ProjectFile(const String& name)
: m_name(name)
{
@ -45,3 +47,5 @@ const GUI::TextDocument& ProjectFile::document() const
}
return *m_document;
}
}

View file

@ -32,6 +32,8 @@
#include <AK/RefCounted.h>
#include <AK/String.h>
namespace HackStudio {
class ProjectFile : public RefCounted<ProjectFile> {
public:
static NonnullRefPtr<ProjectFile> construct_with_name(const String& name)
@ -49,3 +51,5 @@ private:
String m_name;
mutable RefPtr<CodeDocument> m_document;
};
}

View file

@ -41,6 +41,8 @@
#include <sys/wait.h>
#include <unistd.h>
namespace HackStudio {
void TerminalWrapper::run_command(const String& command)
{
if (m_pid != -1) {
@ -183,3 +185,5 @@ TerminalWrapper::TerminalWrapper(bool user_spawned)
TerminalWrapper::~TerminalWrapper()
{
}
}

View file

@ -28,9 +28,12 @@
#include <LibGUI/Widget.h>
class ProcessStateWidget;
class TerminalWidget;
namespace HackStudio {
class ProcessStateWidget;
class TerminalWrapper final : public GUI::Widget {
C_OBJECT(TerminalWrapper)
public:
@ -52,3 +55,5 @@ private:
pid_t m_pid { -1 };
bool m_user_spawned { true };
};
}

View file

@ -29,24 +29,26 @@
#include <AK/Noncopyable.h>
#include <LibGUI/Forward.h>
namespace HackStudio {
class FormEditorWidget;
class Tool {
AK_MAKE_NONCOPYABLE(Tool)
AK_MAKE_NONMOVABLE(Tool)
public:
virtual ~Tool() {}
virtual ~Tool() { }
virtual void on_mousedown(GUI::MouseEvent&) = 0;
virtual void on_mouseup(GUI::MouseEvent&) = 0;
virtual void on_mousemove(GUI::MouseEvent&) = 0;
virtual void on_keydown(GUI::KeyEvent&) = 0;
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) {}
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) { }
virtual const char* class_name() const = 0;
virtual void attach() {}
virtual void detach() {}
virtual void attach() { }
virtual void detach() { }
protected:
explicit Tool(FormEditorWidget& editor)
@ -56,3 +58,5 @@ protected:
FormEditorWidget& m_editor;
};
}

View file

@ -27,6 +27,8 @@
#include "WidgetTool.h"
#include <AK/LogStream.h>
namespace HackStudio {
void WidgetTool::on_mousedown(GUI::MouseEvent& event)
{
(void)event;
@ -50,3 +52,5 @@ void WidgetTool::on_keydown(GUI::KeyEvent& event)
(void)event;
dbg() << "WidgetTool::on_keydown";
}
}

View file

@ -28,9 +28,7 @@
#include "Tool.h"
namespace GUI {
class WidgetClassRegistration;
}
namespace HackStudio {
class WidgetTool final : public Tool {
public:
@ -39,7 +37,7 @@ public:
, m_meta_class(meta_class)
{
}
virtual ~WidgetTool() override {}
virtual ~WidgetTool() override { }
private:
virtual const char* class_name() const override { return "WidgetTool"; }
@ -50,3 +48,5 @@ private:
const GUI::WidgetClassRegistration& m_meta_class;
};
}

View file

@ -27,7 +27,8 @@
#include "WidgetTreeModel.h"
#include <AK/StringBuilder.h>
#include <LibGUI/Widget.h>
#include <stdio.h>
namespace HackStudio {
WidgetTreeModel::WidgetTreeModel(GUI::Widget& root)
: m_root(root)
@ -112,3 +113,5 @@ GUI::ModelIndex WidgetTreeModel::index_for_widget(GUI::Widget& widget) const
}
return {};
}
}

View file

@ -29,6 +29,8 @@
#include <LibGUI/Model.h>
#include <LibGUI/Painter.h>
namespace HackStudio {
class WidgetTreeModel final : public GUI::Model {
public:
static NonnullRefPtr<WidgetTreeModel> create(GUI::Widget& root) { return adopt(*new WidgetTreeModel(root)); }
@ -49,3 +51,5 @@ private:
NonnullRefPtr<GUI::Widget> m_root;
GUI::Icon m_widget_icon;
};
}

View file

@ -80,6 +80,10 @@
#include <sys/wait.h>
#include <unistd.h>
using namespace HackStudio;
namespace HackStudio {
NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers;
RefPtr<EditorWrapper> g_current_editor_wrapper;
Function<void(String)> g_open_file;
@ -172,7 +176,7 @@ static String get_project_executable_path()
return g_project->path().substring(0, g_project->path().index_of(".").value());
}
int main(int argc, char** argv)
int main_impl(int argc, char** argv)
{
if (pledge("stdio tty accept rpath cpath wpath shared_buffer proc exec unix fattr thread", nullptr) < 0) {
perror("pledge");
@ -820,3 +824,10 @@ bool make_is_available()
posix_spawn_file_actions_destroy(&action);
return WEXITSTATUS(wstatus) == 0;
}
}
int main(int argc, char** argv)
{
return main_impl(argc, argv);
}