From bbbf2d4067724ebadcf78e27c7f4849cc9fd514a Mon Sep 17 00:00:00 2001 From: Guo Rui Date: Fri, 3 Jul 2009 23:15:47 +0800 Subject: [PATCH] Move ProcessCaption to current event dispatching system. Compile, but still could not work. Currently the event will be triggered for both caption and hstatus, which does not reflect the name. --- src/lua.c | 26 ++++++-------------------- src/screen.c | 4 +++- src/script.c | 9 ++------- src/script.h | 8 +------- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/lua.c b/src/lua.c index 6155619..9717e0f 100644 --- a/src/lua.c +++ b/src/lua.c @@ -1021,20 +1021,6 @@ int LuaFinit(void) return 0; } -int -LuaProcessCaption(const char *caption, struct win *win, int len) -{ - if (!L) - return 0; - struct fn_def params[] = { - {lua_pushstring, caption}, - {push_window, &win}, - {lua_pushinteger, len}, - {NULL, NULL} - }; - return LuaCallProcess("process_caption", params); -} - static void push_stringarray(lua_State *L, char **args) { @@ -1076,6 +1062,12 @@ LuaPushParams(lua_State *L, const char *params, va_list va) push_window(L, &w); break; } + case 'c': + { + struct canvas *c = va_arg(va, struct canvas *); + push_canvas(L, &c); + break; + } } params++; num++; @@ -1310,11 +1302,6 @@ LuaRegEvent(lua_State *L) /** }}} */ -struct ScriptFuncs LuaFuncs = -{ - LuaProcessCaption -}; - struct binding lua_binding = { "lua", /*name*/ @@ -1326,6 +1313,5 @@ struct binding lua_binding = LuaSource, LuaDispatch, 0, /*b_next*/ - &LuaFuncs }; diff --git a/src/screen.c b/src/screen.c index 7d9b45d..43d6259 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2539,7 +2539,9 @@ int rec; *p = '\0'; #ifdef SCRIPT - if (ScriptProcessCaption(str, win, padlen)) + /* FIXME: Need a way to pass result back. + * Also, should it be specific to caption or to hstatus? */ + if (trigger_sevent(&globalevents.processcaption, display)) return winmsg_buf; #endif if (!display) diff --git a/src/script.c b/src/script.c index a0cd913..b16c6a7 100644 --- a/src/script.c +++ b/src/script.c @@ -180,6 +180,7 @@ struct gevents globalevents; * S: string array (char **) * i: signed int * d: display + * c: canvas */ struct sev_description { @@ -197,6 +198,7 @@ struct sev_description { */ /* fore window changed to window w on display d. */ {"global_forechanged", "dw", offsetof(struct gevents, forechanged)}, + {"global_processcaption", "c", offsetof(struct gevents, processcaption)}, /* Window events */ {"window_can_resize", "", offsetof(struct win, w_sev.canresize)}, @@ -319,10 +321,3 @@ trigger_sevent(struct script_event *ev, VA_DOTS) } \ } while (0) -int ScriptProcessCaption(const char *str, struct win *win, int len) -{ - int ret = 0; - ALL_SCRIPTS(sf_ProcessCaption, (str, win, len), 1); - return ret; -} - diff --git a/src/script.h b/src/script.h index 6f70ce9..6b3ca88 100644 --- a/src/script.h +++ b/src/script.h @@ -22,12 +22,6 @@ #define SCRIPT_H struct win; -/*Obsolete*/ -struct ScriptFuncs -{ - int (*sf_ProcessCaption) __P((const char *, struct win *, int len)); -}; - /***Language binding***/ struct binding { @@ -45,7 +39,6 @@ struct binding int (*bd_dispatch) __P((void *handler, const char *params, va_list va)); struct binding *b_next; - struct ScriptFuncs *fns; }; void LoadBindings(void); @@ -86,6 +79,7 @@ struct gevents { struct script_event cmdexecuted; struct script_event detached; struct script_event forechanged; + struct script_event processcaption; }; extern struct gevents globalevents; #endif -- 2.11.4.GIT