NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
module.c File Reference

Definition of the Gui Module. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "color/lib.h"
#include "curs_lib.h"
#include "module_data.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
#include "mutt_window.h"
#include "rootwin.h"
#include "terminal.h"
+ Include dependency graph for module.c:

Go to the source code of this file.

Functions

static void log_gui (void)
 Log info about the GUI.
 
static bool gui_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool gui_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool gui_gui_init (struct NeoMutt *n)
 Initialise the GUI - Implements Module::gui_init()
 
static void gui_gui_cleanup (struct NeoMutt *n)
 Clean up the GUI - Implements Module::gui_cleanup()
 
static bool gui_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef GuiVars []
 Config definitions for the Gui library.
 
const struct Module ModuleGui
 Module for the Gui library.
 

Detailed Description

Definition of the Gui Module.

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

Function Documentation

◆ log_gui()

static void log_gui ( void )
static

Log info about the GUI.

Definition at line 49 of file module.c.

50{
52
53 const char *term = mutt_str_getenv("TERM");
54 const char *color_term = mutt_str_getenv("COLORTERM");
55 bool true_color = false;
56#ifdef NEOMUTT_DIRECT_COLORS
57 true_color = true;
58#endif
59
60 mutt_debug(LL_DEBUG1, "GUI:\n");
61 mutt_debug(LL_DEBUG1, " Curses: %s\n", curses_version());
62 mutt_debug(LL_DEBUG1, " COLORS=%d\n", COLORS);
63 mutt_debug(LL_DEBUG1, " COLOR_PAIRS=%d\n", COLOR_PAIRS);
64 mutt_debug(LL_DEBUG1, " TERM=%s\n", NONULL(term));
65 mutt_debug(LL_DEBUG1, " COLORTERM=%s\n", NONULL(color_term));
66 mutt_debug(LL_DEBUG1, " True color support: %s\n", true_color ? "YES" : "NO");
67 if (mod_data->root_window)
68 {
69 mutt_debug(LL_DEBUG1, " Screen: %dx%d\n", mod_data->root_window->state.cols,
70 mod_data->root_window->state.rows);
71 }
72}
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:731
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
#define NONULL(x)
Definition string2.h:44
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * root_window
Parent of all Windows.
Definition module_data.h:41
struct WindowState state
Current state of the Window.
Container for Accounts, Notifications.
Definition neomutt.h:41
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:60
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:

◆ gui_init()

static bool gui_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 77 of file module.c.

78{
79 struct GuiModuleData *mod_data = MUTT_MEM_CALLOC(1, struct GuiModuleData);
81
82 mod_data->notify = notify_new();
83 notify_set_parent(mod_data->notify, n->notify);
84
85 return true;
86}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
struct Notify * notify
Notifications.
Definition module_data.h:33
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:

◆ gui_config_define_variables()

static bool gui_config_define_variables ( struct NeoMutt * n,
struct ConfigSet * cs )
static

Define the Config Variables - Implements Module::config_define_variables()

Definition at line 91 of file module.c.

92{
94}
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
struct ConfigDef GuiVars[]
Config definitions for the Gui library.
Definition config.c:37
+ Here is the call graph for this function:

◆ gui_gui_init()

static bool gui_gui_init ( struct NeoMutt * n)
static

Initialise the GUI - Implements Module::gui_init()

Definition at line 99 of file module.c.

100{
102
103 /* check whether terminal status is supported (must follow curses init) */
104 mod_data->ts_supported = mutt_ts_capability();
106 log_gui();
107
109 clear();
110
114
115 return true;
116}
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:53
int log_disp_curses(time_t stamp, const char *file, int line, const char *function, enum LogLevel level, const char *format,...)
Display a log line in the message line - Implements log_dispatcher_t -.
static void log_gui(void)
Log info about the GUI.
Definition module.c:49
int log_dispatcher_t MuttLogger
void log_queue_set_max_size(int size)
Set a upper limit for the queue length.
Definition logging.c:319
void log_queue_flush(log_dispatcher_t disp)
Replay the log queue.
Definition logging.c:353
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
Definition mutt_curses.c:79
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
bool ts_supported
Terminal Setting is supported.
Definition module_data.h:43
bool mutt_ts_capability(void)
Check terminal capabilities.
Definition terminal.c:81
+ Here is the call graph for this function:

◆ gui_gui_cleanup()

static void gui_gui_cleanup ( struct NeoMutt * n)
static

Clean up the GUI - Implements Module::gui_cleanup()

Definition at line 121 of file module.c.

122{
124 rootwin_cleanup(mod_data);
125
126 mutt_endwin();
127}
void mutt_endwin(void)
Shutdown curses.
Definition curs_lib.c:153
void rootwin_cleanup(struct GuiModuleData *mod_data)
Free all the default Windows.
Definition rootwin.c:211
+ Here is the call graph for this function:

◆ gui_cleanup()

static bool gui_cleanup ( struct NeoMutt * n,
void * data )
static

Clean up a Module - Implements Module::cleanup()

Definition at line 132 of file module.c.

133{
134 struct GuiModuleData *mod_data = data;
135
136 notify_free(&mod_data->notify);
137
138 FREE(&mod_data);
139 return true;
140}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
+ Here is the call graph for this function:

Variable Documentation

◆ GuiVars

struct ConfigDef GuiVars[]
extern

Config definitions for the Gui library.

Definition at line 37 of file config.c.

37 {
38 // clang-format off
39 { "beep", DT_BOOL, true, 0, NULL,
40 "Make a noise when an error occurs"
41 },
42 { "collapse_flagged", DT_BOOL, true, 0, NULL,
43 "Prevent the collapse of threads with flagged emails"
44 },
45 { "collapse_unread", DT_BOOL, true, 0, NULL,
46 "Prevent the collapse of threads with unread emails"
47 },
48 { "duplicate_threads", DT_BOOL, true, 0, NULL,
49 "Highlight messages with duplicated message IDs"
50 },
51 { "hide_limited", DT_BOOL, false, 0, NULL,
52 "Don't indicate hidden messages, in the thread tree"
53 },
54 { "hide_missing", DT_BOOL, true, 0, NULL,
55 "Don't indicate missing messages, in the thread tree"
56 },
57 { "hide_thread_subject", DT_BOOL, true, 0, NULL,
58 "Hide subjects that are similar to that of the parent message"
59 },
60 { "hide_top_limited", DT_BOOL, false, 0, NULL,
61 "Don't indicate hidden top message, in the thread tree"
62 },
63 { "hide_top_missing", DT_BOOL, true, 0, NULL,
64 "Don't indicate missing top message, in the thread tree"
65 },
66 { "narrow_tree", DT_BOOL, false, 0, NULL,
67 "Draw a narrower thread tree in the index"
68 },
69 { "sort_re", DT_BOOL, true, 0, NULL,
70 "Whether $reply_regex must be matched when not $strict_threads"
71 },
72 { "strict_threads", DT_BOOL, false, 0, NULL,
73 "Thread messages using 'In-Reply-To' and 'References' headers"
74 },
75 { "thread_received", DT_BOOL, false, 0, NULL,
76 "Sort threaded messages by their received date"
77 },
78
79 { NULL },
80 // clang-format on
81};
@ DT_BOOL
boolean option
Definition types.h:32

◆ ModuleGui

const struct Module ModuleGui
Initial value:
= {
"gui",
NULL,
NULL,
}
static bool gui_gui_init(struct NeoMutt *n)
Initialise the GUI - Implements Module::gui_init()
Definition module.c:99
static bool gui_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:132
static bool gui_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:91
static bool gui_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:77
static void gui_gui_cleanup(struct NeoMutt *n)
Clean up the GUI - Implements Module::gui_cleanup()
Definition module.c:121

Module for the Gui library.

Definition at line 145 of file module.c.

145 {
147 "gui",
148 gui_init,
149 NULL, // config_define_types
151 NULL, // commands_register
155};