cleaning up everything in mac input setup

master
Allen Webster 2017-11-08 19:12:14 -05:00
parent bb7a098663
commit 30c16d6752
8 changed files with 666 additions and 638 deletions

View File

@ -691,13 +691,17 @@ static int32_t named_map_count = 0;
static void
change_mapping(Application_Links *app, String mapping){
bool32 did_remap = false;
for (int32_t i = 0; i < named_map_count; ++i){
if (match(mapping, named_maps[i].name)){
did_remap = true;
exec_command(app, named_maps[i].remap_command);
break;
}
}
print_message(app, literal("Leaving bindings unaltered.\n"));
if (!did_remap){
print_message(app, literal("Leaving bindings unaltered.\n"));
}
}
CUSTOM_COMMAND_SIG(remap_interactive){

File diff suppressed because it is too large Load Diff

View File

@ -687,6 +687,7 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
memset(new_mapping.map_id_table, -1, user_map_count*sizeof(i32));
new_mapping.user_maps = push_array(part, Command_Map, user_map_count);
memset(new_mapping.user_maps, 0, user_map_count*sizeof(Command_Map));
// Find the Size of Each Map
for (++unit; unit < end; ++unit){
@ -824,9 +825,10 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
{
if (map_ptr != 0){
Command_Function *func = 0;
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count)
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count){
func = command_table[unit->binding.command_id];
if (func){
}
if (func != 0){
if (unit->binding.code == 0){
u32 index = 0;
if (map_get_modifiers_hash(unit->binding.modifiers, &index)){
@ -846,7 +848,7 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
if (map_ptr != 0){
Command_Function *func = command_user_callback;
Custom_Command_Function *custom = unit->callback.func;
if (func){
if (func != 0){
if (unit->callback.code == 0){
u32 index = 0;
if (map_get_modifiers_hash(unit->binding.modifiers, &index)){

View File

@ -2098,7 +2098,7 @@ DOC_SEE(User_Input)
}
API_EXPORT User_Input
Get_Command_Input (Application_Links *app)
Get_Command_Input(Application_Links *app)
/*
DOC_RETURN(This call returns the input that triggered the currently executing command.)
DOC_SEE(User_Input)

View File

@ -138,7 +138,7 @@ map_add(Command_Map *map, Key_Code event_code, u8 modifiers, Command_Function *f
u32 max = map->max;
u32 index = hash % max;
Command_Binding entry = map->commands[index];
while (entry.function != 0 && entry.hash != COMMAND_HASH_ERASED){
for (; entry.function != 0 && entry.hash != COMMAND_HASH_ERASED;){
if (entry.hash == hash){
result = true;
break;
@ -148,12 +148,14 @@ map_add(Command_Map *map, Key_Code event_code, u8 modifiers, Command_Function *f
}
if (override_original || !result){
Command_Binding bind;
Command_Binding bind = {0};
bind.function = function;
bind.custom = custom;
bind.hash = hash;
map->commands[index] = bind;
++map->count;
if (!result){
++map->count;
}
}
return(result);
@ -171,7 +173,7 @@ map_find_entry(Command_Map *map, Key_Code event_code, u8 modifiers, u32 *index_o
u32 index = hash % max;
b32 result = false;
Command_Binding entry = map->commands[index];
while (entry.function != 0){
for (; entry.function != 0;){
if (entry.hash == hash){
*index_out = index;
result = true;
@ -222,13 +224,16 @@ map_get_modifiers_hash(u8 modifiers, u32 *hash_out){
b32 result = true;
u32 hash = 0;
if (modifiers & MDFR_SHIFT){
hash += 0x1;
hash += MDFR_SHIFT;
}
if (modifiers & MDFR_CTRL){
hash += 0x2;
hash += MDFR_CTRL;
}
if (modifiers & MDFR_CMND){
hash += MDFR_CMND;
}
if (modifiers & MDFR_ALT){
hash += 0x4;
hash += MDFR_ALT;
}
*hash_out = hash;
return(result);
@ -253,8 +258,8 @@ map_extract(Command_Map *map, Key_Event_Data key){
u8 mod_flags = MDFR_NONE;
if (ctrl) mod_flags |= MDFR_CTRL;
if (command) mod_flags |= MDFR_CMND;
if (alt) mod_flags |= MDFR_ALT;
if (command) mod_flags |= MDFR_CMND;
if (shift) mod_flags |= MDFR_SHIFT;
Key_Code code = key.character_no_caps_lock;

View File

@ -4146,10 +4146,14 @@ internal Single_Line_Input_Step
app_single_line_input_core(System_Functions *system, Working_Set *working_set, Key_Event_Data key, Single_Line_Mode mode){
Single_Line_Input_Step result = {0};
b8 ctrl = key.modifiers[MDFR_CONTROL_INDEX];
b8 cmnd = key.modifiers[MDFR_COMMAND_INDEX];
b8 alt = key.modifiers[MDFR_ALT_INDEX];
if (key.keycode == key_back){
result.hit_backspace = 1;
result.hit_backspace = true;
if (mode.string->size > 0){
result.made_a_change = 1;
result.made_a_change = true;
--mode.string->size;
switch (mode.type){
case SINGLE_LINE_STRING:
@ -4159,7 +4163,7 @@ app_single_line_input_core(System_Functions *system, Working_Set *working_set, K
case SINGLE_LINE_FILE:
{
if (!key.modifiers[MDFR_CONTROL_INDEX]){
if (!ctrl && !cmnd && !alt){
char end_character = mode.string->str[mode.string->size];
if (char_is_slash(end_character)){
mode.string->size = reverse_seek_slash(*mode.string) + 1;
@ -4183,14 +4187,14 @@ app_single_line_input_core(System_Functions *system, Working_Set *working_set, K
}
else if (key.keycode == key_esc){
result.hit_esc = 1;
result.made_a_change = 1;
result.hit_esc = true;
result.made_a_change = true;
}
else if (key.character){
result.hit_a_character = 1;
if (!key.modifiers[MDFR_CONTROL_INDEX] && !key.modifiers[MDFR_ALT_INDEX]){
if (mode.string->size+1 < mode.string->memory_size){
result.hit_a_character = true;
if (!ctrl && !cmnd && !alt){
if (mode.string->size + 1 < mode.string->memory_size){
u8 new_character = (u8)key.character;
mode.string->str[mode.string->size] = new_character;
mode.string->size++;
@ -4198,11 +4202,11 @@ app_single_line_input_core(System_Functions *system, Working_Set *working_set, K
if (mode.type == SINGLE_LINE_FILE && char_is_slash(new_character)){
hot_directory_set(system, mode.hot_directory, *mode.string);
}
result.made_a_change = 1;
result.made_a_change = true;
}
}
else{
result.did_command = 1;
result.did_command = true;
}
}

View File

@ -37,7 +37,9 @@ SOURCE=$PHYS_DIR/$TARGET_FILE
FLAGS="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-writable-strings"
DEBUG=-g
cd "$REAL_PWD"
echo "Building custom_4coders.so from $SOURCE"
g++ -I"$CODE_HOME" $FLAGS -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC
g++ -I"$CODE_HOME" $FLAGS $DEBUG -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC

View File

@ -1,4 +1,3 @@
/*
* Mr. 4th Dimention - Allen Webster
*