1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12: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 * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "CodeDocument.h" #include "CodeDocument.h"
namespace HackStudio {
NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client) NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
{ {
return adopt(*new CodeDocument(client)); return adopt(*new CodeDocument(client));
} }
CodeDocument::CodeDocument(Client* client) CodeDocument::CodeDocument(Client* client)
: TextDocument(client) : TextDocument(client)
{ {
@ -37,3 +41,5 @@ CodeDocument::CodeDocument(Client* client)
CodeDocument::~CodeDocument() CodeDocument::~CodeDocument()
{ {
} }
}

View file

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

View file

@ -31,6 +31,8 @@
#include <AK/LogStream.h> #include <AK/LogStream.h>
#include <LibGfx/Palette.h> #include <LibGfx/Palette.h>
namespace HackStudio {
void CursorTool::on_mousedown(GUI::MouseEvent& event) void CursorTool::on_mousedown(GUI::MouseEvent& event)
{ {
dbg() << "CursorTool::on_mousedown"; 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.fill_rect(rect, m_editor.palette().rubber_band_fill());
painter.draw_rect(rect, m_editor.palette().rubber_band_border()); painter.draw_rect(rect, m_editor.palette().rubber_band_border());
} }
}

View file

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

View file

@ -27,6 +27,8 @@
#include "BacktraceModel.h" #include "BacktraceModel.h"
#include "Debugger.h" #include "Debugger.h"
namespace HackStudio {
NonnullRefPtr<BacktraceModel> BacktraceModel::create(const DebugSession& debug_session, const PtraceRegisters& regs) NonnullRefPtr<BacktraceModel> BacktraceModel::create(const DebugSession& debug_session, const PtraceRegisters& regs)
{ {
return adopt(*new BacktraceModel(create_backtrace(debug_session, 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); } while (current_ebp && current_instruction);
return frames; return frames;
} }
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -33,6 +33,8 @@
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGfx/Font.h> #include <LibGfx/Font.h>
namespace HackStudio {
EditorWrapper::EditorWrapper(BreakpointChangeCallback breakpoint_change_callback) EditorWrapper::EditorWrapper(BreakpointChangeCallback breakpoint_change_callback)
{ {
set_layout<GUI::VerticalBoxLayout>(); 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()); 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 <LibGUI/Widget.h>
#include <string.h> #include <string.h>
namespace HackStudio {
class Editor; class Editor;
class EditorWrapper : public GUI::Widget { class EditorWrapper : public GUI::Widget {
@ -55,6 +57,8 @@ private:
RefPtr<Editor> m_editor; 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"); } static bool is_type(const Core::Object& object) { return !strcmp(object.class_name(), "EditorWrapper"); }
AK_END_TYPE_TRAITS() AK_END_TYPE_TRAITS()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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