Browse Source

field.h - structure

master
heck 2 years ago
parent
commit
97705ed9d8
  1. 42
      src/field.h

42
src/field.h

@ -2,6 +2,19 @@
#include "base.h"
#include <stdio.h> // FILE cannot be forward declared
// A reusable buffer for the per-grid-cell flags. Similar to how Field is a
// reusable buffer for Glyph, Mbuf_reusable is for Mark. The naming isn't so
// great. Also like Field, the VM doesn't have to care about the buffer being
// reusable -- it only cares about a 'Mark*' type. (With the same dimensions of
// the 'Field*' buffer, since it uses them together.) There are no procedures
// for saving/loading Mark* buffers to/from disk, since we currently don't need
// that functionality.
typedef struct Mbuf_reusable {
Mark *buffer;
Usz capacity;
} Mbuf_reusable;
// A reusable buffer for glyphs, stored with its dimensions. Also some helpers
// for loading/saving from files and doing common operations that a UI layer
// might want to do. Not used by the VM.
@ -11,14 +24,6 @@ typedef struct {
U16 width, height;
} Field;
void field_init(Field *field);
void field_init_fill(Field *field, Usz height, Usz width, Glyph fill_char);
void field_deinit(Field *field);
void field_resize_raw(Field *field, Usz height, Usz width);
void field_resize_raw_if_necessary(Field *field, Usz height, Usz width);
void field_copy(Field *src, Field *dest);
void field_fput(Field *field, FILE *stream);
typedef enum
{
Field_load_error_ok = 0,
@ -29,23 +34,18 @@ typedef enum
Field_load_error_not_a_rectangle = 5,
} Field_load_error;
void field_init(Field *field);
void field_init_fill(Field *field, Usz height, Usz width, Glyph fill_char);
void field_deinit(Field *field);
void field_resize_raw(Field *field, Usz height, Usz width);
void field_resize_raw_if_necessary(Field *field, Usz height, Usz width);
void field_copy(Field *src, Field *dest);
void field_fput(Field *field, FILE *stream);
Field_load_error field_load_file(char const *filepath, Field *field);
char const *field_load_error_string(Field_load_error fle);
// A reusable buffer for the per-grid-cell flags. Similar to how Field is a
// reusable buffer for Glyph, Mbuf_reusable is for Mark. The naming isn't so
// great. Also like Field, the VM doesn't have to care about the buffer being
// reusable -- it only cares about a 'Mark*' type. (With the same dimensions of
// the 'Field*' buffer, since it uses them together.) There are no procedures
// for saving/loading Mark* buffers to/from disk, since we currently don't need
// that functionality.
typedef struct Mbuf_reusable {
Mark *buffer;
Usz capacity;
} Mbuf_reusable;
void mbuf_reusable_init(Mbuf_reusable *mbr);
void mbuf_reusable_ensure_size(Mbuf_reusable *mbr, Usz height, Usz width);
void mbuf_reusable_deinit(Mbuf_reusable *mbr);

Loading…
Cancel
Save