NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
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
37extern const struct Command LuaCommands[];
38
42static bool lua_init(struct NeoMutt *n)
43{
44 struct LuaModuleData *mod_data = MUTT_MEM_CALLOC(1, struct LuaModuleData);
46
47 mod_data->notify = notify_new();
48 notify_set_parent(mod_data->notify, n->notify);
49
50 return true;
51}
52
56static bool lua_commands_register(struct NeoMutt *n, struct CommandArray *ca)
57{
59}
60
64static 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
84const struct Module ModuleLua = {
86 "lua",
88 NULL, // config_define_types
89 NULL, // config_define_variables
91 NULL, // gui_init
92 NULL, // gui_cleanup
94};
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
Convenience wrapper for the core headers.
const struct Module ModuleLua
Module for the Lua library.
Definition module.c:84
const struct Command LuaCommands[]
List of NeoMutt commands to register.
Definition commands.c:151
static bool lua_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:64
static bool lua_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:42
static bool lua_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:56
Lua private Module data.
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_LUA
ModuleLua, Integrated Lua scripting
Definition module_api.h:74
Convenience wrapper for the library headers.
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 notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
Lua private Module data.
Definition module_data.h:35
lua_State * lua_state
Lua State.
Definition module_data.h:37
struct Notify * notify
Notifications.
Definition module_data.h:36
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify
Notifications handler.
Definition neomutt.h:45