]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/child.c
Merge branch 'next'
[i3/i3] / i3bar / src / child.c
index 9a89d3c63eb608bf977138c04ecef25813d5b58d..e5f4ea213cd10a5f16d9a2eb0a21343f45fdae63 100644 (file)
@@ -98,6 +98,10 @@ static int stdin_start_array(void *context) {
 static int stdin_start_map(void *context) {
     parser_ctx *ctx = context;
     memset(&(ctx->block), '\0', sizeof(struct status_block));
+
+    /* Default width of the separator block. */
+    ctx->block.sep_block_width = 9;
+
     return 1;
 }
 
@@ -117,6 +121,9 @@ static int stdin_boolean(void *context, int val) {
     if (strcasecmp(ctx->last_map_key, "urgent") == 0) {
         ctx->block.urgent = val;
     }
+    if (strcasecmp(ctx->last_map_key, "separator") == 0) {
+        ctx->block.no_separator = !val;
+    }
     return 1;
 }
 
@@ -132,6 +139,34 @@ static int stdin_string(void *context, const unsigned char *val, unsigned int le
     if (strcasecmp(ctx->last_map_key, "color") == 0) {
         sasprintf(&(ctx->block.color), "%.*s", len, val);
     }
+    if (strcasecmp(ctx->last_map_key, "align") == 0) {
+        if (len == strlen("left") && !strncmp((const char*)val, "left", strlen("left"))) {
+            ctx->block.align = ALIGN_LEFT;
+        } else if (len == strlen("right") && !strncmp((const char*)val, "right", strlen("right"))) {
+            ctx->block.align = ALIGN_RIGHT;
+        } else {
+            ctx->block.align = ALIGN_CENTER;
+        }
+    } else if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
+        i3String *text = i3string_from_utf8_with_length((const char *)val, len);
+        ctx->block.min_width = (uint32_t)predict_text_width(text);
+        i3string_free(text);
+    }
+    return 1;
+}
+
+#if YAJL_MAJOR >= 2
+static int stdin_integer(void *context, long long val) {
+#else
+static int stdin_integer(void *context, long val) {
+#endif
+    parser_ctx *ctx = context;
+    if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
+        ctx->block.min_width = (uint32_t)val;
+    }
+    if (strcasecmp(ctx->last_map_key, "separator_block_width") == 0) {
+        ctx->block.sep_block_width = (uint32_t)val;
+    }
     return 1;
 }
 
@@ -313,6 +348,7 @@ void start_child(char *command) {
     callbacks.yajl_map_key = stdin_map_key;
     callbacks.yajl_boolean = stdin_boolean;
     callbacks.yajl_string = stdin_string;
+    callbacks.yajl_integer = stdin_integer;
     callbacks.yajl_start_array = stdin_start_array;
     callbacks.yajl_end_array = stdin_end_array;
     callbacks.yajl_start_map = stdin_start_map;