NeoMutt  2025-12-11-800-ga0ee0f
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
utilwin.c File Reference

Utility Window. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "utilwin.h"
#include "color/lib.h"
#include "key/lib.h"
#include "module_data.h"
#include "mutt_curses.h"
#include "mutt_window.h"
+ Include dependency graph for utilwin.c:

Go to the source code of this file.

Data Structures

struct  UtilWinData
 Utility Window private data. More...
 

Macros

#define UTILWIN_COLS   10
 Width of the Utility Window in columns.
 

Functions

static int utilwin_recalc (struct MuttWindow *win)
 Recalculate the Utility Window - Implements MuttWindow::recalc() -.
 
static int utilwin_repaint (struct MuttWindow *win)
 Repaint the Utility Window - Implements MuttWindow::repaint() -.
 
static void utilwin_wdata_free (struct MuttWindow *win, void **ptr)
 Free the private data - Implements MuttWindow::wdata_free() -.
 
static int utilwin_key_observer (struct NotifyCallback *nc)
 Notification that key progress has changed - Implements observer_t -.
 
static int utilwin_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
struct MuttWindowutilwin_new (void)
 Create the Utility Window.
 
const char * utilwin_get_text (struct MuttWindow *win)
 Get the text from the Utility Window.
 
void utilwin_set_text (struct MuttWindow *win, const char *text)
 Set the text for the Utility Window.
 

Detailed Description

Utility Window.

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

Macro Definition Documentation

◆ UTILWIN_COLS

#define UTILWIN_COLS   10

Width of the Utility Window in columns.

Definition at line 71 of file utilwin.c.

Function Documentation

◆ utilwin_new()

struct MuttWindow * utilwin_new ( void )

Create the Utility Window.

Return values
ptrNew Utility Window

The window starts hidden and becomes visible when text is set.

Definition at line 215 of file utilwin.c.

216{
219
220 struct UtilWinData *priv = MUTT_MEM_CALLOC(1, struct UtilWinData);
221
222 win->wdata = priv;
224 win->recalc = utilwin_recalc;
226
227 window_set_visible(win, false);
228
230 if (mod_data)
231 mod_data->utility_window = win;
232
235
236 return win;
237}
static int utilwin_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition utilwin.c:182
static int utilwin_key_observer(struct NotifyCallback *nc)
Notification that key progress has changed - Implements observer_t -.
Definition utilwin.c:142
static int utilwin_recalc(struct MuttWindow *win)
Recalculate the Utility Window - Implements MuttWindow::recalc() -.
Definition utilwin.c:84
static int utilwin_repaint(struct MuttWindow *win)
Repaint the Utility Window - Implements MuttWindow::repaint() -.
Definition utilwin.c:97
static void utilwin_wdata_free(struct MuttWindow *win, void **ptr)
Free the private data - Implements MuttWindow::wdata_free() -.
Definition utilwin.c:125
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
@ WT_CUSTOM
Window with a custom drawing function.
Definition mutt_window.h:94
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition mutt_window.h:47
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:58
@ NT_KEY
Runtime key handling changed, NotifyKey, EventKeyProgress.
Definition notify_type.h:49
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * utility_window
Utility Window.
Definition module_data.h:42
int(* repaint)(struct MuttWindow *win)
void * wdata
Private data.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
int(* recalc)(struct MuttWindow *win)
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
Utility Window private data.
Definition utilwin.c:77
#define UTILWIN_COLS
Width of the Utility Window in columns.
Definition utilwin.c:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ utilwin_get_text()

const char * utilwin_get_text ( struct MuttWindow * win)

Get the text from the Utility Window.

Parameters
winUtility Window
Return values
ptrText string
NULLNo text or invalid window
Note
Do not free the returned string

Definition at line 247 of file utilwin.c.

248{
249 if (!win)
250 {
252 if (mod_data)
253 win = mod_data->utility_window;
254 }
255 if (!win)
256 return NULL;
257
258 struct UtilWinData *priv = win->wdata;
259 return priv->text;
260}
char * text
Cached display string.
Definition utilwin.c:78
+ Here is the call graph for this function:

◆ utilwin_set_text()

void utilwin_set_text ( struct MuttWindow * win,
const char * text )

Set the text for the Utility Window.

Parameters
winUtility Window (may be NULL to use the default)
textText to display (NULL or empty to hide)

Setting text makes the window visible; clearing it hides the window.

Note
The text string will be copied

Definition at line 271 of file utilwin.c.

272{
273 if (!win)
274 {
276 if (mod_data)
277 win = mod_data->utility_window;
278 }
279 if (!win)
280 return;
281
282 struct UtilWinData *priv = win->wdata;
283
284 if (!text || (*text == '\0'))
285 {
286 // Clear the old on-screen contents before hiding the window.
287 // Hidden windows are skipped by repaint, so they can't erase themselves.
289 FREE(&priv->text);
290 window_set_visible(win, false);
291 mutt_window_reflow(NULL);
292 return;
293 }
294
295 mutt_str_replace(&priv->text, text);
296
297 window_set_visible(win, true);
298 win->actions |= WA_RECALC;
299 mutt_window_reflow(NULL);
300}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
#define WA_RECALC
Recalculate the contents of the Window.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: