NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
state.h File Reference

Struct to store the cursor position when entering text. More...

#include <stddef.h>
+ Include dependency graph for state.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EnterState
 Keep our place when entering a string. More...
 

Functions

void enter_state_free (struct EnterState **ptr)
 Free an EnterState.
 
struct EnterStateenter_state_new (void)
 Create a new EnterState.
 
void enter_state_resize (struct EnterState *es, size_t num)
 Make the buffer bigger.
 

Detailed Description

Struct to store the cursor position when entering text.

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 state.h.

Function Documentation

◆ enter_state_free()

void enter_state_free ( struct EnterState **  ptr)

Free an EnterState.

Parameters
[out]ptrEnterState to free

Definition at line 38 of file state.c.

39{
40 if (!ptr || !*ptr)
41 return;
42
43 struct EnterState *es = *ptr;
44
45 FREE(&es->wbuf);
46 FREE(ptr);
47}
#define FREE(x)
Definition: memory.h:55
Keep our place when entering a string.
Definition: state.h:32
wchar_t * wbuf
Buffer for the string being entered.
Definition: state.h:33
+ Here is the caller graph for this function:

◆ enter_state_new()

struct EnterState * enter_state_new ( void  )

Create a new EnterState.

Return values
ptrNew EnterState

Definition at line 74 of file state.c.

75{
76 struct EnterState *es = MUTT_MEM_CALLOC(1, struct EnterState);
77
78 enter_state_resize(es, 1);
79
80 return es;
81}
void enter_state_resize(struct EnterState *es, size_t num)
Make the buffer bigger.
Definition: state.c:54
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enter_state_resize()

void enter_state_resize ( struct EnterState es,
size_t  num 
)

Make the buffer bigger.

Parameters
esState of the Enter buffer
numNumber of wide characters

Definition at line 54 of file state.c.

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}
#define ROUND_UP(NUM, STEP)
Definition: memory.h:36
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition: memory.h:43
size_t wbuflen
Length of buffer.
Definition: state.h:34
+ Here is the caller graph for this function: