NeoMutt  2024-04-25-76-g20fe7b
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
state.c File Reference

State of text entry. More...

#include "config.h"
#include <string.h>
#include <wchar.h>
#include "mutt/lib.h"
#include "state.h"
+ Include dependency graph for state.c:

Go to the source code of this file.

Functions

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

Detailed Description

State of text entry.

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

Function Documentation

◆ enter_state_free()

void enter_state_free ( struct EnterState **  ptr)

Free an EnterState.

Parameters
[out]ptrEnterState to free

Definition at line 39 of file state.c.

40{
41 if (!ptr || !*ptr)
42 return;
43
44 struct EnterState *es = *ptr;
45
46 FREE(&es->wbuf);
47 FREE(ptr);
48}
#define FREE(x)
Definition: memory.h:45
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_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 55 of file state.c.

56{
57 if (!es)
58 return;
59
60 if (num <= es->wbuflen)
61 return;
62
63 num = ROUND_UP(num + 4, 128);
64 mutt_mem_realloc(&es->wbuf, num * sizeof(wchar_t));
65
66 wmemset(es->wbuf + es->wbuflen, 0, num - es->wbuflen);
67
68 es->wbuflen = num;
69}
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:115
#define ROUND_UP(NUM, STEP)
Definition: memory.h:36
size_t wbuflen
Length of buffer.
Definition: state.h:34
+ Here is the call graph for this function:
+ 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 75 of file state.c.

76{
77 struct EnterState *es = mutt_mem_calloc(1, sizeof(struct EnterState));
78
79 enter_state_resize(es, 1);
80
81 return es;
82}
void enter_state_resize(struct EnterState *es, size_t num)
Make the buffer bigger.
Definition: state.c:55
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function: