NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
resize.c
Go to the documentation of this file.
1
30#include "config.h"
31#include <fcntl.h>
32#include <unistd.h>
33#include "mutt/lib.h"
34#include "mutt_curses.h"
35#include "mutt_window.h"
36#include "rootwin.h"
37#ifdef HAVE_TERMIOS_H
38#include <termios.h> // IWYU pragma: keep
39#endif
40#ifndef HAVE_TCGETWINSIZE
41#ifdef HAVE_SYS_IOCTL_H
42#include <sys/ioctl.h>
43#else
44#ifdef HAVE_IOCTL_H
45#include <ioctl.h>
46#endif
47#endif
48#endif /* HAVE_TCGETWINSIZE */
49
54static struct winsize mutt_get_winsize(void)
55{
56 struct winsize w = { 0 };
57
58 int fd = open("/dev/tty", O_RDONLY);
59 if (fd != -1)
60 {
61#ifdef HAVE_TCGETWINSIZE
62 tcgetwinsize(fd, &w);
63#else
64 ioctl(fd, TIOCGWINSZ, &w);
65#endif
66 close(fd);
67 }
68 return w;
69}
70
75{
76 struct winsize w = mutt_get_winsize();
77
78 int screenrows = w.ws_row;
79 int screencols = w.ws_col;
80
81 if (screenrows <= 0)
82 {
83 const char *cp = mutt_str_getenv("LINES");
84 if (cp && !mutt_str_atoi_full(cp, &screenrows))
85 screenrows = 24;
86 }
87
88 if (screencols <= 0)
89 {
90 const char *cp = mutt_str_getenv("COLUMNS");
91 if (cp && !mutt_str_atoi_full(cp, &screencols))
92 screencols = 80;
93 }
94
95 resizeterm(screenrows, screencols);
96 rootwin_set_size(screencols, screenrows);
98}
Convenience wrapper for the library headers.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:918
Define wrapper functions around Curses.
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:145
Window management.
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition: resize.c:74
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:54
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:251
Root Window.