i3bar: Split flat line logic to read_flat_input
This commit is contained in:
parent
3732cef764
commit
103b1a3f3a
@ -191,6 +191,18 @@ static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void read_flat_input(char *buffer, int length) {
|
||||||
|
struct status_block *first = TAILQ_FIRST(&statusline_head);
|
||||||
|
/* Clear the old buffer if any. */
|
||||||
|
I3STRING_FREE(first->full_text);
|
||||||
|
/* Remove the trailing newline and terminate the string at the same
|
||||||
|
* time. */
|
||||||
|
if (buffer[length-1] == '\n' || buffer[length-1] == '\r')
|
||||||
|
buffer[length-1] = '\0';
|
||||||
|
else buffer[length] = '\0';
|
||||||
|
first->full_text = i3string_from_utf8(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callbalk for stdin. We read a line from stdin and store the result
|
* Callbalk for stdin. We read a line from stdin and store the result
|
||||||
* in statusline
|
* in statusline
|
||||||
@ -231,15 +243,7 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
|
|||||||
status, rec, json_input);
|
status, rec, json_input);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct status_block *first = TAILQ_FIRST(&statusline_head);
|
read_flat_input((char*)buffer, rec);
|
||||||
/* Clear the old buffer if any. */
|
|
||||||
I3STRING_FREE(first->full_text);
|
|
||||||
/* Remove the trailing newline and terminate the string at the same
|
|
||||||
* time. */
|
|
||||||
if (buffer[rec-1] == '\n' || buffer[rec-1] == '\r')
|
|
||||||
buffer[rec-1] = '\0';
|
|
||||||
else buffer[rec] = '\0';
|
|
||||||
first->full_text = i3string_from_utf8((const char *)buffer);
|
|
||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
draw_bars();
|
draw_bars();
|
||||||
|
Loading…
Reference in New Issue
Block a user