38 lines
1.0 KiB
C
38 lines
1.0 KiB
C
#ifndef _LIBINPUT_INPUT_GAPBUFFER_H
|
|
#define _LIBINPUT_INPUT_GAPBUFFER_H
|
|
|
|
#include <stddef.h>
|
|
|
|
struct in_gb {
|
|
char* buffer;
|
|
size_t size;
|
|
size_t gap_start;
|
|
size_t gap_end;
|
|
};
|
|
|
|
typedef void* (*in_gb_malloc_func_t)(void*, size_t);
|
|
|
|
typedef void* (*in_gb_realloc_func_t)(void*, void*, size_t, size_t);
|
|
|
|
typedef void (*in_gb_free_func_t)(void*, void*);
|
|
|
|
void in_gb_init(in_gb_malloc_func_t mallocfn, void* ctx, struct in_gb* gb, size_t capacity);
|
|
|
|
void in_gb_fini(in_gb_free_func_t freefn, void* ctx, struct in_gb* gb);
|
|
|
|
void in_gb_move(struct in_gb* gb, size_t pos);
|
|
|
|
void in_gb_insert(in_gb_realloc_func_t reallocfn, void* ctx, struct in_gb* gb, char c);
|
|
|
|
void in_gb_backspace(struct in_gb* gb);
|
|
|
|
void in_gb_grow(in_gb_realloc_func_t reallocfn, void* ctx, struct in_gb* gb);
|
|
|
|
size_t in_gb_length(struct in_gb* gb);
|
|
|
|
char* in_gb_string_at(in_gb_malloc_func_t mallocfn, void* ctx, struct in_gb* gb, size_t pos);
|
|
|
|
void in_gb_concat(in_gb_realloc_func_t reallocfn, void* ctx, struct in_gb* dest, struct in_gb* src);
|
|
|
|
#endif // _LIBINPUT_INPUT_GAPBUFFER_H
|