diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-26 19:33:35 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-26 19:33:35 -0800 |
commit | a0171352a11dc250d62f86872d8574b0a36ec888 (patch) | |
tree | e202a9f1c01b84e263d6a6a0f29a702c5590c96a | |
parent | 576ab1df8d309ed4f1779b7988f32c9c8920b31a (diff) | |
download | teliva-a0171352a11dc250d62f86872d8574b0a36ec888.tar.gz |
start processing undo events
-rw-r--r-- | src/lua.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lua.c b/src/lua.c index 313ec45..2fcf7e3 100644 --- a/src/lua.c +++ b/src/lua.c @@ -323,6 +323,13 @@ static const char *look_up_definition (lua_State *L, const char *name) { /* really we expect only one */ for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { const char* key = lua_tostring(L, -2); + if (strcmp(key, "__teliva_undo") == 0) { + int next_i = lua_tointeger(L, -1); + assert(next_i < i); + i = next_i + 1; /* account for decrement */ + lua_pop(L, 1); + break; + } if (is_special_history_key(key)) continue; if (strcmp(key, name) == 0) return lua_tostring(L, -1); @@ -346,6 +353,13 @@ int load_definitions(lua_State *L) { /* really we expect only one */ for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { const char* key = lua_tostring(L, -2); + if (strcmp(key, "__teliva_undo") == 0) { + int next_i = lua_tointeger(L, -1); + assert(next_i < i); + i = next_i + 1; /* account for decrement */ + lua_pop(L, 1); + break; + } if (is_special_history_key(key)) continue; if (binding_exists(L, key)) continue; // most recent binding trumps older ones |