summaryrefslogtreecommitdiff
path: root/src/output.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2015-03-16 10:00:32 +0100
committerMichael Stapelberg <michael@stapelberg.de>2015-03-16 10:01:07 +0100
commitd74e904bf4bdd7f1d767a8db09987b90de809579 (patch)
tree07ab4f610c2f222a662daf417f1356154806c29e /src/output.c
parent6996f0a4a34e0744f09dbce39a2164c6fcee875e (diff)
clang-format-3.5 -i **/*.[ch], update modeline
From here on, we’ll use clang-format to automatically format the source. This has worked well in i3, so we are introducing it for i3status.
Diffstat (limited to 'src/output.c')
-rw-r--r--src/output.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/src/output.c b/src/output.c
index 3a43d58..b2fb1dd 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,4 +1,4 @@
-// vim:ts=8:expandtab
+// vim:ts=4:sw=4:expandtab
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
@@ -15,29 +15,29 @@
*
*/
char *color(const char *colorstr) {
- static char colorbuf[32];
- if (!cfg_getbool(cfg_general, "colors")) {
- colorbuf[0] = '\0';
- return colorbuf;
- }
- if (output_format == O_DZEN2)
- (void)snprintf(colorbuf, sizeof(colorbuf), "^fg(%s)", cfg_getstr(cfg_general, colorstr));
- else if (output_format == O_XMOBAR)
- (void)snprintf(colorbuf, sizeof(colorbuf), "<fc=%s>", cfg_getstr(cfg_general, colorstr));
- else if (output_format == O_TERM) {
- /* The escape-sequence for color is <CSI><col>;1m (bright/bold
- * output), where col is a 3-bit rgb-value with b in the
- * least-significant bit. We round the given color to the
- * nearist 3-bit-depth color and output the escape-sequence */
- char *str = cfg_getstr(cfg_general, colorstr);
- int col = strtol(str + 1, NULL, 16);
- int r = (col & (0xFF << 0)) / 0x80;
- int g = (col & (0xFF << 8)) / 0x8000;
- int b = (col & (0xFF << 16)) / 0x800000;
- col = (r << 2) | (g << 1) | b;
- (void)snprintf(colorbuf, sizeof(colorbuf), "\033[3%d;1m", col);
- }
+ static char colorbuf[32];
+ if (!cfg_getbool(cfg_general, "colors")) {
+ colorbuf[0] = '\0';
return colorbuf;
+ }
+ if (output_format == O_DZEN2)
+ (void)snprintf(colorbuf, sizeof(colorbuf), "^fg(%s)", cfg_getstr(cfg_general, colorstr));
+ else if (output_format == O_XMOBAR)
+ (void)snprintf(colorbuf, sizeof(colorbuf), "<fc=%s>", cfg_getstr(cfg_general, colorstr));
+ else if (output_format == O_TERM) {
+ /* The escape-sequence for color is <CSI><col>;1m (bright/bold
+ * output), where col is a 3-bit rgb-value with b in the
+ * least-significant bit. We round the given color to the
+ * nearist 3-bit-depth color and output the escape-sequence */
+ char *str = cfg_getstr(cfg_general, colorstr);
+ int col = strtol(str + 1, NULL, 16);
+ int r = (col & (0xFF << 0)) / 0x80;
+ int g = (col & (0xFF << 8)) / 0x8000;
+ int b = (col & (0xFF << 16)) / 0x800000;
+ col = (r << 2) | (g << 1) | b;
+ (void)snprintf(colorbuf, sizeof(colorbuf), "\033[3%d;1m", col);
+ }
+ return colorbuf;
}
/*
@@ -45,30 +45,31 @@ char *color(const char *colorstr) {
*
*/
char *endcolor(void) {
- if (output_format == O_XMOBAR)
- return "</fc>";
- else if (output_format == O_TERM)
- return "\033[0m";
- else return "";
+ if (output_format == O_XMOBAR)
+ return "</fc>";
+ else if (output_format == O_TERM)
+ return "\033[0m";
+ else
+ return "";
}
void print_separator(const char *separator) {
- if (output_format == O_I3BAR || strlen(separator) == 0)
- return;
+ if (output_format == O_I3BAR || strlen(separator) == 0)
+ return;
- if (output_format == O_DZEN2)
- printf("^fg(%s)%s^fg()", cfg_getstr(cfg_general, "color_separator"), separator);
- else if (output_format == O_XMOBAR)
- printf("<fc=%s>%s</fc>", cfg_getstr(cfg_general, "color_separator"), separator);
- else if (output_format == O_TERM)
- printf("%s%s%s", color("color_separator"), separator, endcolor());
- else if (output_format == O_NONE)
- printf("%s", separator);
+ if (output_format == O_DZEN2)
+ printf("^fg(%s)%s^fg()", cfg_getstr(cfg_general, "color_separator"), separator);
+ else if (output_format == O_XMOBAR)
+ printf("<fc=%s>%s</fc>", cfg_getstr(cfg_general, "color_separator"), separator);
+ else if (output_format == O_TERM)
+ printf("%s%s%s", color("color_separator"), separator, endcolor());
+ else if (output_format == O_NONE)
+ printf("%s", separator);
}
/*
* The term-output hides the cursor. We call this on exit to reset that.
*/
void reset_cursor(void) {
- printf("\033[?25h");
+ printf("\033[?25h");
}