2018-03-24 10:06:45 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 24.01.2018
|
|
|
|
*
|
|
|
|
* Buffer types
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FRED_BUFFER_H)
|
|
|
|
#define FRED_BUFFER_H
|
|
|
|
|
|
|
|
struct Cursor_With_Index{
|
2019-08-24 01:34:42 +00:00
|
|
|
i64 pos;
|
2018-03-24 10:06:45 +00:00
|
|
|
i32 index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Gap_Buffer{
|
2019-09-02 18:59:36 +00:00
|
|
|
Base_Allocator *allocator;
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
u8 *data;
|
|
|
|
i64 size1;
|
|
|
|
i64 gap_size;
|
|
|
|
i64 size2;
|
|
|
|
i64 max;
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
// NOTE(allen): If there are N lines I store N + 1 slots in this array with
|
|
|
|
// line_starts[N] = size of the buffer.
|
|
|
|
// The variable line_start_count stores N + 1; call buffer_line_count(buffer)
|
|
|
|
// to get "N" the actual number of lines.
|
|
|
|
i64 *line_starts;
|
|
|
|
i64 line_start_count;
|
|
|
|
i64 line_start_max;
|
2018-03-24 10:06:45 +00:00
|
|
|
};
|
|
|
|
|
2019-06-11 23:16:27 +00:00
|
|
|
struct Buffer_Chunk_Position{
|
2019-09-02 18:59:36 +00:00
|
|
|
i64 real_pos;
|
|
|
|
i64 chunk_pos;
|
|
|
|
i64 chunk_index;
|
2018-03-24 10:06:45 +00:00
|
|
|
};
|
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
typedef u32 Buffer_Layout_Flag;
|
2018-03-24 10:06:45 +00:00
|
|
|
enum{
|
|
|
|
BRFlag_Special_Character = (1 << 0),
|
|
|
|
BRFlag_Ghost_Character = (1 << 1)
|
|
|
|
};
|
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
struct Buffer_Layout_Item{
|
|
|
|
i64 index;
|
2018-03-24 10:06:45 +00:00
|
|
|
u32 codepoint;
|
2019-09-02 18:59:36 +00:00
|
|
|
Buffer_Layout_Flag flags;
|
|
|
|
Rect_f32 rect;
|
2018-03-24 10:06:45 +00:00
|
|
|
};
|
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
struct Buffer_Layout_Item_Block{
|
|
|
|
Buffer_Layout_Item_Block *next;
|
|
|
|
Buffer_Layout_Item *items;
|
|
|
|
i64 count;
|
|
|
|
i64 character_count;
|
2018-03-24 10:06:45 +00:00
|
|
|
};
|
|
|
|
|
2019-09-02 18:59:36 +00:00
|
|
|
struct Buffer_Layout_Item_List{
|
|
|
|
Buffer_Layout_Item_Block *first;
|
|
|
|
Buffer_Layout_Item_Block *last;
|
|
|
|
i32 node_count;
|
|
|
|
i32 total_count;
|
2018-03-24 10:06:45 +00:00
|
|
|
f32 height;
|
2019-10-09 19:48:01 +00:00
|
|
|
f32 bottom_extension;
|
2019-09-02 18:59:36 +00:00
|
|
|
i64 character_count;
|
|
|
|
Interval_i64 index_range;
|
2018-03-24 10:06:45 +00:00
|
|
|
};
|
|
|
|
|
2019-10-26 20:48:50 +00:00
|
|
|
#if 0
|
|
|
|
struct Edit_Array{
|
|
|
|
Edit *vals;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
#endif
|
|
|
|
|
2019-01-29 05:36:17 +00:00
|
|
|
// BOTTOM
|