diff options
author | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-03-21 14:52:17 +0200 |
---|---|---|
committer | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-03-21 14:52:17 +0200 |
commit | fb790a955be29184a376a5d579ad9378718c280f (patch) | |
tree | 3c6a82886395c3106dcb8c79246e79e449705f52 | |
parent | 06ef6842e8ff6b7a754c54f4af39775bc842612b (diff) | |
download | profani-tty-fb790a955be29184a376a5d579ad9378718c280f.tar.gz |
Use funcs available in all glib versions to replace \n in quotes
-rw-r--r-- | src/ui/window.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 516e2209..7952497c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -2033,12 +2033,17 @@ win_quote_autocomplete(ProfWin* window, const char* const input, gboolean previo return NULL; } + gchar **parts = g_strsplit(result, "\n", -1); + gchar *quoted_result = g_strjoinv("\n> ", parts); + GString* replace_with = g_string_new("> "); - g_string_append(replace_with, result); - g_string_replace(replace_with, "\n", "\n> ", 0); + g_string_append(replace_with, quoted_result); g_string_append(replace_with, "\n"); g_free(result); + g_free(quoted_result); + g_strfreev(parts); + result = replace_with->str; g_string_free(replace_with, FALSE); return result; |