patch-src_screen_init_c 683 B

123456789101112131415161718192021222324252627
  1. $OpenBSD: patch-src_screen_init_c,v 1.1 2017/03/27 17:26:10 dcoppa Exp $
  2. --- src/screen_init.c.orig Mon Mar 20 21:59:49 2017
  3. +++ src/screen_init.c Mon Mar 27 18:44:28 2017
  4. @@ -26,7 +26,9 @@
  5. #include "options.h"
  6. #include "colors.h"
  7. +#include <sys/ioctl.h>
  8. #include <stdlib.h>
  9. +#include <termios.h>
  10. #ifndef NCMPC_MINI
  11. /** welcome message time [s] */
  12. @@ -63,6 +65,12 @@ screen_exit(void)
  13. void
  14. screen_resize(struct mpdclient *c)
  15. {
  16. + struct winsize ws;
  17. + if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) == 0) {
  18. + LINES = ws.ws_row;
  19. + COLS = ws.ws_col;
  20. + }
  21. +
  22. const unsigned cols = COLS, rows = LINES;
  23. if (cols < SCREEN_MIN_COLS || rows < SCREEN_MIN_ROWS) {
  24. screen_exit();