Skip to content

Commit 8ab150a

Browse files
committed
Use a helper function for redraw hook and call from recursiveedit too
1 parent f04d219 commit 8ab150a

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

Src/Zle/zle_main.c

+27-22
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,31 @@ getrestchar(int inchar, char *outstr, int *outcount)
10251025
/**/
10261026
#endif
10271027

1028+
static void redrawhook()
1029+
{
1030+
Thingy initthingy;
1031+
if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
1032+
int lastcmd_prev = lastcmd;
1033+
int old_incompfunc = incompfunc;
1034+
char *args[2];
1035+
Thingy lbindk_save = lbindk, bindk_save = bindk;
1036+
refthingy(lbindk_save);
1037+
refthingy(bindk_save);
1038+
args[0] = initthingy->nam;
1039+
args[1] = NULL;
1040+
incompfunc = 0;
1041+
execzlefunc(initthingy, args, 0);
1042+
incompfunc = old_incompfunc;
1043+
unrefthingy(initthingy);
1044+
unrefthingy(lbindk);
1045+
unrefthingy(bindk);
1046+
lbindk = lbindk_save;
1047+
bindk = bindk_save;
1048+
/* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so
1049+
* restore lastcmd manually so that we don't mess up the global state */
1050+
lastcmd = lastcmd_prev;
1051+
}
1052+
}
10281053

10291054
/**/
10301055
void
@@ -1085,28 +1110,7 @@ zlecore(void)
10851110
break;
10861111
}
10871112

1088-
Thingy initthingy;
1089-
if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
1090-
int lastcmd_prev = lastcmd;
1091-
int old_incompfunc = incompfunc;
1092-
char *args[2];
1093-
Thingy lbindk_save = lbindk, bindk_save = bindk;
1094-
refthingy(lbindk_save);
1095-
refthingy(bindk_save);
1096-
args[0] = initthingy->nam;
1097-
args[1] = NULL;
1098-
incompfunc = 0;
1099-
execzlefunc(initthingy, args, 0);
1100-
incompfunc = old_incompfunc;
1101-
unrefthingy(initthingy);
1102-
unrefthingy(lbindk);
1103-
unrefthingy(bindk);
1104-
lbindk = lbindk_save;
1105-
bindk = bindk_save;
1106-
/* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so
1107-
* restore lastcmd manually so that we don't mess up the global state */
1108-
lastcmd = lastcmd_prev;
1109-
}
1113+
redrawhook();
11101114
#ifdef HAVE_POLL
11111115
if (baud && !(lastcmd & ZLE_MENUCMP)) {
11121116
struct pollfd pfd;
@@ -1818,6 +1822,7 @@ recursiveedit(UNUSED(char **args))
18181822
{
18191823
int locerror;
18201824

1825+
redrawhook();
18211826
zrefresh();
18221827
zlecore();
18231828

0 commit comments

Comments
 (0)