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 | 02f786920bc437b4192fdea36d525a33e5821eae (patch) | |
tree | 81081ee91c788ba7a4b898eb5b143d3d703a73dd /linenoise | |
parent | c958dacad2dfbf2008ae1de8a98f0155126e53af (diff) | |
download | txr-02f786920bc437b4192fdea36d525a33e5821eae.tar.gz txr-02f786920bc437b4192fdea36d525a33e5821eae.tar.bz2 txr-02f786920bc437b4192fdea36d525a33e5821eae.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.
Diffstat (limited to 'linenoise')
-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 *); |