summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/TextDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibGUI/TextDocument.cpp')
-rw-r--r--Libraries/LibGUI/TextDocument.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Libraries/LibGUI/TextDocument.cpp b/Libraries/LibGUI/TextDocument.cpp
index 10a5ffe497..35abe1e3ac 100644
--- a/Libraries/LibGUI/TextDocument.cpp
+++ b/Libraries/LibGUI/TextDocument.cpp
@@ -282,6 +282,18 @@ void TextDocument::set_all_cursors(const TextPosition& position)
}
}
+String TextDocument::text() const
+{
+ StringBuilder builder;
+ for (size_t i = 0; i < line_count(); ++i) {
+ auto& line = this->line(i);
+ builder.append(line.view());
+ if (i != line_count() - 1)
+ builder.append('\n');
+ }
+ return builder.to_string();
+}
+
String TextDocument::text_in_range(const TextRange& a_range) const
{
auto range = a_range.normalized();