2019-10-23 20:54:41 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
|
|
|
#include <AK/RefCounted.h>
|
|
|
|
|
#include <AK/String.h>
|
2019-10-27 19:39:15 +01:00
|
|
|
#include <LibGUI/GTextDocument.h>
|
2019-10-23 20:54:41 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2019-10-27 19:39:15 +01:00
|
|
|
const GTextDocument& document() const;
|
|
|
|
|
|
2019-10-23 20:54:41 +02:00
|
|
|
private:
|
|
|
|
|
explicit TextDocument(const String& name)
|
|
|
|
|
: m_name(name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String m_name;
|
|
|
|
|
mutable ByteBuffer m_contents;
|
2019-10-27 19:39:15 +01:00
|
|
|
mutable RefPtr<GTextDocument> m_document;
|
2019-10-23 20:54:41 +02:00
|
|
|
};
|