NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
resize.c File Reference

GUI handle the resizing of the screen. More...

#include "config.h"
#include <fcntl.h>
#include <stddef.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "rootwin.h"
+ Include dependency graph for resize.c:

Go to the source code of this file.

Functions

static struct winsize mutt_get_winsize (void)
 Get the window size.
 
void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size.
 

Detailed Description

GUI handle the resizing of the screen.

Authors
  • Richard Russon
  • Ivan J.
  • Pietro Cerutti

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file resize.c.

Function Documentation

◆ mutt_get_winsize()

static struct winsize mutt_get_winsize ( void  )
static

Get the window size.

Return values
objWindow size

Definition at line 56 of file resize.c.

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}
+ Here is the caller graph for this function:

◆ mutt_resize_screen()

void mutt_resize_screen ( void  )

Update NeoMutt's opinion about the window size.

Definition at line 76 of file resize.c.

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}
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:726
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:144
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function: