diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-07-09 08:42:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-07-09 08:42:56 -0700 |
commit | dab353cf2160ac997ca2f7bcdee87ff3d79e3532 (patch) | |
tree | 81081ee91c788ba7a4b898eb5b143d3d703a73dd | |
parent | 6185378f40daf94d8ec1df07e4bcc528cdd97c0d (diff) | |
download | txr-dab353cf2160ac997ca2f7bcdee87ff3d79e3532.tar.gz txr-dab353cf2160ac997ca2f7bcdee87ff3d79e3532.tar.bz2 txr-dab353cf2160ac997ca2f7bcdee87ff3d79e3532.zip |
linenoise: replace linefeeds with CR in previous result.
This fixes the issue that when a multi-line result is pasted
into the edit buffer with Ctrl-X P, the line breaks appear in
it as linefeeds, displayed as ^J. In linenoise, we need line
breaks to be carriage returns.
* linenoise/linenoise.c (lino_set_result): replace newlines
with carriage returns in the given string.
* linenoise/linenoise.h (lino_set_result): Add comment that
function takes ownership of memory assumed to be malloced,
and that it modifies it.
-rw-r--r-- | linenoise/linenoise.c | 2 | ||||
-rw-r--r-- | linenoise/linenoise.h | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 41f9066c..a3c83e66 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -2621,4 +2621,6 @@ void lino_set_result(lino_t *ls, char *res) { free(ls->result); ls->result = res; + while ((res = strchr(res, '\n')) != 0) + *res = '\r'; } diff --git a/linenoise/linenoise.h b/linenoise/linenoise.h index b07b15ea..cf2ddba6 100644 --- a/linenoise/linenoise.h +++ b/linenoise/linenoise.h @@ -69,7 +69,7 @@ int lino_hist_add(lino_t *, const char *line); int lino_hist_set_max_len(lino_t *, int len); int lino_hist_save(lino_t *, const char *filename); int lino_hist_load(lino_t *, const char *filename); -void lino_set_result(lino_t *, char *); +void lino_set_result(lino_t *, char *); /* takes ownership of malloced mem; modifies it */ int lino_clear_screen(lino_t *); void lino_set_multiline(lino_t *, int ml); int lino_get_multiline(lino_t *); |