aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-04-04 12:30:50 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-04-04 12:30:50 +0000
commit5b67e97fc2e97a1aa6c525d90ecbab0ef9700dce (patch)
tree7fc537b6708c507119b58a796cfd0bb0201c3e05
parentosc: 4: handle multiple idx;spec pairs (diff)
osc 104: handle multiple indices the same way we do in OSC 4 - use strtok()
-rw-r--r--osc.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/osc.c b/osc.c
index 2e42dae5..98de86f7 100644
--- a/osc.c
+++ b/osc.c
@@ -559,24 +559,23 @@ osc_dispatch(struct terminal *term)
LOG_DBG("resetting all colors");
for (size_t i = 0; i < 256; i++)
term->colors.table[i] = term->colors.default_table[i];
- } else {
- unsigned idx = 0;
+ }
- for (; *string != '\0'; string++) {
- char c = *string;
- if (c == ';') {
- LOG_DBG("resetting color #%u", idx);
- term->colors.table[idx] = term->colors.default_table[idx];
- idx = 0;
- continue;
+ else {
+ for (const char *s_idx = strtok(string, ";");
+ s_idx != NULL;
+ s_idx = strtok(NULL, ";"))
+ {
+ unsigned idx = 0;
+ for (; *s_idx != '\0'; s_idx++) {
+ char c = *s_idx;
+ idx *= 10;
+ idx += c - '0';
}
- idx *= 10;
- idx += c - '0';
+ LOG_DBG("resetting color #%u", idx);
+ term->colors.table[idx] = term->colors.default_table[idx];
}
-
- LOG_DBG("resetting color #%u", idx);
- term->colors.table[idx] = term->colors.default_table[idx];
}
render_refresh(term);