NeoMutt
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 <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
  • Michael R. Elkins
  • Ivan J.

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 54 of file resize.c.

55{
56 struct winsize w = { 0 };
57
58 int fd = open("/dev/tty", O_RDONLY);
59 if (fd != -1)
60 {
61#ifdef HAVE_TCGETWINSIZE
62 tcgetwinsize(fd, &w);
63#else
64 ioctl(fd, TIOCGWINSZ, &w);
65#endif
66 close(fd);
67 }
68 return w;
69}
+ 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 74 of file resize.c.

75{
76 struct winsize w = mutt_get_winsize();
77
78 int screenrows = w.ws_row;
79 int screencols = w.ws_col;
80
81 if (screenrows <= 0)
82 {
83 const char *cp = mutt_str_getenv("LINES");
84 if (cp && !mutt_str_atoi_full(cp, &screenrows))
85 screenrows = 24;
86 }
87
88 if (screencols <= 0)
89 {
90 const char *cp = mutt_str_getenv("COLUMNS");
91 if (cp && !mutt_str_atoi_full(cp, &screencols))
92 screencols = 80;
93 }
94
95 resizeterm(screenrows, screencols);
96 rootwin_set_size(screencols, screenrows);
98}
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:145
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:54
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:251
+ Here is the call graph for this function:
+ Here is the caller graph for this function: