NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
module.c
Go to the documentation of this file.
1
22
28
29
#include "config.h"
30
#include <lua.h>
31
#include <stdbool.h>
32
#include <stddef.h>
33
#include "
mutt/lib.h
"
34
#include "
core/lib.h
"
35
#include "
module_data.h
"
36
37
extern
const
struct
Command
LuaCommands
[];
38
42
static
bool
lua_init
(
struct
NeoMutt
*n)
43
{
44
struct
LuaModuleData
*mod_data =
MUTT_MEM_CALLOC
(1,
struct
LuaModuleData
);
45
neomutt_set_module_data
(n,
MODULE_ID_LUA
, mod_data);
46
47
mod_data->
notify
=
notify_new
();
48
notify_set_parent
(mod_data->
notify
, n->
notify
);
49
50
return
true
;
51
}
52
56
static
bool
lua_commands_register
(
struct
NeoMutt
*n,
struct
CommandArray *ca)
57
{
58
return
commands_register
(ca,
LuaCommands
);
59
}
60
64
static
bool
lua_cleanup
(
struct
NeoMutt
*n,
void
*data)
65
{
66
struct
LuaModuleData
*mod_data = data;
67
68
notify_free
(&mod_data->
notify
);
69
70
lua_State *
lua_state
= mod_data->
lua_state
;
71
if
(
lua_state
)
72
{
73
lua_close(
lua_state
);
74
mod_data->
lua_state
= NULL;
75
}
76
77
FREE
(&mod_data);
78
return
true
;
79
}
80
84
const
struct
Module
ModuleLua
= {
85
MODULE_ID_LUA
,
86
"lua"
,
87
lua_init
,
88
NULL,
// config_define_types
89
NULL,
// config_define_variables
90
lua_commands_register
,
91
NULL,
// gui_init
92
NULL,
// gui_cleanup
93
lua_cleanup
,
94
};
commands_register
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition
command.c:51
lib.h
Convenience wrapper for the core headers.
ModuleLua
const struct Module ModuleLua
Module for the Lua library.
Definition
module.c:84
LuaCommands
const struct Command LuaCommands[]
List of NeoMutt commands to register.
Definition
commands.c:151
lua_cleanup
static bool lua_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup().
Definition
module.c:64
lua_init
static bool lua_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init().
Definition
module.c:42
lua_commands_register
static bool lua_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register().
Definition
module.c:56
module_data.h
Lua private Module data.
FREE
#define FREE(x)
Free memory and set the pointer to NULL.
Definition
memory.h:68
MUTT_MEM_CALLOC
#define MUTT_MEM_CALLOC(n, type)
Definition
memory.h:52
MODULE_ID_LUA
@ MODULE_ID_LUA
ModuleLua, Integrated Lua scripting
Definition
module_api.h:75
lib.h
Convenience wrapper for the library headers.
notify_new
struct Notify * notify_new(void)
Create a new notifications handler.
Definition
notify.c:62
notify_set_parent
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition
notify.c:95
notify_free
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition
notify.c:75
neomutt_set_module_data
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition
neomutt.c:680
Command
Definition
command.h:161
LuaModuleData
Lua private Module data.
Definition
module_data.h:35
LuaModuleData::lua_state
lua_State * lua_state
Lua State.
Definition
module_data.h:37
LuaModuleData::notify
struct Notify * notify
Notifications.
Definition
module_data.h:36
Module
Definition
module_api.h:104
NeoMutt
Container for Accounts, Notifications.
Definition
neomutt.h:41
NeoMutt::notify
struct Notify * notify
Notifications handler.
Definition
neomutt.h:45