diff options
author | okan | 2012-10-23 15:32:38 +0000 |
---|---|---|
committer | okan | 2012-10-23 15:32:38 +0000 |
commit | af4604f740e5a494de8226697fbe0e942a1fbe45 (patch) | |
tree | d563cbadb14317a18d209c7db227fd35024e1b93 | |
parent | 0e921af581eb2c54d6c706a9730bac1114304d0b (diff) | |
download | cwm-af4604f740e5a494de8226697fbe0e942a1fbe45.tar.gz |
Stop drawing when menu doesn't fit inside the screen; picked from a
larger diff from Alexander Polakov.
-rw-r--r-- | menu.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: menu.c,v 1.36 2012/08/07 14:05:49 okan Exp $ + * $OpenBSD: menu.c,v 1.37 2012/10/23 15:32:38 okan Exp $ */ #include <sys/param.h> @@ -387,9 +387,14 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, TAILQ_FOREACH(mi, resultq, resultentry) { char *text = mi->print[0] != '\0' ? mi->print : mi->text; + int y = n * font_height(sc) + font_ascent(sc) + 1; + + /* Stop drawing when menu doesn't fit inside the screen. */ + if (mc->y + y > ymax) + break; font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY), - sc->menuwin, 0, n * font_height(sc) + font_ascent(sc) + 1); + sc->menuwin, 0, y); n++; } |