From da765ebdaa986918fd048f4ee20e65a9a55e3538 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 5 Jul 2020 13:39:48 -0400 Subject: [PATCH] mojibake: don't stomp right side of boxes --- TERMS.md | 15 +++++++++++++++ src/demo/mojibake.c | 10 +++++----- src/lib/blit.c | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 TERMS.md diff --git a/TERMS.md b/TERMS.md new file mode 100644 index 000000000..093259c91 --- /dev/null +++ b/TERMS.md @@ -0,0 +1,15 @@ +# Terminals and `TERM` + +| Terminal | Recommended `TERM` | Notes | +| -------- | ------ | ----- | +| Linux console | `linux` | 8 (512 glyph fonts) or 16 (256 glyph fonts) colors max. | +| FBterm | | | +| kmscon | | | +| XTerm | | | +| XFCE4 Terminal | | | +| Gnome Terminal | | | +| Konsole | | | +| Alacritty | | | +| Kitty | | | +| GNU Screen | `screen-256colors` | Must be compiled with `--enable-256color`. | +| tmux | | | diff --git a/src/demo/mojibake.c b/src/demo/mojibake.c index ce5c5becb..887d2bf83 100644 --- a/src/demo/mojibake.c +++ b/src/demo/mojibake.c @@ -3458,7 +3458,7 @@ unicode52(struct ncplane* title, int y){ "\xf0\x9f\x85\xbf \xf0\x9f\x85\xbf\ufe0f" "\xf0\x9f\x88\xaf \xf0\x9f\x88\xaf\ufe0f" "\xf0\x9f\x88\x9a \xf0\x9f\x88\x9a\ufe0f" - "\u3299 \u3299\ufe0f \U0001F41D"); + "\u3299 \u3299\ufe0f"); return n; } @@ -3511,10 +3511,10 @@ unicode7emoji2(struct ncplane* title, int y){ struct ncplane* makegroup(struct ncplane* title, int y, const char* emoji, const char* name){ int cols = mbswidth(emoji); - if(cols < 0){ - cols = 1; + if(cols < 0){ // take a wild guess on mbswidth() error. + cols = strlen(emoji) * 3 / 5; // best by test } - struct ncplane* n = mojiplane(title, y, 2 + (cols + (planewidth - 1)) / planewidth, name); + struct ncplane* n = mojiplane(title, y, 2 + (cols + (planewidth - 3)) / (planewidth - 2), name); if(n == NULL){ return NULL; } @@ -3537,7 +3537,7 @@ makegroup(struct ncplane* title, int y, const char* emoji, const char* name){ } emoji += bytes; x += w; - if(x >= planewidth - 1){ + if(x >= planewidth - 2){ ++y; x = 1; } diff --git a/src/lib/blit.c b/src/lib/blit.c index 5dd26d6dc..bc737f792 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1,3 +1,4 @@ +#include #include "internal.h" static const unsigned char zeroes[] = "\x00\x00\x00\x00";