1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

HackStudio: Use CodeDocument instead of TextDocument

This commit adds a new GUI widget type, called CodeDocument, which
is a TextDocument that can additionaly store data related to the
debugger.

This fixes various bugs and crashes that occured when we switched
between files in debug mode, because we previously held stale breakpoint
data for the previous file in the Editor object.
We now keep this data at the "document" level rather than the Editor
level, which fixes things.
This commit is contained in:
Itamar 2020-08-15 10:58:31 +03:00 committed by Andreas Kling
parent e793cc3d13
commit 627f258c97
9 changed files with 137 additions and 22 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include "CodeDocument.h"
#include "Debugger/BreakpointCallback.h"
#include <AK/Optional.h>
#include <LibGUI/TextEditor.h>
@ -44,12 +45,19 @@ public:
EditorWrapper& wrapper();
const EditorWrapper& wrapper() const;
const Vector<size_t>& breakpoint_lines() const { return m_breakpoint_lines; }
const Vector<size_t>& breakpoint_lines() const { return code_document().breakpoint_lines(); }
Vector<size_t>& breakpoint_lines() { return code_document().breakpoint_lines(); }
Optional<size_t> execution_position() const { return code_document().execution_position(); }
void set_execution_position(size_t line_number);
void clear_execution_position();
BreakpointChangeCallback on_breakpoint_change;
const CodeDocument& code_document() const;
CodeDocument& code_document();
virtual void set_document(GUI::TextDocument&) override;
private:
virtual void focusin_event(GUI::FocusEvent&) override;
virtual void focusout_event(GUI::FocusEvent&) override;
@ -77,7 +85,4 @@ private:
bool m_hovering_editor { false };
bool m_hovering_link { false };
bool m_holding_ctrl { false };
Vector<size_t> m_breakpoint_lines;
Optional<size_t> m_execution_position;
};