Bindings only do strict-matching now so ordering is less important and less confusing
parent
d72636138d
commit
8b2281e093
|
@ -208,9 +208,11 @@ map_get_binding_non_recursive(Command_Map *map, Input_Event *event){
|
||||||
}
|
}
|
||||||
else if (map != 0){
|
else if (map != 0){
|
||||||
b32 do_table_lookup = false;
|
b32 do_table_lookup = false;
|
||||||
Input_Modifier_Set *mods = 0;
|
Input_Modifier_Set *mod_set = 0;
|
||||||
u64 key = 0;
|
u64 key = 0;
|
||||||
|
Key_Code skip_self_mod = 0;
|
||||||
|
|
||||||
|
// TODO(allen): extract and make sure we only do this once for recursive version.
|
||||||
switch (event->kind){
|
switch (event->kind){
|
||||||
case InputEventKind_TextInsert:
|
case InputEventKind_TextInsert:
|
||||||
{
|
{
|
||||||
|
@ -221,28 +223,29 @@ map_get_binding_non_recursive(Command_Map *map, Input_Event *event){
|
||||||
{
|
{
|
||||||
key = mapping__key(InputEventKind_KeyStroke, event->key.code);
|
key = mapping__key(InputEventKind_KeyStroke, event->key.code);
|
||||||
do_table_lookup = true;
|
do_table_lookup = true;
|
||||||
mods = &event->key.modifiers;
|
mod_set = &event->key.modifiers;
|
||||||
|
skip_self_mod = event->key.code;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_MouseButton:
|
case InputEventKind_MouseButton:
|
||||||
{
|
{
|
||||||
key = mapping__key(InputEventKind_MouseButton, event->mouse.code);
|
key = mapping__key(InputEventKind_MouseButton, event->mouse.code);
|
||||||
do_table_lookup = true;
|
do_table_lookup = true;
|
||||||
mods = &event->mouse.modifiers;
|
mod_set = &event->mouse.modifiers;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_MouseWheel:
|
case InputEventKind_MouseWheel:
|
||||||
{
|
{
|
||||||
key = mapping__key(InputEventKind_MouseWheel, 0);
|
key = mapping__key(InputEventKind_MouseWheel, 0);
|
||||||
do_table_lookup = true;
|
do_table_lookup = true;
|
||||||
mods = &event->mouse_wheel.modifiers;
|
mod_set = &event->mouse_wheel.modifiers;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_MouseMove:
|
case InputEventKind_MouseMove:
|
||||||
{
|
{
|
||||||
key = mapping__key(InputEventKind_MouseMove, 0);
|
key = mapping__key(InputEventKind_MouseMove, 0);
|
||||||
do_table_lookup = true;
|
do_table_lookup = true;
|
||||||
mods = &event->mouse_move.modifiers;
|
mod_set = &event->mouse_move.modifiers;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case InputEventKind_Core:
|
case InputEventKind_Core:
|
||||||
|
@ -258,7 +261,7 @@ map_get_binding_non_recursive(Command_Map *map, Input_Event *event){
|
||||||
u64 val = 0;
|
u64 val = 0;
|
||||||
table_read(&map->event_code_to_binding_list, lookup, &val);
|
table_read(&map->event_code_to_binding_list, lookup, &val);
|
||||||
Command_Binding_List *list = (Command_Binding_List*)IntAsPtr(val);
|
Command_Binding_List *list = (Command_Binding_List*)IntAsPtr(val);
|
||||||
if (mods != 0){
|
if (mod_set != 0){
|
||||||
for (SNode *node = list->first;
|
for (SNode *node = list->first;
|
||||||
node != 0;
|
node != 0;
|
||||||
node = node->next){
|
node = node->next){
|
||||||
|
@ -268,7 +271,15 @@ map_get_binding_non_recursive(Command_Map *map, Input_Event *event){
|
||||||
i32 binding_mod_count = binding_mod_set->count;
|
i32 binding_mod_count = binding_mod_set->count;
|
||||||
Key_Code *binding_mods = binding_mod_set->mods;
|
Key_Code *binding_mods = binding_mod_set->mods;
|
||||||
for (i32 i = 0; i < binding_mod_count; i += 1){
|
for (i32 i = 0; i < binding_mod_count; i += 1){
|
||||||
if (!has_modifier(mods, binding_mods[i])){
|
if (!has_modifier(mod_set, binding_mods[i])){
|
||||||
|
is_a_match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i32 mod_count = mod_set->count;
|
||||||
|
Key_Code *mods = mod_set->mods;
|
||||||
|
for (i32 i = 0; i < mod_count; i += 1){
|
||||||
|
if (mods[i] != skip_self_mod && !has_modifier(binding_mod_set, mods[i])){
|
||||||
is_a_match = false;
|
is_a_match = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ setup_default_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id)
|
||||||
Bind(command_lister, KeyCode_X, KeyCode_Alt);
|
Bind(command_lister, KeyCode_X, KeyCode_Alt);
|
||||||
Bind(project_command_lister, KeyCode_X, KeyCode_Alt, KeyCode_Shift);
|
Bind(project_command_lister, KeyCode_X, KeyCode_Alt, KeyCode_Shift);
|
||||||
Bind(list_all_functions_current_buffer_lister, KeyCode_I, KeyCode_Control, KeyCode_Shift);
|
Bind(list_all_functions_current_buffer_lister, KeyCode_I, KeyCode_Control, KeyCode_Shift);
|
||||||
|
Bind(exit_4coder, KeyCode_F4, KeyCode_Alt);
|
||||||
Bind(project_fkey_command, KeyCode_F1);
|
Bind(project_fkey_command, KeyCode_F1);
|
||||||
Bind(project_fkey_command, KeyCode_F2);
|
Bind(project_fkey_command, KeyCode_F2);
|
||||||
Bind(project_fkey_command, KeyCode_F3);
|
Bind(project_fkey_command, KeyCode_F3);
|
||||||
|
@ -53,7 +54,6 @@ setup_default_mapping(Mapping *mapping, i64 global_id, i64 file_id, i64 code_id)
|
||||||
Bind(project_fkey_command, KeyCode_F14);
|
Bind(project_fkey_command, KeyCode_F14);
|
||||||
Bind(project_fkey_command, KeyCode_F15);
|
Bind(project_fkey_command, KeyCode_F15);
|
||||||
Bind(project_fkey_command, KeyCode_F16);
|
Bind(project_fkey_command, KeyCode_F16);
|
||||||
Bind(exit_4coder, KeyCode_F4, KeyCode_Alt);
|
|
||||||
BindMouseWheel(mouse_wheel_scroll);
|
BindMouseWheel(mouse_wheel_scroll);
|
||||||
BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Control);
|
BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Control);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue