diff options
author | C. McEnroe | 2020-10-09 18:45:52 -0400 |
---|---|---|
committer | C. McEnroe | 2020-10-09 18:45:52 -0400 |
commit | c48672313b910cade2ec5050ded95713a3a2b5b9 (patch) | |
tree | 430aa29c55dd301db40e65dad32766a685073a74 /chat.h | |
parent | f7f5acbbe2a848d2c827aed0fe8410e48300c1e9 (diff) |
Factor out styleStrip
Diffstat (limited to 'chat.h')
-rw-r--r-- | chat.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chat.h b/chat.h index cd8798c..89d5797 100644 --- a/chat.h +++ b/chat.h @@ -105,6 +105,15 @@ static inline size_t styleParse(struct Style *style, const char **str) { return strcspn(*str, (const char[]) { B, C, O, R, I, U, '\0' }); } +static inline void styleStrip(struct Cat *cat, const char *str) { + struct Style style = StyleDefault; + while (*str) { + size_t len = styleParse(&style, &str); + catf(cat, "%.*s", (int)len, str); + str += len; + } +} + enum { None, Debug, Network, IDCap = 256 }; extern char *idNames[IDCap]; extern enum Color idColors[IDCap]; |