Fixed some keyboard problems, going to ditch 4coder-like next

This commit is contained in:
Allen Webster 2017-11-15 11:13:36 -05:00
parent 162ffe828a
commit a9acd4831c
3 changed files with 18 additions and 12 deletions

View File

@ -339,6 +339,7 @@ mac_default_keys(Bind_Helper *context){
begin_map(context, mapid_file);
bind_vanilla_keys(context, write_character);
bind_vanilla_keys(context, MDFR_ALT, write_character);
bind(context, key_mouse_left, MDFR_NONE, click_set_cursor);
bind(context, key_mouse_left_release, MDFR_NONE, click_set_mark);
@ -362,15 +363,12 @@ mac_default_keys(Bind_Helper *context){
bind(context, key_up, MDFR_CMND, seek_whitespace_up_end_line);
bind(context, key_down, MDFR_CMND, seek_whitespace_down_end_line);
bind(context, key_up, MDFR_ALT, move_up_10);
bind(context, key_down, MDFR_ALT, move_down_10);
bind(context, key_back, MDFR_CMND, backspace_word);
bind(context, key_del, MDFR_CMND, delete_word);
bind(context, key_back, MDFR_CTRL, snipe_token_or_word);
bind(context, key_del, MDFR_CTRL, snipe_token_or_word_right);
bind(context, ' ', MDFR_CTRL, set_mark);
bind(context, '/', MDFR_CMND, set_mark);
bind(context, 'a', MDFR_CMND, replace_in_range);
bind(context, 'c', MDFR_CMND, copy);
bind(context, 'd', MDFR_CMND, delete_range);

View File

@ -441,10 +441,10 @@ osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){
Key_Code chr = code;
Key_Code nocaps = code;
if (modifier_flags.caps){
if ('a' <= chr && chr <= 'z'){
if ('a' <= nocaps && nocaps <= 'z'){
chr += 'A' - 'a';
}
else if ('A' <= chr && chr <= 'Z'){
else if ('A' <= nocaps && nocaps <= 'Z'){
chr += 'a' - 'A';
}
}

View File

@ -54,6 +54,7 @@ osx_post_to_clipboard(char *str){
osx_objc.just_posted_to_clipboard = true;
}
void
osx_error_dialogue(char *str){
NSAlert *alert = [[NSAlert alloc] init];
@ -90,6 +91,7 @@ static DISPLINK_SIG(osx_display_link);
- (void)keyDown:(NSEvent *)event{
NSString *real = [event charactersIgnoringModifiers];
NSString *with_mods = [event characters];
b32 is_dead_key = false;
if (real && !with_mods){
is_dead_key = true;
@ -103,9 +105,17 @@ static DISPLINK_SIG(osx_display_link);
mods.option = ((flags & NSEventModifierFlagOption) != 0);
mods.caps = ((flags & NSEventModifierFlagCapsLock) != 0);
u32 length = real.length;
// TODO(allen): Not ideal solution, look for realer text
// input on Mac. This just makes sure we're getting good
// results for unmodified keys when cmnd and ctrl aren't down.
NSString *which = with_mods;
if (mods.command || mods.control){
which = real;
}
u32 length = which.length;
for (u32 i = 0; i < length; ++i){
unichar c = [real characterAtIndex:i];
unichar c = [which characterAtIndex:i];
osx_character_input(c, mods);
}
}
@ -337,11 +347,9 @@ file_change_node_free(File_Change_Node *node){
free(node);
}
#define file_queue_lock()
//for(;;){i64 v=__sync_val_compare_and_swap(&file_queue.lock,0,1);if(v==0){break;}}
#define file_queue_lock() for(;;){i64 v=__sync_val_compare_and_swap(&file_queue.lock,0,1);if(v==0){break;}}
#define file_queue_unlock()
//__sync_lock_test_and_set(&file_queue.lock, 0)
#define file_queue_unlock() __sync_lock_test_and_set(&file_queue.lock, 0)
void
file_watch_callback(ConstFSEventStreamRef stream, void *callbackInfo, size_t numEvents, void *evPaths, const FSEventStreamEventFlags *evFlags, const FSEventStreamEventId *evIds){