summaryrefslogtreecommitdiff
path: root/components/keyboard_indicators.c
diff options
context:
space:
mode:
Diffstat (limited to 'components/keyboard_indicators.c')
-rw-r--r--components/keyboard_indicators.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/components/keyboard_indicators.c b/components/keyboard_indicators.c
index 4a81539..5f62bb7 100644
--- a/components/keyboard_indicators.c
+++ b/components/keyboard_indicators.c
@@ -33,17 +33,18 @@ keyboard_indicators(const char *fmt)
fmtlen = strnlen(fmt, 4);
for (i = n = 0; i < fmtlen; i++) {
key = tolower(fmt[i]);
- if (key != 'c' && key != 'n') {
+ if (key != 'c' && key != 'n')
continue;
- }
+
togglecase = (i + 1 >= fmtlen || fmt[i + 1] != '?');
isset = (state.led_mask & (1 << (key == 'n')));
- if (togglecase) {
+
+ if (togglecase)
buf[n++] = isset ? toupper(key) : key;
- } else if (isset) {
+ else if (isset)
buf[n++] = fmt[i];
- }
}
+
buf[n] = 0;
return buf;
}