summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-08-12 20:19:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-08-12 20:19:56 -0700
commitb3afc5dc912589b6eee2da2a7c86c4826fdd221f (patch)
tree2b05c2dd51419b560658272d8e1623afae7bfe61 /parser.c
parent8814829f386cb8b4fd89b969f0188d26bb61440d (diff)
downloadtxr-b3afc5dc912589b6eee2da2a7c86c4826fdd221f.tar.gz
txr-b3afc5dc912589b6eee2da2a7c86c4826fdd221f.tar.bz2
txr-b3afc5dc912589b6eee2da2a7c86c4826fdd221f.zip
listener: don't flush lines when writing files.
* linenoise/linenoise.h (struct lino_os): New virtual operation, puts_file_fn: like puts_fn, but not display-oriented: doesn't check for and ignore padding characters, and doesn't flush after each line. (lino_os_init): Initializer macro updated. * linenoise/linenoise.c (edit_it_editor): Use puts_file_fn to write to temporary file. (lino_hist_save): Likewise, when writing out history. * parser.c (lino_puts_file): New static function. (linenoise_txr_binding): Add lino_puts_file to initializer to wire in the operation.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/parser.c b/parser.c
index 88b9b6c2..59ec46c7 100644
--- a/parser.c
+++ b/parser.c
@@ -1478,6 +1478,16 @@ static int lino_puts(mem_t *stream_in, const wchar_t *str_in)
return 1;
}
+static int lino_puts_file(mem_t *stream_in, const wchar_t *str_in)
+{
+ val stream = coerce(val, stream_in);
+ wchar_t ch;
+ while ((ch = *str_in++))
+ if (put_char(chr(ch), stream) != t)
+ return 0;
+ return 1;
+}
+
static wint_t lino_getch(mem_t *stream_in)
{
wint_t ret = WEOF;
@@ -1593,7 +1603,7 @@ static void lino_close(mem_t *stream)
static_def(lino_os_t linenoise_txr_binding =
lino_os_init(chk_malloc, chk_realloc, chk_wmalloc,
chk_wrealloc, chk_strdup, free,
- lino_fileno, lino_puts, lino_getch,
+ lino_fileno, lino_puts, lino_puts_file, lino_getch,
lino_getl, lino_gets, lino_feof,
lino_open, lino_open8, lino_fdopen, lino_close,
wide_display_char_p));