1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 21:05:06 +00:00
serenity/DevTools/HackStudio/TextDocument.h
Andreas Kling e2d7f585da HackStudio: Support opening the same file in both editors
Hey, it actually works! You can now edit the same file in both editors
and even the C++ highlighting updates correctly in both of them. :^)
2019-10-27 19:39:15 +01:00

33 lines
736 B
C++

#pragma once
#include <AK/ByteBuffer.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/String.h>
#include <LibGUI/GTextDocument.h>
class TextDocument : public RefCounted<TextDocument> {
public:
static NonnullRefPtr<TextDocument> construct_with_name(const String& name)
{
return adopt(*new TextDocument(name));
}
const String& name() const { return m_name; }
const ByteBuffer& contents() const;
Vector<int> find(const StringView&) const;
const GTextDocument& document() const;
private:
explicit TextDocument(const String& name)
: m_name(name)
{
}
String m_name;
mutable ByteBuffer m_contents;
mutable RefPtr<GTextDocument> m_document;
};