diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index d822236d..149d1895 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -127,6 +127,14 @@ OPEN_FILE_HOOK_SIG(default_file_settings){ parse_context_id = parse_context_language_cpp; } + // TODO(NAME): Real Objective-C highlighting + if (match(ext, "m")){ + if (parse_context_language_cpp == 0){ + init_language_cpp(app); + } + parse_context_id = parse_context_language_cpp; + } + break; } } diff --git a/meta/build.cpp b/meta/build.cpp index 10d33a18..4796f99d 100644 --- a/meta/build.cpp +++ b/meta/build.cpp @@ -422,7 +422,7 @@ buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){ #elif defined(IS_MAC) -# define PLAT_LAYER "platform_mac/mac_4ed.m" +# define PLAT_LAYER "platform_mac/mac_4ed.m platform_mac/mac_4ed.cpp" # if defined(IS_GCC) # define PLAT_INC "-I../code/platform_all -I../code/platform_unix" # else diff --git a/osx_objective_c_to_cpp_links.h b/osx_objective_c_to_cpp_links.h new file mode 100644 index 00000000..d16f441f --- /dev/null +++ b/osx_objective_c_to_cpp_links.h @@ -0,0 +1,71 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 06.29.2017 + * + * Types and functions for communication between C++ and Objective-C layers. + * + */ + +// TOP + +#if !defined(OSX_OBJECTIVE_C_TO_CPP_LINKS_H) +#define OSX_OBJECTIVE_C_TO_CPP_LINKS_H + +typedef enum OSX_Mouse_Event_Type{ + MouseType_Move, + MouseType_Press, + MouseType_Release, +} OSX_Mouse_Event_Type; + +typedef struct OSX_Keyboard_Modifiers{ + b32 shift; + b32 command; + b32 control; + b32 option; +} OSX_Keyboard_Modifiers; + +typedef struct OSX_Vars{ + i32 width, height; + b32 running; + u32 key_count; + u32 keys[8]; + + u32 prev_clipboard_change_count; + b32 has_clipboard_item; + void *clipboard_data; + umem clipboard_size, clipboard_max; + b32 just_posted_to_clipboard; +} OSX_Vars; + +// In C++ layer. +extern OSX_Vars osx; + +void +osx_post_to_clipboard(char *str); + +internal void* +osx_allocate(umem size); + +internal void +osx_resize(int width, int height); + +internal void +osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags); + +internal void +osx_mouse(i32 mx, i32 my, u32 type); + +internal void +osx_mouse_wheel(float dx, float dy); + +internal void +osx_step(); + +internal void +osx_init(); + +#endif + +// BOTTOM + diff --git a/platform_mac/mac_4ed.c b/platform_mac/mac_4ed.c deleted file mode 100644 index b14b835a..00000000 --- a/platform_mac/mac_4ed.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 06.28.2017 - * - * Mac C layer for 4coder - * - */ - -// TOP - -#define WINDOW_TITLE "4coder" - -#include "4tech_defines.h" -#include "4coder_API/version.h" - -typedef enum OSX_Mouse_Event_Type{ - MouseType_Move, - MouseType_Press, - MouseType_Release, -} OSX_Mouse_Event_Type; - -typedef struct OSX_Keyboard_Modifiers{ - b32 shift; - b32 command; - b32 control; - b32 option; -} OSX_Keyboard_Modifiers; - -typedef struct OSX_Vars{ - i32 width, height; - b32 running; - u32 key_count; - u32 keys[8]; - - u32 prev_clipboard_change_count; - b32 has_clipboard_item; - void *clipboard_data; - umem clipboard_size, clipboard_max; - b32 just_posted_to_clipboard; -} OSX_Vars; - -internal OSX_Vars osx; - -internal void -osx_post_to_clipboard(char *str); - -// TODO(allen): Implement a real allocate -#include -internal void* -osx_allocate(umem size){ - void *result = malloc(size); - return(result); -} - -internal void -osx_resize(int width, int height){ - osx.width = width; - osx.height = height; - // TODO -} - -internal void -osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){ - // TODO -} - -internal void -osx_mouse(i32 mx, i32 my, u32 type){ - // TODO -} - -internal void -osx_mouse_wheel(float dx, float dy){ - // TODO -} - -internal void -osx_step(){ - // TODO -} - -internal void -osx_init(){ - // TODO -} - -// BOTTOM - diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp new file mode 100644 index 00000000..f6024212 --- /dev/null +++ b/platform_mac/mac_4ed.cpp @@ -0,0 +1,62 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 06.28.2017 + * + * Mac C++ layer for 4coder + * + */ + +// TOP + +#include "4tech_defines.h" +#include "4coder_API/version.h" + +#define WINDOW_TITLE "4coder" VERSION + +#include "osx_objective_c_to_cpp_links.h" + +OSX_Vars osx; + +// TODO(allen): Implement a real allocate +#include +internal void* +osx_allocate(umem size){ + void *result = malloc(size); + return(result); +} + +internal void +osx_resize(int width, int height){ + osx.width = width; + osx.height = height; + // TODO +} + +internal void +osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){ + // TODO +} + +internal void +osx_mouse(i32 mx, i32 my, u32 type){ + // TODO +} + +internal void +osx_mouse_wheel(float dx, float dy){ + // TODO +} + +internal void +osx_step(){ + // TODO +} + +internal void +osx_init(){ + // TODO +} + +// BOTTOM + diff --git a/platform_mac/mac_4ed.m b/platform_mac/mac_4ed.m index c909d7f1..dbad608f 100644 --- a/platform_mac/mac_4ed.m +++ b/platform_mac/mac_4ed.m @@ -9,7 +9,8 @@ // TOP -#include "mac_4ed.c" +#include "4tech_defines.h" +#include "osx_objective_c_to_cpp_links.h" #undef internal #undef global @@ -22,7 +23,7 @@ static void osx_post_to_clipboard(char *str){ - NSPasteboard *board = [NSPasteboard generalPasteboard]; + NSPasteboard *board = [NSPasteboard generalPasteboard]; NSString *utf8_type = @"public.utf8-plain-text"; NSArray *typesArray = [NSArray arrayWithObjects: utf8_type, nil]; [board declareTypes:typesArray owner:nil]; diff --git a/project.4coder b/project.4coder index 7484655a..b9a555f4 100644 --- a/project.4coder +++ b/project.4coder @@ -1,4 +1,4 @@ -extensions=".c.cpp.h.hpp.bat.sh.4coder"; +extensions=".c.cpp.h.m.bat.sh.4coder"; open_recursively=true; fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*", true , true }; diff --git a/win32_4ed.cpp b/win32_4ed.cpp index c4f5711d..2a90fb5d 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -33,11 +33,13 @@ #define FPS 60 #define frame_useconds (1000000 / FPS) -#include -#include #include "4tech_defines.h" #include "4coder_API/version.h" +#define WINDOW_NAME L"4coder: " L_VERSION + +#include +#include #include "4coder_lib/4coder_utf8.h" #if defined(FRED_SUPER) @@ -2199,8 +2201,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS window_style |= WS_MAXIMIZE; } -#define WINDOW_NAME L"4coder-window: " L_VERSION - LOG(system, "Creating window... "); win32vars.window_handle = CreateWindow(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0);