NeoMutt  2021-10-22-8-g9cb437
Teaching an old dog new tricks
DOXYGEN
resize.c File Reference

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

#include "config.h"
#include <stddef.h>
#include <fcntl.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "gui/lib.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. More...
 
void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size (CURSES) More...
 

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

54 {
55  struct winsize w = { 0 };
56 
57  int fd = open("/dev/tty", O_RDONLY);
58  if (fd != -1)
59  {
60 #ifdef HAVE_TCGETWINSIZE
61  tcgetwinsize(fd, &w);
62 #else
63  ioctl(fd, TIOCGWINSZ, &w);
64 #endif
65  close(fd);
66  }
67  return w;
68 }
+ Here is the caller graph for this function:

◆ mutt_resize_screen()

void mutt_resize_screen ( void  )

Update NeoMutt's opinion about the window size (CURSES)

Definition at line 73 of file resize.c.

74 {
75  struct winsize w = mutt_get_winsize();
76 
77  int screenrows = w.ws_row;
78  int screencols = w.ws_col;
79 
80  if (screenrows <= 0)
81  {
82  const char *cp = mutt_str_getenv("LINES");
83  if (cp && (mutt_str_atoi(cp, &screenrows) < 0))
84  screenrows = 24;
85  }
86 
87  if (screencols <= 0)
88  {
89  const char *cp = mutt_str_getenv("COLUMNS");
90  if (cp && (mutt_str_atoi(cp, &screencols) < 0))
91  screencols = 80;
92  }
93 
94  resizeterm(screenrows, screencols);
95  rootwin_set_size(screencols, screenrows);
96  window_notify_all(NULL);
97 }
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:252
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1024
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:143
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition: resize.c:53
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:220
+ Here is the call graph for this function:
+ Here is the caller graph for this function: