diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-02-06 11:10:59 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-02-06 11:30:47 +0100 |
commit | 6cc75f8c9e2b41f27c12302b396546c528fe6440 (patch) | |
tree | 7a92242c8d22de7eb4e94d4b8acbf505d497f8ed | |
parent | 2073929621ed25546dd60cf4249adb04505ba6d5 (diff) |
add compile-time option to improve output on dumb non-UTF8 terminals
This makes atleast feeds with simple ASCII work.
-rw-r--r-- | sfeed_curses.c | 9 | ||||
-rw-r--r-- | util.c | 6 | ||||
-rw-r--r-- | util.h | 8 |
3 files changed, 18 insertions, 5 deletions
diff --git a/sfeed_curses.c b/sfeed_curses.c index 2167b7a..734427c 100644 --- a/sfeed_curses.c +++ b/sfeed_curses.c @@ -32,12 +32,17 @@ #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define PAD_TRUNCATE_SYMBOL "\xe2\x80\xa6" /* symbol: "ellipsis" */ +#ifndef SFEED_DUMBTERM #define SCROLLBAR_SYMBOL_BAR "\xe2\x94\x82" /* symbol: "light vertical" */ #define SCROLLBAR_SYMBOL_TICK " " #define LINEBAR_SYMBOL_BAR "\xe2\x94\x80" /* symbol: "light horizontal" */ #define LINEBAR_SYMBOL_RIGHT "\xe2\x94\xa4" /* symbol: "light vertical and left" */ -#define UTF_INVALID_SYMBOL "\xef\xbf\xbd" /* symbol: "replacement" */ +#else +#define SCROLLBAR_SYMBOL_BAR "|" /* symbol: "light vertical" */ +#define SCROLLBAR_SYMBOL_TICK " " +#define LINEBAR_SYMBOL_BAR "-" /* symbol: "light horizontal" */ +#define LINEBAR_SYMBOL_RIGHT "|" /* symbol: "light vertical and left" */ +#endif /* color-theme */ #ifndef SFEED_THEME @@ -354,11 +354,11 @@ printutf8pad(FILE *fp, const char *s, size_t len, int pad) } if (col + w > len || (col + w == len && s[i + inc])) { - fputs("\xe2\x80\xa6", fp); /* ellipsis */ + fputs(PAD_TRUNCATE_SYMBOL, fp); /* ellipsis */ col++; break; } else if (rl < 0) { - fputs("\xef\xbf\xbd", fp); /* replacement */ + fputs(UTF_INVALID_SYMBOL, fp); /* replacement */ col++; continue; } @@ -367,7 +367,7 @@ printutf8pad(FILE *fp, const char *s, size_t len, int pad) } else { /* optimization: simple ASCII character */ if (col + 1 > len || (col + 1 == len && s[i + 1])) { - fputs("\xe2\x80\xa6", fp); /* ellipsis */ + fputs(PAD_TRUNCATE_SYMBOL, fp); /* ellipsis */ col++; break; } @@ -16,6 +16,14 @@ size_t strlcat(char *, const char *, size_t); #undef strlcpy size_t strlcpy(char *, const char *, size_t); +#ifndef SFEED_DUMBTERM +#define PAD_TRUNCATE_SYMBOL "\xe2\x80\xa6" /* symbol: "ellipsis" */ +#define UTF_INVALID_SYMBOL "\xef\xbf\xbd" /* symbol: "replacement" */ +#else +#define PAD_TRUNCATE_SYMBOL "." /* symbol: "ellipsis" */ +#define UTF_INVALID_SYMBOL "?" /* symbol: "replacement" */ +#endif + /* feed info */ struct feed { char *name; /* feed name */ |