Keep current setting value on syntax error

This commit is contained in:
baskerville 2012-08-15 23:08:22 +02:00
parent f158b4aecd
commit 49de0d6e94
5 changed files with 18 additions and 9 deletions

View file

@ -54,7 +54,7 @@
## Planned Features
- Directional focus movement.
- Float individual windows (it means there will be a floating layer).
- Float individual windows.
- Resize and move floating windows with the keyboard.
- Resize and move floating windows on a regular magnetic grid (the granularity of the grid might be related to GCD(screen\_width, screen\_height)).
- Double window borders. Rationale: with single borders, it might happen that the color of the window border is too close to the color of the window content to be visible.

View file

@ -14,7 +14,7 @@ void handle_event(xcb_generic_event_t *evt)
PUTS("received a map request\n");
break;
case XCB_UNGRAB_KEY:
PUTS("ungrab key received");
/* PUTS("ungrab key received"); */
break;
case XCB_KEY_PRESS:
PUTS("keypress received");

View file

@ -26,8 +26,10 @@ char *string_expr(lua_State *L, char *expr, char* fallback)
if (eval_expr(L, expr) == 0) {
if (lua_isstring(L, -1))
result = strdup(lua_tostring(L, -1));
else
else if (fallback != NULL)
result = strdup(fallback);
else
result = NULL;
lua_pop(L, 1);
}
return result;

View file

@ -26,6 +26,4 @@ void process_message(char *msg, char *rsp)
}
lua_close(L);
/* strcpy(rsp, "hello\n"); */
}

View file

@ -1,3 +1,5 @@
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -73,7 +75,7 @@ void get_setting(lua_State *L, char* rsp)
void set_setting(lua_State *L)
{
char *name;
char *name, *backup;
if (!has_table(L, "set"))
return;
@ -84,12 +86,19 @@ void set_setting(lua_State *L)
return;
if (strcmp(name, "inner_border_width") == 0) {
inner_border_width = int_expr(L, "set.value", INNER_BORDER_WIDTH);
inner_border_width = int_expr(L, "set.value", inner_border_width);
} else if (strcmp(name, "normal_border_color") == 0) {
backup = strdup(normal_border_color);
free(normal_border_color);
normal_border_color = string_expr(L, "set.value", NORMAL_BORDER_COLOR);
normal_border_color = string_expr(L, "set.value", backup);
} else if (strcmp(name, "inner_border_color") == 0) {
backup = strdup(inner_border_color);
free(inner_border_color);
inner_border_color = string_expr(L, "set.value", INNER_BORDER_COLOR);
inner_border_color = string_expr(L, "set.value", backup);
} else if (strcmp(name, "smart_surroundings") == 0) {
smart_surroundings = bool_expr(L, "set.value", smart_surroundings);
}
if (backup != NULL)
free(backup);
}