From eb8a8c5fa0657d8a3d404589d6ad1f954acde935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 31 Dec 2015 12:28:55 +0100 Subject: text: introduce text_newline_insert --- text.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'text.c') 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) { -- cgit v1.2.3