NeoMutt  2022-04-29-145-g9b6a0e
Teaching an old dog new tricks
DOXYGEN
msgwin.c File Reference

Message Window. More...

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

Go to the source code of this file.

Data Structures

struct  MsgWinPrivateData
 Private data for the Message Window. More...
 

Functions

static int msgwin_recalc (struct MuttWindow *win)
 Recalculate the display of the Message Window - Implements MuttWindow::recalc() -. More...
 
static int msgwin_repaint (struct MuttWindow *win)
 Redraw the Message Window - Implements MuttWindow::repaint() -. More...
 
static int msgwin_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -. More...
 
static void msgwin_wdata_free (struct MuttWindow *win, void **ptr)
 Free the private data attached to the Message Window - Implements MuttWindow::wdata_free() -. More...
 
static struct MsgWinPrivateDatamsgwin_wdata_new (void)
 Create new private data for the Message Window. More...
 
struct MuttWindowmsgwin_new (void)
 Create the Message Window. More...
 
const char * msgwin_get_text (void)
 Get the text from the Message Window. More...
 
void msgwin_set_text (enum ColorId cid, const char *text)
 Set the text for the Message Window. More...
 
void msgwin_clear_text (void)
 Clear the text in the Message Window. More...
 
struct MuttWindowmsgwin_get_window (void)
 Get the Message Window pointer. More...
 
size_t msgwin_get_width (void)
 Get the width of the Message Window. More...
 
void msgwin_set_height (short height)
 Resize the Message Window. More...
 

Variables

static struct MuttWindowMessageWindow = NULL
 Message Window for messages, warnings, errors etc. More...
 

Detailed Description

Message 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 msgwin.c.

Function Documentation

◆ msgwin_wdata_new()

static struct MsgWinPrivateData* msgwin_wdata_new ( void  )
static

Create new private data for the Message Window.

Return values
ptrNew private data

Definition at line 182 of file msgwin.c.

183 {
184  struct MsgWinPrivateData *msgwin_data = mutt_mem_calloc(1, sizeof(struct MsgWinPrivateData));
185 
186  msgwin_data->cid = MT_COLOR_NORMAL;
187 
188  return msgwin_data;
189 }
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:53
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
Private data for the Message Window.
Definition: msgwin.c:94
enum ColorId cid
Colour for the text, e.g. MT_COLOR_MESSAGE.
Definition: msgwin.c:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgwin_new()

struct MuttWindow* msgwin_new ( void  )

Create the Message Window.

Return values
ptrNew Window

Definition at line 195 of file msgwin.c.

196 {
203 
205 
206  return MessageWindow;
207 }
static int msgwin_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: msgwin.c:142
static int msgwin_recalc(struct MuttWindow *win)
Recalculate the display of the Message Window - Implements MuttWindow::recalc() -.
Definition: msgwin.c:102
static int msgwin_repaint(struct MuttWindow *win)
Redraw the Message Window - Implements MuttWindow::repaint() -.
Definition: msgwin.c:115
static void msgwin_wdata_free(struct MuttWindow *win, void **ptr)
Free the private data attached to the Message Window - Implements MuttWindow::wdata_free() -.
Definition: msgwin.c:169
static struct MsgWinPrivateData * msgwin_wdata_new(void)
Create new private data for the Message Window.
Definition: msgwin.c:182
static struct MuttWindow * MessageWindow
Message Window for messages, warnings, errors etc.
Definition: msgwin.c:88
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:189
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:181
@ WT_MESSAGE
Window for messages/errors and command entry.
Definition: mutt_window.h:99
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:38
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:47
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:182
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:171
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgwin_get_text()

const char* msgwin_get_text ( void  )

Get the text from the Message Window.

Note
Do not free the returned string

Definition at line 214 of file msgwin.c.

215 {
216  if (!MessageWindow)
217  return NULL;
218 
219  struct MsgWinPrivateData *priv = MessageWindow->wdata;
220 
221  return priv->text;
222 }
char * text
Cached display string.
Definition: msgwin.c:96
+ Here is the caller graph for this function:

◆ msgwin_set_text()

void msgwin_set_text ( enum ColorId  cid,
const char *  text 
)

Set the text for the Message Window.

Parameters
cidColour Id, e.g. MT_COLOR_MESSAGE
textText to set
Note
The text string will be copied

Definition at line 231 of file msgwin.c.

232 {
233  if (!MessageWindow)
234  return;
235 
236  struct MsgWinPrivateData *priv = MessageWindow->wdata;
237 
238  priv->cid = cid;
239  mutt_str_replace(&priv->text, text);
240 
242 }
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:326
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgwin_clear_text()

void msgwin_clear_text ( void  )

Clear the text in the Message Window.

Definition at line 247 of file msgwin.c.

248 {
250 }
void msgwin_set_text(enum ColorId cid, const char *text)
Set the text for the Message Window.
Definition: msgwin.c:231
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgwin_get_window()

struct MuttWindow* msgwin_get_window ( void  )

Get the Message Window pointer.

Return values
ptrMessage Window

Allow some users direct access to the Message Window.

Definition at line 258 of file msgwin.c.

259 {
260  return MessageWindow;
261 }
+ Here is the caller graph for this function:

◆ msgwin_get_width()

size_t msgwin_get_width ( void  )

Get the width of the Message Window.

Return values
numWidth of Message Window

Definition at line 267 of file msgwin.c.

268 {
269  if (!MessageWindow)
270  return 0;
271 
272  return MessageWindow->state.cols;
273 }
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
+ Here is the caller graph for this function:

◆ msgwin_set_height()

void msgwin_set_height ( short  height)

Resize the Message Window.

Parameters
heightNumber of rows required

Resize the other Windows to allow a multi-line message to be displayed.

Definition at line 281 of file msgwin.c.

282 {
283  if (!MessageWindow)
284  return;
285 
286  if (height < 1)
287  height = 1;
288  else if (height > 3)
289  height = 3;
290 
291  struct MuttWindow *win_cont = MessageWindow->parent;
292 
293  win_cont->req_rows = height;
294  mutt_window_reflow(win_cont->parent);
295 }
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:340
short req_rows
Number of rows required.
Definition: mutt_window.h:125
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
+ Here is the caller graph for this function:

Variable Documentation

◆ MessageWindow

struct MuttWindow* MessageWindow = NULL
static

Message Window for messages, warnings, errors etc.

Definition at line 88 of file msgwin.c.