From 7d181af50f8839ea748982fd42da52f77af97b58 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 13 May 2014 18:14:31 +1000 Subject: Purkle gets an append command, and use it from extantz to show llSay() and friends. --- src/extantz/extantz.c | 32 ++++++++++++++------------------ src/purkle/purkle.c | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index a6ffad7..7fce3a3 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -21,8 +21,8 @@ static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev) static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev) { -// globals *ourGlobals = data; -// char buf[PATH_MAX]; + globals *ourGlobals = data; + char buf[PATH_MAX]; char SID[PATH_MAX]; const char *command; char *ext; @@ -39,23 +39,19 @@ static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev) ext = index(SID, '.'); if (ext) { - ext[0] = '\0'; - command = ext + 1; - if (0 == strncmp(command, "llOwnerSay(", 11)) - { - PI("Saying to owner from %s - %s", SID, command); - } - else if (0 == strncmp(command, "llWhisper(", 10)) - { - PI("Whispering from %s - %s", SID, command); - } - else if (0 == strncmp(command, "llSay(", 6)) - { - PI("Saying from %s - %s", SID, command); - } - else if (0 == strncmp(command, "llShout(", 8)) + ext[0] = '\0'; + command = ext + 1; + if ((0 == strncmp(command, "llOwnerSay(", 11)) + || (0 == strncmp(command, "llWhisper(", 10)) + || (0 == strncmp(command, "llSay(", 6)) + || (0 == strncmp(command, "llShout(", 8))) { - PI("Shouting from %s - %s", SID, command); + int _M; + + sprintf(buf, "%s: %s", SID, command); + lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name); + _M = lua_gettop(ourGlobals->purkle->L); + push_lua(ourGlobals->purkle->L, "@ ( $ )", _M, "append", buf, 0); } else if (0 == strncmp(command, "llDialog(", 9)) { diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index 2ee4964..f86f3f3 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c @@ -4,21 +4,24 @@ #include "winFang.h" +static const char *ourName = "purkle"; +static int skang, _M; +static Widget *entry, *history; + static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) { winFang *me; - Widget *wid; me = winFangAdd(parent, 30, 590, w, h, "chatter box", "purkle", world); - wid = widgetAdd(me, WT_TEXTBOX, "History is shown here", -1, -1, -1, -1); - eo_do(wid->obj, + history = widgetAdd(me, WT_TEXTBOX, "History is shown here", -1, -1, -1, -1); + eo_do(history->obj, elm_obj_entry_scrollable_set(EINA_TRUE), elm_obj_entry_editable_set(EINA_FALSE) ); - wid = widgetAdd(me, WT_ENTRY, "", -1, -1, -1, -1); - eo_do(wid->obj, + entry = widgetAdd(me, WT_ENTRY, "", -1, -1, -1, -1); + eo_do(entry->obj, elm_obj_entry_scrollable_set(EINA_TRUE), elm_obj_entry_editable_set(EINA_TRUE) ); @@ -28,8 +31,23 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) return me; } -static const char *ourName = "purkle"; -static int skang, _M; +static int append(lua_State *L) +{ + char *text = NULL; + + pull_lua(L, 1, "$", &text); + if (text) + { + eo_do(history->obj, + elm_obj_entry_entry_append("
"), + // TODO - Add a time stamp, and log to a file. + elm_obj_entry_entry_append(text), + // TODO - really need a "scroll to the bottom" here, this cursor down wont work if lines get wrapped onto multiple lines. + elm_obj_entry_cursor_down() + ); + } + return 0; +} int luaopen_purkle(lua_State *L) { @@ -51,6 +69,8 @@ int luaopen_purkle(lua_State *L) lua_getfield(L, LUA_REGISTRYINDEX, ourName); _M = lua_gettop(L); + push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, _M, "append", "Append text to the history box.", append, "string", 0); + lua_getfield(L, LUA_REGISTRYINDEX, glName); gl = lua_touserdata(L, -1); lua_pop(L, 1); @@ -60,8 +80,7 @@ int luaopen_purkle(lua_State *L) world = gl->world; } - purkleAdd(parent, 200, 400, world); - + purkleAdd(parent, 500, 420, world); push_lua(L, "@ ( = )", skang, MODULEEND, _M, 0); // Return _M, the table itself, not the index. -- cgit v1.1