NeoMutt
2025-12-11-1009-ga75d9e
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
state.c
Go to the documentation of this file.
1
22
28
29
#include "config.h"
30
#include <wchar.h>
31
#include "
mutt/lib.h
"
32
#include "
state.h
"
33
38
void
enter_state_free
(
struct
EnterState
**ptr)
39
{
40
if
(!ptr || !*ptr)
41
return
;
42
43
struct
EnterState
*es = *ptr;
44
45
FREE
(&es->
wbuf
);
46
FREE
(ptr);
47
}
48
54
void
enter_state_resize
(
struct
EnterState
*es,
size_t
num)
55
{
56
if
(!es)
57
return
;
58
59
if
(num <= es->
wbuflen
)
60
return
;
61
62
num =
ROUND_UP
(num + 4, 128);
63
MUTT_MEM_REALLOC
(&es->
wbuf
, num,
wchar_t
);
64
65
wmemset(es->
wbuf
+ es->
wbuflen
, 0, num - es->
wbuflen
);
66
67
es->
wbuflen
= num;
68
}
69
74
struct
EnterState
*
enter_state_new
(
void
)
75
{
76
struct
EnterState
*es =
MUTT_MEM_CALLOC
(1,
struct
EnterState
);
77
78
enter_state_resize
(es, 1);
79
80
return
es;
81
}
enter_state_new
struct EnterState * enter_state_new(void)
Create a new EnterState.
Definition
state.c:74
enter_state_free
void enter_state_free(struct EnterState **ptr)
Free an EnterState.
Definition
state.c:38
enter_state_resize
void enter_state_resize(struct EnterState *es, size_t num)
Make the buffer bigger.
Definition
state.c:54
state.h
Struct to store the cursor position when entering text.
FREE
#define FREE(x)
Free memory and set the pointer to NULL.
Definition
memory.h:68
ROUND_UP
#define ROUND_UP(NUM, STEP)
Round up NUM to the nearest multiple of STEP.
Definition
memory.h:46
MUTT_MEM_CALLOC
#define MUTT_MEM_CALLOC(n, type)
Definition
memory.h:52
MUTT_MEM_REALLOC
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition
memory.h:55
lib.h
Convenience wrapper for the library headers.
EnterState
Keep our place when entering a string.
Definition
state.h:32
EnterState::wbuflen
size_t wbuflen
Length of buffer.
Definition
state.h:34
EnterState::wbuf
wchar_t * wbuf
Buffer for the string being entered.
Definition
state.h:33