NeoMutt  2023-05-17-33-gce4425
Teaching an old dog new tricks
DOXYGEN
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 "gui/lib.h"
35#ifdef HAVE_TERMIOS_H
36#include <termios.h>
37#endif
38#ifndef HAVE_TCGETWINSIZE
39#ifdef HAVE_SYS_IOCTL_H
40#include <sys/ioctl.h>
41#else
42#ifdef HAVE_IOCTL_H
43#include <ioctl.h>
44#endif
45#endif
46#endif /* HAVE_TCGETWINSIZE */
47
52static struct winsize mutt_get_winsize(void)
53{
54 struct winsize w = { 0 };
55
56 int fd = open("/dev/tty", O_RDONLY);
57 if (fd != -1)
58 {
59#ifdef HAVE_TCGETWINSIZE
60 tcgetwinsize(fd, &w);
61#else
62 ioctl(fd, TIOCGWINSZ, &w);
63#endif
64 close(fd);
65 }
66 return w;
67}
68
73{
74 struct winsize w = mutt_get_winsize();
75
76 int screenrows = w.ws_row;
77 int screencols = w.ws_col;
78
79 if (screenrows <= 0)
80 {
81 const char *cp = mutt_str_getenv("LINES");
82 if (cp && !mutt_str_atoi_full(cp, &screenrows))
83 screenrows = 24;
84 }
85
86 if (screencols <= 0)
87 {
88 const char *cp = mutt_str_getenv("COLUMNS");
89 if (cp && !mutt_str_atoi_full(cp, &screencols))
90 screencols = 80;
91 }
92
93 resizeterm(screenrows, screencols);
94 rootwin_set_size(screencols, screenrows);
96}
Convenience wrapper for the gui headers.
Convenience wrapper for the library headers.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:918
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:143
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size (CURSES)
Definition: resize.c:72
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:52
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:226