commit 6cc75f8c9e2b41f27c12302b396546c528fe6440
parent 2073929621ed25546dd60cf4249adb04505ba6d5
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 6 Feb 2022 11:10:59 +0100
add compile-time option to improve output on dumb non-UTF8 terminals
This makes atleast feeds with simple ASCII work.
Diffstat:
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git 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
diff --git a/util.c b/util.c
@@ -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;
}
diff --git a/util.h b/util.h
@@ -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 */