From 5da101a52afd8d99f7ede8ef8fbf61afbd52cb02 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 16 Jun 2017 23:14:50 -0700 Subject: linenoise: callback for checking syntax completeness. The idea is that when the user types Enter to submit a line, it can be checked whether it is complete syntax using a callback. If the callback indicates that the syntax is incomplete (there are open expressions, string literals or whatever), then Enter is inserted verbatim. This is active in multi-line mode only. * linenoise.c (struct lino_state): New members, enter_callback and ce_ctx. (lino_set_enter_cb): New function. (edit): If enter is issued, and multi-line mode is in effect, and there is an enter callback, then call it. If the callback returns false, then just insert the character. * linenoise.h (lino_enter_cb_t): New typedef. (lino_set_enter_cb): Declared. --- linenoise/linenoise.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'linenoise/linenoise.h') diff --git a/linenoise/linenoise.h b/linenoise/linenoise.h index 28b304a4..b07b15ea 100644 --- a/linenoise/linenoise.h +++ b/linenoise/linenoise.h @@ -80,3 +80,6 @@ int lino_get_noninteractive(lino_t *); typedef char *lino_atom_cb_t(lino_t *, const char *line, int n, void *ctx); void lino_set_atom_cb(lino_t *, lino_atom_cb_t *, void *ctx); + +typedef int lino_enter_cb_t(const char *line, void *ctx); +void lino_set_enter_cb(lino_t *, lino_enter_cb_t *, void *ctx); -- cgit v1.2.3