aboutsummaryrefslogtreecommitdiffstats
path: root/code/custom/4coder_helper.h
blob: d2e78ff21ad164c4bd953513831196c52c619119 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
 * Miscellaneous helpers for common operations.
 */

// TOP

#if !defined(FCODER_HELPER_H)
#define FCODER_HELPER_H

struct File_Name_Data{
    String_Const_u8 file_name;
    String_Const_u8 data;
};

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();
};

////////////////////////////////

typedef i32 Position_Within_Line;
enum{
    PositionWithinLine_Start,
    PositionWithinLine_SkipLeadingWhitespace,
    PositionWithinLine_End,
};

typedef u32 Buffer_Seek_String_Flags;
enum{
    BufferSeekString_Backward = 1,
    BufferSeekString_CaseInsensitive = 2,
};

////////////////////////////////

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, 
    } };

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, 
    } };

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, 
    } };

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, 
    } };

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, 
    } };

typedef i64 Boundary_Function(Application_Links *app, Buffer_ID buffer, Side side, Scan_Direction direction, i64 pos);

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;
};

typedef Range_i64 Enclose_Function(Application_Links *app, Buffer_ID buffer, Range_i64 range);

struct Indent_Info{
    i64 first_char_pos;
    i32 indent_pos;
    b32 is_blank;
    b32 all_space;
};

////////////////////////////////

struct Sort_Pair_i32{
    i32 index;
    i32 key;
};

////////////////////////////////

struct History_Group{
    Application_Links *app;
    Buffer_ID buffer;
    History_Record_Index first;
};

////////////////////////////////

typedef i32 View_Split_Kind;
enum{
    ViewSplitKind_Ratio,
    ViewSplitKind_FixedPixels,
};

////////////////////////////////

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,
};

#endif

// BOTTOM