commit - 59ae0cdcffd29c8e595590e9b8e61741fbdef970
commit + 6ca7e1b63ef5aef1042589144639a5fa5ee64c1e
blob - 076e5d516eb3a05fe5aaa7e0418cf76b42dd9b1d
blob + ab42fbf08a36fff38c3a2153816035d5458afbf5
--- ui.c
+++ ui.c
static void handle_resize_nodelay(int, short, void*);
static void rearrange_windows(void);
static int wrap_page(struct buffer*, int);
+static void line_prefix_and_text(struct vline *, char *, size_t, const char **, const char **);
static void print_vline(int, int, WINDOW*, struct vline*);
static void redraw_tabline(void);
static void redraw_window(WINDOW*, int, int, int, struct buffer*);
return 1;
}
+
+static void
+line_prefix_and_text(struct vline *vl, char *buf, size_t len,
+ const char **prfx_ret, const char **text_ret)
+{
+ int type, i, cont, width;
+ char *space, *t;
+
+ if ((*text_ret = vl->line) == NULL)
+ *text_ret = "";
+
+ cont = vl->flags & L_CONTINUATION;
+ type = vl->parent->type;
+ if (cont)
+ *prfx_ret = line_prefixes[type].prfx1;
+ else
+ *prfx_ret = line_prefixes[type].prfx2;
+
+ space = vl->parent->data;
+ if (!emojify_link || type != LINE_LINK || space == NULL)
+ return;
+ if (cont) {
+ memset(buf, 0, len);
+ width = utf8_swidth_between(vl->parent->line, space);
+ for (i = 0; i < width + 1; ++i)
+ strlcat(buf, " ", len);
+ } else {
+ strlcpy(buf, *text_ret, len);
+ if ((t = strchr(buf, ' ')) != NULL)
+ *t = '\0';
+ strlcat(buf, " ", len);
+
+ /* skip the emoji */
+ *text_ret += (space - vl->parent->line) + 1;
+ }
+
+ *prfx_ret = buf;
+}
+
/*
* Core part of the rendering. It prints a vline starting from the
* current cursor position. Printing a vline consists of skipping
* That means, to stay large, 4*10 bytes + NUL.
*/
char emojibuf[41] = {0};
- char *space, *t;
const char *text, *prfx;
struct line_face *f;
- int i, left, x, y, emojified, cont;
- long len = sizeof(emojibuf);
+ int i, left, x, y;
f = &line_faces[vl->parent->type];
/* unused, set by getyx */
(void)y;
- cont = vl->flags & L_CONTINUATION;
- if (!cont)
- prfx = line_prefixes[vl->parent->type].prfx1;
- else
- prfx = line_prefixes[vl->parent->type].prfx2;
+ line_prefix_and_text(vl, emojibuf, sizeof(emojibuf), &prfx, &text);
- text = vl->line;
- if (text == NULL)
- text = "";
-
wattr_on(window, body_face.left, NULL);
for (i = 0; i < off; i++)
waddch(window, ' ');
wattr_off(window, body_face.left, NULL);
wattr_on(window, f->prefix, NULL);
- emojified = 0;
- space = vl->parent->data;
- if (vl->parent->type == LINE_LINK && space != NULL) {
- emojified = 1;
- if (cont) {
- len = utf8_swidth_between(vl->parent->line, space) + 1;
- for (i = 0; i < len; ++i)
- wprintw(window, " ");
- } else {
- strlcpy(emojibuf, text, sizeof(emojibuf));
- if ((t = strchr(emojibuf, ' ')) != NULL)
- *t = '\0';
- wprintw(window, "%s ", emojibuf);
- }
- } else {
- wprintw(window, "%s", prfx);
- }
+ wprintw(window, "%s", prfx);
wattr_off(window, f->prefix, NULL);
wattr_on(window, f->text, NULL);
- if (emojified && !cont)
- wprintw(window, "%s", text + (space - vl->parent->line) + 1);
- else
- wprintw(window, "%s", text);
+ wprintw(window, "%s", text);
wattr_off(window, f->text, NULL);
getyx(window, y, x);