NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
resize.c
Go to the documentation of this file.
1
31#include "config.h"
32#include <fcntl.h>
33#include <stddef.h>
34#include <unistd.h>
35#include "mutt/lib.h"
36#include "mutt_curses.h"
37#include "mutt_window.h"
38#include "rootwin.h"
39#ifdef HAVE_TERMIOS_H
40#include <termios.h>
41#endif
42#ifndef HAVE_TCGETWINSIZE
43#ifdef HAVE_SYS_IOCTL_H
44#include <sys/ioctl.h>
45#else
46#ifdef HAVE_IOCTL_H
47#include <ioctl.h>
48#endif
49#endif
50#endif /* HAVE_TCGETWINSIZE */
51
56static struct winsize mutt_get_winsize(void)
57{
58 struct winsize w = { 0 };
59
60 int fd = open("/dev/tty", O_RDONLY);
61 if (fd != -1)
62 {
63#ifdef HAVE_TCGETWINSIZE
64 tcgetwinsize(fd, &w);
65#else
66 ioctl(fd, TIOCGWINSZ, &w);
67#endif
68 close(fd);
69 }
70 return w;
71}
72
77{
78 struct winsize w = mutt_get_winsize();
79
80 int screenrows = w.ws_row;
81 int screencols = w.ws_col;
82
83 if (screenrows <= 0)
84 {
85 const char *cp = mutt_str_getenv("LINES");
86 if (cp && !mutt_str_atoi_full(cp, &screenrows))
87 screenrows = 24;
88 }
89
90 if (screencols <= 0)
91 {
92 const char *cp = mutt_str_getenv("COLUMNS");
93 if (cp && !mutt_str_atoi_full(cp, &screencols))
94 screencols = 80;
95 }
96
97 resizeterm(screenrows, screencols);
98 rootwin_set_size(screencols, screenrows);
100}
Convenience wrapper for the library headers.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:726
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:76
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:56
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:253
Root Window.