NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
resize.c
Go to the documentation of this file.
1
24
30
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
56
static
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
76
void
mutt_resize_screen
(
void
)
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);
99
window_notify_all
(NULL);
100
}
lib.h
Convenience wrapper for the library headers.
mutt_str_getenv
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition
string.c:732
mutt_curses.h
Define wrapper functions around Curses.
window_notify_all
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition
mutt_window.c:147
mutt_window.h
Window management.
mutt_resize_screen
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition
resize.c:76
mutt_get_winsize
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition
resize.c:56
rootwin_set_size
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition
rootwin.c:273
rootwin.h
Root Window.