From 8bfbabd87744c84357301e5b1b46bed573ff7a71 Mon Sep 17 00:00:00 2001 From: Ilia Demianenko Date: Thu, 13 Jul 2023 21:36:31 -0700 Subject: [PATCH 1/4] Orca UI support --- src/platform/orca_clock.c | 6 ++++++ src/platform/platform_clock.h | 1 + src/ui.c | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/platform/orca_clock.c diff --git a/src/platform/orca_clock.c b/src/platform/orca_clock.c new file mode 100644 index 0000000..8658f0a --- /dev/null +++ b/src/platform/orca_clock.c @@ -0,0 +1,6 @@ +#include"util/typedefs.h" +#include"platform_clock.h" + +void ORCA_IMPORT(mp_clock_init)(); + +f64 ORCA_IMPORT(mp_get_time)(mp_clock_kind clock); diff --git a/src/platform/platform_clock.h b/src/platform/platform_clock.h index 023b885..98fba1d 100644 --- a/src/platform/platform_clock.h +++ b/src/platform/platform_clock.h @@ -10,6 +10,7 @@ #define __PLATFORM_CLOCK_H_ #include"util/typedefs.h" +#include"platform.h" #ifdef __cplusplus extern "C" { diff --git a/src/ui.c b/src/ui.c index fd13c1a..de97e29 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2249,6 +2249,7 @@ str32 ui_edit_delete_selection(ui_context* ui, str32 codepoints) void ui_edit_copy_selection_to_clipboard(ui_context* ui, str32 codepoints) { + #if !PLATFORM_ORCA if(ui->editCursor == ui->editMark) { return; @@ -2260,13 +2261,18 @@ void ui_edit_copy_selection_to_clipboard(ui_context* ui, str32 codepoints) mp_clipboard_clear(); mp_clipboard_set_string(string); + #endif } str32 ui_edit_replace_selection_with_clipboard(ui_context* ui, str32 codepoints) { + #if PLATFORM_ORCA + str32 result = {0}; + #else str8 string = mp_clipboard_get_string(&ui->frameArena); str32 input = utf8_push_to_codepoints(&ui->frameArena, string); str32 result = ui_edit_replace_selection_with_codepoints(ui, codepoints, input); + #endif return(result); } @@ -2297,7 +2303,7 @@ typedef struct ui_edit_command } ui_edit_command; -#if PLATFORM_WINDOWS +#if PLATFORM_WINDOWS || PLATFORM_ORCA #define OS_COPY_PASTE_MOD MP_KEYMOD_CTRL #elif PLATFORM_MACOS #define OS_COPY_PASTE_MOD MP_KEYMOD_CMD From 40906bb852d1785fea990c76bf5068f3d4090bc1 Mon Sep 17 00:00:00 2001 From: Ilia Demianenko Date: Sat, 15 Jul 2023 00:15:12 -0700 Subject: [PATCH 2/4] Feedback --- src/mp_app.h | 11 ++++++----- src/osx_app.m | 1 + src/platform/orca_clock.c | 2 -- src/ui.c | 14 ++++++++------ src/util/hash.c | 2 +- src/win32_app.c | 1 + 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/mp_app.h b/src/mp_app.h index 468b06c..d652c9c 100644 --- a/src/mp_app.h +++ b/src/mp_app.h @@ -190,11 +190,12 @@ typedef enum { MP_KEY_UNKNOWN = 0, MP_KEY_COUNT } mp_key_code; typedef enum { - MP_KEYMOD_NONE = 0x00, - MP_KEYMOD_ALT = 0x01, - MP_KEYMOD_SHIFT = 0x02, - MP_KEYMOD_CTRL = 0x04, - MP_KEYMOD_CMD = 0x08 } mp_keymod_flags; + MP_KEYMOD_NONE = 0x00, + MP_KEYMOD_ALT = 0x01, + MP_KEYMOD_SHIFT = 0x02, + MP_KEYMOD_CTRL = 0x04, + MP_KEYMOD_CMD = 0x08, + MP_KEYMOD_MAIN_MODIFIER = 0x16 } mp_keymod_flags; typedef enum { MP_MOUSE_LEFT = 0x00, diff --git a/src/osx_app.m b/src/osx_app.m index 1ae74a5..affb7d7 100644 --- a/src/osx_app.m +++ b/src/osx_app.m @@ -253,6 +253,7 @@ static mp_keymod_flags mp_convert_osx_mods(NSUInteger nsFlags) if(nsFlags & NSEventModifierFlagCommand) { mods |= MP_KEYMOD_CMD; + mods |= MP_KEYMOD_MAIN_MODIFIER; } return(mods); } diff --git a/src/platform/orca_clock.c b/src/platform/orca_clock.c index 8658f0a..a93599d 100644 --- a/src/platform/orca_clock.c +++ b/src/platform/orca_clock.c @@ -1,6 +1,4 @@ #include"util/typedefs.h" #include"platform_clock.h" -void ORCA_IMPORT(mp_clock_init)(); - f64 ORCA_IMPORT(mp_get_time)(mp_clock_kind clock); diff --git a/src/ui.c b/src/ui.c index de97e29..b8aea1c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -6,11 +6,11 @@ * @revision: * *****************************************************************/ -#include"platform.h" -#include"platform_assert.h" -#include"memory.h" -#include"hash.h" -#include"platform_clock.h" +#include"platform/platform.h" +#include"platform/platform_assert.h" +#include"platform/platform_clock.h" +#include"util/memory.h" +#include"util/hash.h" #include"ui.h" static ui_style UI_STYLE_DEFAULTS = @@ -2303,10 +2303,12 @@ typedef struct ui_edit_command } ui_edit_command; -#if PLATFORM_WINDOWS || PLATFORM_ORCA +#if PLATFORM_WINDOWS #define OS_COPY_PASTE_MOD MP_KEYMOD_CTRL #elif PLATFORM_MACOS #define OS_COPY_PASTE_MOD MP_KEYMOD_CMD +#elif PLATFORM_ORCA + #define OS_COPY_PASTE_MOD MP_KEYMOD_MAIN_MODIFIER #endif const ui_edit_command UI_EDIT_COMMANDS[] = { diff --git a/src/util/hash.c b/src/util/hash.c index e1a4ee0..d60493d 100644 --- a/src/util/hash.c +++ b/src/util/hash.c @@ -7,7 +7,7 @@ * *****************************************************************/ #include"hash.h" -#include"platform.h" +#include"platform/platform.h" #if ARCH_X64 #include diff --git a/src/win32_app.c b/src/win32_app.c index af99453..c438847 100644 --- a/src/win32_app.c +++ b/src/win32_app.c @@ -191,6 +191,7 @@ static mp_keymod_flags mp_get_mod_keys() if(GetKeyState(VK_CONTROL) & 0x8000) { mods |= MP_KEYMOD_CTRL; + mods |= MP_KEYMOD_MAIN_MODIFIER; } if(GetKeyState(VK_MENU) & 0x8000) { From e6c271c3f5bae7a2ecd5535ad5dd3aea7d8c1d44 Mon Sep 17 00:00:00 2001 From: Ilia Demianenko Date: Sat, 15 Jul 2023 00:35:02 -0700 Subject: [PATCH 3/4] minor --- src/mp_app.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mp_app.h b/src/mp_app.h index d652c9c..237b598 100644 --- a/src/mp_app.h +++ b/src/mp_app.h @@ -195,7 +195,7 @@ typedef enum { MP_KEYMOD_SHIFT = 0x02, MP_KEYMOD_CTRL = 0x04, MP_KEYMOD_CMD = 0x08, - MP_KEYMOD_MAIN_MODIFIER = 0x16 } mp_keymod_flags; + MP_KEYMOD_MAIN_MODIFIER = 0x16 /* CMD on Mac, CTRL on Win32 */ } mp_keymod_flags; typedef enum { MP_MOUSE_LEFT = 0x00, From e7982b7786583bce33cf80097269fdc6ad0f8fb0 Mon Sep 17 00:00:00 2001 From: Ilia Demianenko Date: Sat, 15 Jul 2023 00:54:57 -0700 Subject: [PATCH 4/4] Just use MP_KEYMOD_MAIN_MODIFIER instead of OS_COPY_PASTE_MOD --- src/ui.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ui.c b/src/ui.c index b8aea1c..79153b5 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2303,14 +2303,6 @@ typedef struct ui_edit_command } ui_edit_command; -#if PLATFORM_WINDOWS - #define OS_COPY_PASTE_MOD MP_KEYMOD_CTRL -#elif PLATFORM_MACOS - #define OS_COPY_PASTE_MOD MP_KEYMOD_CMD -#elif PLATFORM_ORCA - #define OS_COPY_PASTE_MOD MP_KEYMOD_MAIN_MODIFIER -#endif - const ui_edit_command UI_EDIT_COMMANDS[] = { //NOTE(martin): move one left { @@ -2403,7 +2395,7 @@ const ui_edit_command UI_EDIT_COMMANDS[] = { //NOTE(martin): select all { .key = MP_KEY_Q, - .mods = OS_COPY_PASTE_MOD, + .mods = MP_KEYMOD_MAIN_MODIFIER, .operation = UI_EDIT_SELECT_ALL, .move = UI_EDIT_MOVE_NONE }, @@ -2424,21 +2416,21 @@ const ui_edit_command UI_EDIT_COMMANDS[] = { //NOTE(martin): cut { .key = MP_KEY_X, - .mods = OS_COPY_PASTE_MOD, + .mods = MP_KEYMOD_MAIN_MODIFIER, .operation = UI_EDIT_CUT, .move = UI_EDIT_MOVE_NONE }, //NOTE(martin): copy { .key = MP_KEY_C, - .mods = OS_COPY_PASTE_MOD, + .mods = MP_KEYMOD_MAIN_MODIFIER, .operation = UI_EDIT_COPY, .move = UI_EDIT_MOVE_NONE }, //NOTE(martin): paste { .key = MP_KEY_V, - .mods = OS_COPY_PASTE_MOD, + .mods = MP_KEYMOD_MAIN_MODIFIER, .operation = UI_EDIT_PASTE, .move = UI_EDIT_MOVE_NONE }