2017-01-07 02:59:55 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 06.01.2017
|
|
|
|
*
|
|
|
|
* Undo subsystem for 4coder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
//
|
|
|
|
// Undo Basics
|
|
|
|
//
|
|
|
|
|
|
|
|
enum Edit_Type{
|
|
|
|
ED_NORMAL,
|
|
|
|
ED_REVERSE_NORMAL,
|
|
|
|
ED_UNDO,
|
|
|
|
ED_REDO,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Edit_Step{
|
|
|
|
Edit_Type type;
|
|
|
|
union{
|
|
|
|
struct{
|
|
|
|
b32 can_merge;
|
|
|
|
Buffer_Edit edit;
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 next_block;
|
|
|
|
i32 prev_block;
|
2017-01-07 02:59:55 +00:00
|
|
|
};
|
|
|
|
struct{
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 first_child;
|
|
|
|
i32 inverse_first_child;
|
|
|
|
i32 inverse_child_count;
|
|
|
|
i32 special_type;
|
2017-01-07 02:59:55 +00:00
|
|
|
};
|
|
|
|
};
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 child_count;
|
2017-01-07 02:59:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Edit_Stack{
|
|
|
|
u8 *strings;
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 size, max;
|
2017-01-07 02:59:55 +00:00
|
|
|
|
|
|
|
Edit_Step *edits;
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 edit_count, edit_max;
|
2017-01-07 02:59:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Small_Edit_Stack{
|
|
|
|
u8 *strings;
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 size, max;
|
2017-01-07 02:59:55 +00:00
|
|
|
|
|
|
|
Buffer_Edit *edits;
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 edit_count, edit_max;
|
2017-01-07 02:59:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Undo_Data{
|
|
|
|
Edit_Stack undo;
|
|
|
|
Edit_Stack redo;
|
|
|
|
Edit_Stack history;
|
|
|
|
Small_Edit_Stack children;
|
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
i32 history_block_count, history_head_block;
|
|
|
|
i32 edit_history_cursor;
|
2017-01-07 02:59:55 +00:00
|
|
|
b32 current_block_normal;
|
|
|
|
};
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|