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