Skip to content

Commit

Permalink
vis-lua: expose mode constants to lua
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Feb 18, 2016
1 parent 505fc2a commit 5d9cf02
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 30 additions & 0 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,36 @@ static int vis_index(lua_State *L) {
obj_ref_new(L, vis->windows, "vis.window");
return 1;
}

if (strcmp(key, "MODE_NORMAL") == 0) {
lua_pushunsigned(L, VIS_MODE_NORMAL);
return 1;
}

if (strcmp(key, "MODE_OPERATOR_PENDING") == 0) {
lua_pushunsigned(L, VIS_MODE_OPERATOR_PENDING);
return 1;
}

if (strcmp(key, "MODE_VISUAL") == 0) {
lua_pushunsigned(L, VIS_MODE_VISUAL);
return 1;
}

if (strcmp(key, "MODE_VISUAL_LINE") == 0) {
lua_pushunsigned(L, VIS_MODE_VISUAL_LINE);
return 1;
}

if (strcmp(key, "MODE_INSERT") == 0) {
lua_pushunsigned(L, VIS_MODE_INSERT);
return 1;
}

if (strcmp(key, "MODE_REPLACE") == 0) {
lua_pushunsigned(L, VIS_MODE_REPLACE);
return 1;
}
}

return index_common(L);
Expand Down
2 changes: 0 additions & 2 deletions vis.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ void vis_exit(Vis*, int status);
/* emergency exit, print given message, perform minimal ui cleanup and exit process */
void vis_die(Vis*, const char *msg, ...) __attribute__((noreturn));

/* user facing modes are: NORMAL, VISUAL, VISUAL_LINE, INSERT, REPLACE.
* the others should be considered as implementation details (TODO: do not expose them?) */
enum VisMode {
VIS_MODE_NORMAL,
VIS_MODE_OPERATOR_PENDING,
Expand Down

0 comments on commit 5d9cf02

Please sign in to comment.