NeoMutt  2020-03-20-65-g141838
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)
 Use an ioctl to 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

Use an ioctl to get the window size.

Return values
objWindow size

Definition at line 51 of file resize.c.

52 {
53  struct winsize w = { 0 };
54  int fd = open("/dev/tty", O_RDONLY);
55  if (fd != -1)
56  {
57  ioctl(fd, TIOCGWINSZ, &w);
58  close(fd);
59  }
60  return w;
61 }
+ Here is the call graph for this function:
+ 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 101 of file resize.c.

102 {
103  struct winsize w = mutt_get_winsize();
104 
105  int screenrows = w.ws_row;
106  int screencols = w.ws_col;
107 
108  if (screenrows <= 0)
109  {
110  const char *cp = mutt_str_getenv("LINES");
111  if (cp && (mutt_str_atoi(cp, &screenrows) < 0))
112  screenrows = 24;
113  }
114 
115  if (screencols <= 0)
116  {
117  const char *cp = mutt_str_getenv("COLUMNS");
118  if (cp && (mutt_str_atoi(cp, &screencols) < 0))
119  screencols = 80;
120  }
121 
122  resizeterm(screenrows, screencols);
123  mutt_window_set_root(screenrows, screencols);
124  mutt_window_reflow(NULL);
125 }
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:262
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition: string.c:1071
void mutt_window_set_root(int rows, int cols)
Set the dimensions of the Root Window.
Definition: mutt_window.c:506
static struct winsize mutt_get_winsize(void)
Use an ioctl to get the window size.
Definition: resize.c:51
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:345
+ Here is the call graph for this function:
+ Here is the caller graph for this function: