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 | #include "4coder_default_include.cpp"
CUSTOM_COMMAND_SIG(switch_buffer_rot)
CUSTOM_DOC("Switches the buffer by rotating to the most recently used one. Useful if you're constantly changing between 2 different buffers.")
{
Buffer_Summary next_buffer = {};
get_buffer_next(app, &next_buffer, AccessHidden);
View_Summary active_view = get_active_view(app, AccessOpen);
view_set_buffer(app, &active_view,next_buffer.buffer_id, 0);
}
CUSTOM_COMMAND_SIG(kill_cur_buffer_and_rot)
CUSTOM_DOC("Kills the buffer in the current view, and opens the next buffer in its place")
{
Buffer_Summary next_buffer = {};
get_buffer_next(app, &next_buffer, AccessHidden);
View_Summary active_view = get_active_view(app, AccessOpen);
Buffer_Identifier buff_ident = {0, 0, active_view.buffer_id};
kill_buffer(app, buff_ident, active_view.view_id, 0);
view_set_buffer(app, &active_view,next_buffer.buffer_id, 0);
}
CUSTOM_COMMAND_SIG(seek_whitespace_or_inword_right)
CUSTOM_DOC("Seek right. If the word is camelCase, or snake_case, it'll seek until the next separator, or it'll just go until the end of the word.")
{ basic_seek(app, true, BoundaryAlphanumeric | BoundaryCamelCase | BoundaryWhitespace); }
CUSTOM_COMMAND_SIG(seek_whitespace_or_inword_left)
CUSTOM_DOC("Seek left. If the word is camelCase, or snake_case, it'll seek until the next separator, or it'll just go until the end of the word.")
{ basic_seek(app, false, BoundaryAlphanumeric | BoundaryCamelCase | BoundaryWhitespace); }
CUSTOM_COMMAND_SIG(seek_word_right)
CUSTOM_DOC("Seek right. Always reaches end of current word.")
{ basic_seek(app, true, BoundaryWhitespace); }
CUSTOM_COMMAND_SIG(seek_word_left)
CUSTOM_DOC("Seek left. Always reaches end of current word.")
{ basic_seek(app, false, BoundaryWhitespace); }
CUSTOM_COMMAND_SIG(move_buffer_other_panel)
CUSTOM_DOC("Moves buffer in active panel to other non-active panel, and switches current panel with next available buffer")
{
swap_buffers_between_panels(app);
switch_buffer_rot(app);
}
extern "C" int32_t get_bindings(void *data, int32_t size)
{
Bind_Helper context_ = begin_bind_helper(data, size);
Bind_Helper *context = &context_;
set_all_default_hooks(context);
/* Put all bindings here */
bind(context, ' ', MDFR_CTRL, set_mark);
bind(context, 'c', MDFR_CTRL, copy);
bind(context, 'd', MDFR_CTRL, delete_range);
bind(context, 'D', MDFR_CTRL, delete_line);
bind(context, 'f', MDFR_CTRL, search);
bind(context, 'F', MDFR_CTRL, list_all_locations);
bind(context, 'F', MDFR_ALT, list_all_substring_locations_case_insensitive);
bind(context, 'l', MDFR_CTRL , change_active_panel);
bind(context, 'p', MDFR_CTRL , open_panel_vsplit);
bind(context, 'p', MDFR_ALT , open_panel_hsplit);
bind(context, 'k', MDFR_CTRL , close_panel);
bind(context, 's', MDFR_CTRL , save);
bind(context, 'S', MDFR_CTRL , save_all_dirty_buffers);
bind(context, 'o', MDFR_CTRL , interactive_open_or_new);
bind(context, 'O', MDFR_CTRL , open_in_other);
bind(context, 'i', MDFR_CTRL , switch_buffer_rot);
bind(context, 'I', MDFR_CTRL , interactive_switch_buffer);
bind(context, 'n', MDFR_CTRL , interactive_new);
bind(context, 'j', MDFR_CTRL , kill_cur_buffer_and_rot);
bind(context, 'J', MDFR_CTRL , interactive_kill_buffer);
bind(context, 'y', MDFR_CTRL, redo);
bind(context, 'z', MDFR_CTRL, undo);
bind(context, 'u', MDFR_CTRL , view_buffer_other_panel);
bind(context, 'U', MDFR_CTRL , swap_buffers_between_panels);
bind(context, 'u', MDFR_ALT , move_buffer_other_panel);
bind(context, '.', MDFR_CTRL , open_matching_file_cpp);
bind(context, key_right, MDFR_CTRL , seek_whitespace_or_inword_right);
bind(context, key_left, MDFR_CTRL , seek_whitespace_or_inword_left);
bind(context, key_right, MDFR_CTRL | MDFR_SHIFT , seek_word_right);
bind(context, key_left, MDFR_CTRL | MDFR_SHIFT , seek_word_left);
bind(context, key_up, MDFR_CTRL , seek_whitespace_up_end_line);
bind(context, key_down, MDFR_CTRL , seek_whitespace_down_end_line);
bind(context, key_up, MDFR_ALT , move_line_up);
bind(context, key_down, MDFR_ALT , move_line_down);
bind(context, key_back, MDFR_CTRL, backspace_word);
bind(context, key_del, MDFR_CTRL, delete_word);
bind(context, key_back, MDFR_ALT, snipe_token_or_word);
bind(context, key_del, MDFR_ALT, snipe_token_or_word_right);
bind(context, 'ù', MDFR_ALT , open_color_tweaker);
int32_t result = end_bind_helper(context);
return(result);
}
|