NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
reflow.c File Reference

Window reflowing. More...

#include "config.h"
#include <stddef.h>
#include "mutt/lib.h"
#include "reflow.h"
#include "mutt_window.h"
+ Include dependency graph for reflow.c:

Go to the source code of this file.

Functions

static void window_reflow_horiz (struct MuttWindow *win)
 Reflow Windows using all the available horizontal space.
 
static void window_reflow_vert (struct MuttWindow *win)
 Reflow Windows using all the available vertical space.
 
void window_reflow (struct MuttWindow *win)
 Reflow Windows.
 

Detailed Description

Window reflowing.

Authors
  • Richard Russon

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 reflow.c.

Function Documentation

◆ window_reflow_horiz()

static void window_reflow_horiz ( struct MuttWindow * win)
static

Reflow Windows using all the available horizontal space.

Parameters
winWindow

Definition at line 39 of file reflow.c.

40{
41 if (!win)
42 return;
43
44 int max_count = 0;
45 int space = win->state.cols;
46
47 // Pass one - minimal allocation
48 struct MuttWindow **wp = NULL;
49 ARRAY_FOREACH(wp, &win->children)
50 {
51 if (!(*wp)->state.visible)
52 continue;
53
54 switch ((*wp)->size)
55 {
57 {
58 const int avail = MIN(space, (*wp)->req_cols);
59 (*wp)->state.cols = avail;
60 (*wp)->state.rows = win->state.rows;
61 space -= avail;
62 break;
63 }
65 {
66 (*wp)->state.cols = 1;
67 (*wp)->state.rows = win->state.rows;
68 max_count++;
69 space -= 1;
70 break;
71 }
73 {
74 (*wp)->state.rows = win->state.rows;
75 (*wp)->state.cols = win->state.cols;
76 (*wp)->state.row_offset = win->state.row_offset;
77 (*wp)->state.col_offset = win->state.col_offset;
78 window_reflow(*wp);
79 space -= (*wp)->state.cols;
80 break;
81 }
82 }
83 }
84
85 // Pass two - sharing
86 if ((max_count > 0) && (space > 0))
87 {
88 int alloc = (space + max_count - 1) / max_count;
89 ARRAY_FOREACH(wp, &win->children)
90 {
91 if (space == 0)
92 break;
93 if (!(*wp)->state.visible)
94 continue;
95 if ((*wp)->size != MUTT_WIN_SIZE_MAXIMISE)
96 continue;
97
98 alloc = MIN(space, alloc);
99 (*wp)->state.cols += alloc;
100 space -= alloc;
101 }
102 }
103
104 // Pass three - position and recursion
105 int col = win->state.col_offset;
106 ARRAY_FOREACH(wp, &win->children)
107 {
108 if (!(*wp)->state.visible)
109 continue;
110
111 (*wp)->state.col_offset = col;
112 (*wp)->state.row_offset = win->state.row_offset;
113 col += (*wp)->state.cols;
114
115 window_reflow(*wp);
116 }
117
118 if ((space > 0) && (win->size == MUTT_WIN_SIZE_MINIMISE))
119 {
120 win->state.cols -= space;
121 }
122}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define MIN(a, b)
Return the minimum of two values.
Definition memory.h:40
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition mutt_window.h:47
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition mutt_window.h:49
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
void window_reflow(struct MuttWindow *win)
Reflow Windows.
Definition reflow.c:220
struct MuttWindowArray children
Children Windows.
struct WindowState state
Current state of the Window.
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:60
short row_offset
Absolute on-screen row.
Definition mutt_window.h:63
short col_offset
Absolute on-screen column.
Definition mutt_window.h:62
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ window_reflow_vert()

static void window_reflow_vert ( struct MuttWindow * win)
static

Reflow Windows using all the available vertical space.

Parameters
winWindow

Definition at line 128 of file reflow.c.

129{
130 if (!win)
131 return;
132
133 int max_count = 0;
134 int space = win->state.rows;
135
136 // Pass one - minimal allocation
137 struct MuttWindow **wp = NULL;
138 ARRAY_FOREACH(wp, &win->children)
139 {
140 if (!(*wp)->state.visible)
141 continue;
142
143 switch ((*wp)->size)
144 {
146 {
147 const int avail = MIN(space, (*wp)->req_rows);
148 (*wp)->state.rows = avail;
149 (*wp)->state.cols = win->state.cols;
150 space -= avail;
151 break;
152 }
154 {
155 (*wp)->state.rows = 1;
156 (*wp)->state.cols = win->state.cols;
157 max_count++;
158 space -= 1;
159 break;
160 }
162 {
163 (*wp)->state.rows = win->state.rows;
164 (*wp)->state.cols = win->state.cols;
165 (*wp)->state.row_offset = win->state.row_offset;
166 (*wp)->state.col_offset = win->state.col_offset;
167 window_reflow(*wp);
168 space -= (*wp)->state.rows;
169 break;
170 }
171 }
172 }
173
174 // Pass two - sharing
175 if ((max_count > 0) && (space > 0))
176 {
177 int alloc = (space + max_count - 1) / max_count;
178 ARRAY_FOREACH(wp, &win->children)
179 {
180 if (space == 0)
181 break;
182 if (!(*wp)->state.visible)
183 continue;
184 if ((*wp)->size != MUTT_WIN_SIZE_MAXIMISE)
185 continue;
186
187 alloc = MIN(space, alloc);
188 (*wp)->state.rows += alloc;
189 space -= alloc;
190 }
191 }
192
193 // Pass three - position and recursion
194 int row = win->state.row_offset;
195 ARRAY_FOREACH(wp, &win->children)
196 {
197 if (!(*wp)->state.visible)
198 continue;
199
200 (*wp)->state.row_offset = row;
201 (*wp)->state.col_offset = win->state.col_offset;
202 row += (*wp)->state.rows;
203
204 window_reflow(*wp);
205 }
206
207 if ((space > 0) && (win->size == MUTT_WIN_SIZE_MINIMISE))
208 {
209 win->state.rows -= space;
210 }
211}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ window_reflow()

void window_reflow ( struct MuttWindow * win)

Reflow Windows.

Parameters
winRoot Window

Using the rules coded into the Windows, such as Fixed or Maximise, allocate space to a set of nested Windows.

Definition at line 220 of file reflow.c.

221{
222 if (!win)
223 return;
226 else
228}
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
static void window_reflow_vert(struct MuttWindow *win)
Reflow Windows using all the available vertical space.
Definition reflow.c:128
static void window_reflow_horiz(struct MuttWindow *win)
Reflow Windows using all the available horizontal space.
Definition reflow.c:39
enum MuttWindowOrientation orient
Which direction the Window will expand.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: