From 8ab150a867ff9ab87d2efdf5cfce919614f2ddbb Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 6 Sep 2015 23:44:23 +0200 Subject: Use a helper function for redraw hook and call from recursiveedit too --- Src/Zle/zle_main.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index e06be664d..516baeb44 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1025,6 +1025,31 @@ getrestchar(int inchar, char *outstr, int *outcount) /**/ #endif +static void redrawhook() +{ + Thingy initthingy; + if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) { + int lastcmd_prev = lastcmd; + int old_incompfunc = incompfunc; + char *args[2]; + Thingy lbindk_save = lbindk, bindk_save = bindk; + refthingy(lbindk_save); + refthingy(bindk_save); + args[0] = initthingy->nam; + args[1] = NULL; + incompfunc = 0; + execzlefunc(initthingy, args, 0); + incompfunc = old_incompfunc; + unrefthingy(initthingy); + unrefthingy(lbindk); + unrefthingy(bindk); + lbindk = lbindk_save; + bindk = bindk_save; + /* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so + * restore lastcmd manually so that we don't mess up the global state */ + lastcmd = lastcmd_prev; + } +} /**/ void @@ -1085,28 +1110,7 @@ zlecore(void) break; } - Thingy initthingy; - if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) { - int lastcmd_prev = lastcmd; - int old_incompfunc = incompfunc; - char *args[2]; - Thingy lbindk_save = lbindk, bindk_save = bindk; - refthingy(lbindk_save); - refthingy(bindk_save); - args[0] = initthingy->nam; - args[1] = NULL; - incompfunc = 0; - execzlefunc(initthingy, args, 0); - incompfunc = old_incompfunc; - unrefthingy(initthingy); - unrefthingy(lbindk); - unrefthingy(bindk); - lbindk = lbindk_save; - bindk = bindk_save; - /* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so - * restore lastcmd manually so that we don't mess up the global state */ - lastcmd = lastcmd_prev; - } + redrawhook(); #ifdef HAVE_POLL if (baud && !(lastcmd & ZLE_MENUCMP)) { struct pollfd pfd; @@ -1818,6 +1822,7 @@ recursiveedit(UNUSED(char **args)) { int locerror; + redrawhook(); zrefresh(); zlecore(); -- cgit 1.4.1