diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-24 21:45:00 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-24 21:45:00 +0200 |
| commit | a338f4fd81a00c14f416f4bfa004583e5ede18c5 (patch) | |
| tree | 4dcd276a4a6ee1c9f36e5264f823a7f8101c46e8 /vis-lua.c | |
| parent | 6c208480102ac6b64f4ca37b4c2550727ac73911 (diff) | |
| download | vis-a338f4fd81a00c14f416f4bfa004583e5ede18c5.tar.gz vis-a338f4fd81a00c14f416f4bfa004583e5ede18c5.tar.xz | |
vis-lua: cleanup Lua status bar display code
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -919,7 +919,16 @@ static int window_style(lua_State *L) { static int window_status(lua_State *L) { Win *win = obj_ref_check(L, 1, "vis.window"); if (win) { - const char *status = luaL_checkstring(L, 2); + char status[1024] = ""; + int width = vis_window_width_get(win); + const char *left = luaL_checkstring(L, 2); + const char *right = luaL_optstring(L, 3, ""); + int left_width = text_string_width(left, strlen(left)); + int right_width = text_string_width(right, strlen(right)); + int spaces = width - left_width - right_width; + if (spaces < 1) + spaces = 1; + snprintf(status, sizeof(status)-1, "%s%*s%s", left, spaces, " ", right); vis_window_status(win, status); } return 0; |
