-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4coder_sloth.cpp
More file actions
105 lines (96 loc) · 4.99 KB
/
4coder_sloth.cpp
File metadata and controls
105 lines (96 loc) · 4.99 KB
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
#include "4coder_default_include.h"
//#define SNIPPET_EXPANSION "path/to/snippet.inc"
//#define AUTO_CENTER_AFTER_JUMPS true
CUSTOM_ID(colors, defcolor_type);
CUSTOM_ID(colors, defcolor_function);
CUSTOM_ID(colors, defcolor_macro);
CUSTOM_ID(colors, defcolor_enum);
CUSTOM_ID(colors, defcolor_global);
CUSTOM_ID(colors, defcolor_control);
CUSTOM_ID(colors, defcolor_primitive);
CUSTOM_ID(colors, defcolor_struct);
CUSTOM_ID(colors, defcolor_non_text);
CUSTOM_ID(colors, defcolor_operator);
CUSTOM_ID(colors, defcolor_list_back); // NOTE(sloth): my color which your theme prolly doesn't have
CUSTOM_ID(colors, lily_color_file_progress_bar);
CUSTOM_ID(colors, lily_color_comment_user_name);
#include "4coder_qol_helper.h"
#include "4coder_default_include.cpp"
#include "plugins/4coder_multi_cursor.cpp"
global b32 qol_opened_brace = false;
global u8 qol_target_char;
global Buffer_Cursor qol_col_cursor = {-1};
global Vec2_f32 qol_cur_cursor_pos;
global Vec2_f32 qol_nxt_cursor_pos;
global Color_Table qol_cur_colors;
global Color_Table qol_nxt_colors;
global Face_ID qol_small_face;
global Buffer_ID qol_temp_buffer; // NOTE(sloth): used to allow qol_ctrl_backspace_string in queries
global u8 g_qol_bot_buffer[1024];
global String_u8 g_qol_bot_string = Su8(g_qol_bot_buffer, 0, sizeof(g_qol_bot_buffer));
global Character_Predicate character_predicate_word = {};
global Character_Predicate character_predicate_non_word = {};
#include "generated/lexer_markdown.h"
#include "generated/lexer_markdown.cpp"
#include "4coder_qol_helper.cpp"
#include "4coder_sloth_helper.cpp"
#include "4coder_qol_block.cpp" // NOTE(sloth): "block": characters appearing in buffers on different columns and lines make "blocks"
#include "4coder_sloth_jump.cpp"
#include "4coder_qol_colors.cpp"
#include "4coder_sloth_token.cpp"
#include "4coder_sloth_bindings.cpp"
#include "4coder_qol_commands.cpp"
#include "4coder_sloth_commands.cpp"
#include "4coder_fleury_base_commands.cpp"
#include "4coder_qol_isearch.cpp"
#include "4coder_modal_bindings_hud.cpp"
function void sloth_draw_file_bar(Application_Links *app, View_ID view_id, Buffer_ID buffer, Face_ID face_id, Rect_f32 bar);
function void sloth_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id, Buffer_ID buffer, Text_Layout_ID text_layout_id, Rect_f32 rect);
#include "4coder_sloth_draw.cpp"
#include "4coder_sloth_lister.cpp"
#include "4coder_clang_format.cpp"
#include "4coder_qol_snippets.cpp"
#include "4coder_sloth_hooks.cpp"
#if !defined(META_PASS)
# include "generated/managed_id_metadata.cpp"
#endif
void
custom_layer_init(Application_Links *app) {
default_framework_init(app);
MC_init(app);
MC_register(exit_4coder, MC_Command_Global);
MC_register(default_try_exit, MC_Command_Global);
MC_register(lily_mouse_wheel_change_face_size, MC_Command_Global);
MC_register(swap_panels, MC_Command_Global);
MC_register(save, MC_Command_Global);
MC_register(save_all_dirty_buffers, MC_Command_Global);
MC_register(qol_column_toggle, MC_Command_Global);
MC_register(center_view, MC_Command_Global);
MC_register(left_adjust_view, MC_Command_Global);
MC_register(lily_copy, MC_Command_CursorCopy);
MC_register(lily_cut, MC_Command_CursorCopy);
MC_register(paste_and_indent, MC_Command_CursorPaste);
set_custom_hook(app, HookID_BufferViewerUpdate, default_view_adjust);
set_custom_hook(app, HookID_ViewEventHandler, sloth_view_input_handler);
set_custom_hook(app, HookID_Tick, sloth_tick);
set_custom_hook(app, HookID_RenderCaller, sloth_render_caller);
set_custom_hook(app, HookID_WholeScreenRenderCaller, default_whole_screen_render_caller);
set_custom_hook(app, HookID_DeltaRule, fixed_time_cubic_delta);
set_custom_hook_memory_size(app, HookID_DeltaRule, delta_ctx_size(fixed_time_cubic_delta_memory_size));
set_custom_hook(app, HookID_BufferNameResolver, default_buffer_name_resolution);
set_custom_hook(app, HookID_BeginBuffer, default_begin_buffer);
set_custom_hook(app, HookID_EndBuffer, end_buffer_close_jump_list);
set_custom_hook(app, HookID_NewFile, default_new_file);
set_custom_hook(app, HookID_SaveFile, qol_file_save);
set_custom_hook(app, HookID_BufferEditRange, sloth_buffer_edit_range);
set_custom_hook(app, HookID_BufferRegion, sloth_buffer_region);
set_custom_hook(app, HookID_ViewChangeBuffer, default_view_change_buffer);
set_custom_hook(app, HookID_Layout, layout_unwrapped);
Thread_Context *tctx = get_thread_context(app);
mapping_init(tctx, &framework_mapping);
String_ID global_map_id = vars_save_string_lit("keys_global");
String_ID file_map_id = vars_save_string_lit("keys_file");
String_ID code_map_id = vars_save_string_lit("keys_code");
// TODO(sloth): why do we need to call this so many times?
sloth_setup_essential_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id);
}