aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-12-31 12:28:55 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-12-31 13:20:12 +0100
commiteb8a8c5fa0657d8a3d404589d6ad1f954acde935 (patch)
tree9ca1a386a9faee8467cc994e4f03ef8452231a39 /text.c
parent809a73a6a50d82da27f2df6fb1906c8a6d09d19d (diff)
downloadvis-eb8a8c5fa0657d8a3d404589d6ad1f954acde935.tar.gz
vis-eb8a8c5fa0657d8a3d404589d6ad1f954acde935.tar.xz
text: introduce text_newline_insert
Diffstat (limited to 'text.c')
-rw-r--r--text.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/text.c b/text.c
index da14209..7f94247 100644
--- a/text.c
+++ b/text.c
@@ -664,6 +664,17 @@ bool text_vprintf(Text *txt, size_t pos, const char *format, va_list ap) {
return ret;
}
+bool text_insert_newline(Text *txt, size_t pos) {
+ switch (text_newline_type(txt)) {
+ case TEXT_NEWLINE_NL:
+ return text_insert(txt, pos, "\n", 1);
+ case TEXT_NEWLINE_CRNL:
+ return text_insert(txt, pos, "\r\n", 2);
+ default:
+ return false;
+ }
+}
+
static size_t action_undo(Text *txt, Action *a) {
size_t pos = EPOS;
for (Change *c = a->change; c; c = c->next) {