=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/popup.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/tmux/popup.c 2020/03/24 08:09:44 1.1 +++ src/usr.bin/tmux/popup.c 2020/03/28 09:39:44 1.2 @@ -1,4 +1,4 @@ -/* $OpenBSD: popup.c,v 1.1 2020/03/24 08:09:44 nicm Exp $ */ +/* $OpenBSD: popup.c,v 1.2 2020/03/28 09:39:44 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott @@ -350,6 +350,22 @@ } u_int +popup_height(u_int nlines, const char **lines) +{ + char *copy, *next, *loop; + u_int i, height = 0; + + for (i = 0; i < nlines; i++) { + copy = next = xstrdup(lines[i]); + while ((loop = strsep(&next, "\n")) != NULL) + height++; + free(copy); + } + + return (height); +} + +u_int popup_width(struct cmdq_item *item, u_int nlines, const char **lines, struct client *c, struct cmd_find_state *fs) { @@ -372,8 +388,8 @@ width = tmpwidth; free(tmp); } + free(copy); } - free(copy); format_free(ft); return (width); @@ -394,8 +410,6 @@ return (-1); if (c->tty.sx < sx || c->tty.sy < sy) return (-1); - if (nlines > sy - 2) - nlines = sy - 2; pd = xcalloc(1, sizeof *pd); pd->item = item;