2018-05-10 08:12:47 +00:00
|
|
|
/*
|
|
|
|
* Miscellaneous helpers for common operations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FCODER_HELPER_H)
|
|
|
|
#define FCODER_HELPER_H
|
|
|
|
|
2018-05-19 22:05:31 +00:00
|
|
|
struct File_Name_Data{
|
2019-06-01 23:58:28 +00:00
|
|
|
String_Const_u8 file_name;
|
2020-12-31 00:55:11 +00:00
|
|
|
String_Const_u8 data;
|
2018-08-10 21:52:57 +00:00
|
|
|
};
|
2018-05-19 22:05:31 +00:00
|
|
|
|
2019-10-29 01:28:44 +00:00
|
|
|
struct View_Context_Block{
|
|
|
|
Application_Links *app;
|
|
|
|
View_ID view;
|
|
|
|
|
|
|
|
View_Context_Block(Application_Links *app, View_ID view, View_Context *ctx);
|
|
|
|
~View_Context_Block();
|
|
|
|
};
|
|
|
|
|
2018-05-19 22:05:31 +00:00
|
|
|
////////////////////////////////
|
2018-05-10 08:12:47 +00:00
|
|
|
|
2019-06-16 23:38:22 +00:00
|
|
|
typedef i32 Position_Within_Line;
|
|
|
|
enum{
|
|
|
|
PositionWithinLine_Start,
|
|
|
|
PositionWithinLine_SkipLeadingWhitespace,
|
|
|
|
PositionWithinLine_End,
|
|
|
|
};
|
|
|
|
|
2019-10-01 19:12:34 +00:00
|
|
|
typedef u32 Buffer_Seek_String_Flags;
|
|
|
|
enum{
|
|
|
|
BufferSeekString_Backward = 1,
|
|
|
|
BufferSeekString_CaseInsensitive = 2,
|
|
|
|
};
|
|
|
|
|
2019-06-16 23:38:22 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2019-06-09 00:09:14 +00:00
|
|
|
typedef b8 Character_Predicate_Function(u8 c);
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_alpha = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
254, 255, 255, 7, 254, 255, 255, 7,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_alpha_numeric = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
254, 255, 255, 7, 254, 255, 255, 7,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_alpha_numeric_underscore = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
254, 255, 255, 135, 254, 255, 255, 7,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_uppercase = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
254, 255, 255, 7, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_lowercase = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 254, 255, 255, 7,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_base10 = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_base16 = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
126, 0, 0, 0, 126, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
|
|
|
global Character_Predicate character_predicate_whitespace = { {
|
|
|
|
0, 62, 0, 0, 1, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
} };
|
|
|
|
|
2019-06-09 21:05:57 +00:00
|
|
|
global Character_Predicate character_predicate_non_whitespace = { {
|
|
|
|
255, 193, 255, 255, 254, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
} };
|
|
|
|
|
2019-06-09 00:09:14 +00:00
|
|
|
global Character_Predicate character_predicate_utf8_byte = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
} };
|
|
|
|
|
2021-05-15 03:32:31 +00:00
|
|
|
global Character_Predicate character_predicate_alpha_numeric_utf8 = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
254, 255, 255, 7, 254, 255, 255, 7,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
} };
|
|
|
|
|
2019-06-14 21:07:17 +00:00
|
|
|
global Character_Predicate character_predicate_alpha_numeric_underscore_utf8 = { {
|
|
|
|
0, 0, 0, 0, 0, 0, 255, 3,
|
|
|
|
254, 255, 255, 135, 254, 255, 255, 7,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
} };
|
|
|
|
|
2019-06-20 23:43:27 +00:00
|
|
|
typedef i64 Boundary_Function(Application_Links *app, Buffer_ID buffer, Side side, Scan_Direction direction, i64 pos);
|
2019-06-11 05:01:57 +00:00
|
|
|
|
|
|
|
struct Boundary_Function_Node{
|
|
|
|
Boundary_Function_Node *next;
|
|
|
|
Boundary_Function *func;
|
|
|
|
};
|
|
|
|
struct Boundary_Function_List{
|
|
|
|
Boundary_Function_Node *first;
|
|
|
|
Boundary_Function_Node *last;
|
|
|
|
i32 count;
|
2019-06-09 21:05:57 +00:00
|
|
|
};
|
|
|
|
|
2019-06-20 23:43:27 +00:00
|
|
|
typedef Range_i64 Enclose_Function(Application_Links *app, Buffer_ID buffer, Range_i64 range);
|
2019-06-11 05:01:57 +00:00
|
|
|
|
2019-06-14 22:57:22 +00:00
|
|
|
struct Indent_Info{
|
2019-06-20 23:43:27 +00:00
|
|
|
i64 first_char_pos;
|
2019-06-14 22:57:22 +00:00
|
|
|
i32 indent_pos;
|
2019-06-20 23:43:27 +00:00
|
|
|
b32 is_blank;
|
|
|
|
b32 all_space;
|
2019-06-14 22:57:22 +00:00
|
|
|
};
|
|
|
|
|
2019-06-09 00:09:14 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2018-08-18 08:16:52 +00:00
|
|
|
struct Sort_Pair_i32{
|
2019-02-26 23:08:42 +00:00
|
|
|
i32 index;
|
|
|
|
i32 key;
|
2018-08-18 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
struct History_Group{
|
|
|
|
Application_Links *app;
|
|
|
|
Buffer_ID buffer;
|
|
|
|
History_Record_Index first;
|
|
|
|
};
|
|
|
|
|
2019-06-19 02:31:59 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
typedef i32 View_Split_Kind;
|
|
|
|
enum{
|
|
|
|
ViewSplitKind_Ratio,
|
|
|
|
ViewSplitKind_FixedPixels,
|
|
|
|
};
|
|
|
|
|
2019-10-16 04:54:40 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
typedef i32 Nest_Delimiter_Kind;
|
|
|
|
enum{
|
|
|
|
NestDelim_None = 0,
|
|
|
|
NestDelim_Open = 1,
|
|
|
|
NestDelim_Close = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef u32 Find_Nest_Flag;
|
|
|
|
enum{
|
|
|
|
FindNest_Scope = 1,
|
|
|
|
FindNest_Paren = 2,
|
|
|
|
FindNest_EndOfToken = 4,
|
|
|
|
FindNest_Balanced = 8,
|
|
|
|
};
|
|
|
|
|
2018-05-10 08:12:47 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-02 00:58:44 +00:00
|
|
|
// BOTTOM
|