diff options
author | David Walter Seikel | 2014-05-13 18:14:31 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-13 18:14:31 +1000 |
commit | 7d181af50f8839ea748982fd42da52f77af97b58 (patch) | |
tree | ffbd41b916f3f2fb1b0efa3cc0b8595918fb6142 /src/purkle | |
parent | GuiLuaLoad() now returns the GuiLua it loaded, and adds the name. Use that f... (diff) | |
download | SledjHamr-7d181af50f8839ea748982fd42da52f77af97b58.zip SledjHamr-7d181af50f8839ea748982fd42da52f77af97b58.tar.gz SledjHamr-7d181af50f8839ea748982fd42da52f77af97b58.tar.bz2 SledjHamr-7d181af50f8839ea748982fd42da52f77af97b58.tar.xz |
Purkle gets an append command, and use it from extantz to show llSay() and friends.
Diffstat (limited to 'src/purkle')
-rw-r--r-- | src/purkle/purkle.c | 37 |
1 files changed, 28 insertions, 9 deletions
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 @@ | |||
4 | #include "winFang.h" | 4 | #include "winFang.h" |
5 | 5 | ||
6 | 6 | ||
7 | static const char *ourName = "purkle"; | ||
8 | static int skang, _M; | ||
9 | static Widget *entry, *history; | ||
10 | |||
7 | static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) | 11 | static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) |
8 | { | 12 | { |
9 | winFang *me; | 13 | winFang *me; |
10 | Widget *wid; | ||
11 | 14 | ||
12 | me = winFangAdd(parent, 30, 590, w, h, "chatter box", "purkle", world); | 15 | me = winFangAdd(parent, 30, 590, w, h, "chatter box", "purkle", world); |
13 | 16 | ||
14 | wid = widgetAdd(me, WT_TEXTBOX, "History is shown here", -1, -1, -1, -1); | 17 | history = widgetAdd(me, WT_TEXTBOX, "History is shown here", -1, -1, -1, -1); |
15 | eo_do(wid->obj, | 18 | eo_do(history->obj, |
16 | elm_obj_entry_scrollable_set(EINA_TRUE), | 19 | elm_obj_entry_scrollable_set(EINA_TRUE), |
17 | elm_obj_entry_editable_set(EINA_FALSE) | 20 | elm_obj_entry_editable_set(EINA_FALSE) |
18 | ); | 21 | ); |
19 | 22 | ||
20 | wid = widgetAdd(me, WT_ENTRY, "", -1, -1, -1, -1); | 23 | entry = widgetAdd(me, WT_ENTRY, "", -1, -1, -1, -1); |
21 | eo_do(wid->obj, | 24 | eo_do(entry->obj, |
22 | elm_obj_entry_scrollable_set(EINA_TRUE), | 25 | elm_obj_entry_scrollable_set(EINA_TRUE), |
23 | elm_obj_entry_editable_set(EINA_TRUE) | 26 | elm_obj_entry_editable_set(EINA_TRUE) |
24 | ); | 27 | ); |
@@ -28,8 +31,23 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) | |||
28 | return me; | 31 | return me; |
29 | } | 32 | } |
30 | 33 | ||
31 | static const char *ourName = "purkle"; | 34 | static int append(lua_State *L) |
32 | static int skang, _M; | 35 | { |
36 | char *text = NULL; | ||
37 | |||
38 | pull_lua(L, 1, "$", &text); | ||
39 | if (text) | ||
40 | { | ||
41 | eo_do(history->obj, | ||
42 | elm_obj_entry_entry_append("<br/>"), | ||
43 | // TODO - Add a time stamp, and log to a file. | ||
44 | elm_obj_entry_entry_append(text), | ||
45 | // TODO - really need a "scroll to the bottom" here, this cursor down wont work if lines get wrapped onto multiple lines. | ||
46 | elm_obj_entry_cursor_down() | ||
47 | ); | ||
48 | } | ||
49 | return 0; | ||
50 | } | ||
33 | 51 | ||
34 | int luaopen_purkle(lua_State *L) | 52 | int luaopen_purkle(lua_State *L) |
35 | { | 53 | { |
@@ -51,6 +69,8 @@ int luaopen_purkle(lua_State *L) | |||
51 | lua_getfield(L, LUA_REGISTRYINDEX, ourName); | 69 | lua_getfield(L, LUA_REGISTRYINDEX, ourName); |
52 | _M = lua_gettop(L); | 70 | _M = lua_gettop(L); |
53 | 71 | ||
72 | push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, _M, "append", "Append text to the history box.", append, "string", 0); | ||
73 | |||
54 | lua_getfield(L, LUA_REGISTRYINDEX, glName); | 74 | lua_getfield(L, LUA_REGISTRYINDEX, glName); |
55 | gl = lua_touserdata(L, -1); | 75 | gl = lua_touserdata(L, -1); |
56 | lua_pop(L, 1); | 76 | lua_pop(L, 1); |
@@ -60,8 +80,7 @@ int luaopen_purkle(lua_State *L) | |||
60 | world = gl->world; | 80 | world = gl->world; |
61 | } | 81 | } |
62 | 82 | ||
63 | purkleAdd(parent, 200, 400, world); | 83 | purkleAdd(parent, 500, 420, world); |
64 | |||
65 | push_lua(L, "@ ( = )", skang, MODULEEND, _M, 0); | 84 | push_lua(L, "@ ( = )", skang, MODULEEND, _M, 0); |
66 | 85 | ||
67 | // Return _M, the table itself, not the index. | 86 | // Return _M, the table itself, not the index. |