From 52bf9471a4223eb9f7bcaa592664dc9bedde7721 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 7 May 2016 13:25:45 -0400 Subject: [PATCH] changes to customization file setup --- 4coder_custom.cpp | 33 --------------------------------- 4coder_default_bindings.cpp | 20 +++++++++++--------- 4coder_helper.h | 5 ++++- 4ed.cpp | 4 +++- buildsuper.sh | 8 +++++++- linux_4ed.cpp | 2 +- win32_4ed.cpp | 2 +- 7 files changed, 27 insertions(+), 47 deletions(-) delete mode 100644 4coder_custom.cpp diff --git a/4coder_custom.cpp b/4coder_custom.cpp deleted file mode 100644 index aa482ff0..00000000 --- a/4coder_custom.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Delete CustomCurrent to define your own customizations or -// set it to one of the preexisting options -#define Custom_Current Custom_Default - -#define Custom_Default 1 - -// The following customization schemes are power users only: -#define Custom_HandmadeHero 2 - - -// TOP - -#if Custom_Current == Custom_Default -# include "4coder_default_bindings.cpp" -#elif Custom_Current == Custom_HandmadeHero -# include "power/4coder_casey.cpp" -#endif - -extern "C" GET_BINDING_DATA(get_bindings){ - Bind_Helper context_actual = begin_bind_helper(data, size); - Bind_Helper *context = &context_actual; - -#if Custom_Current == Custom_Default - default_get_bindings(context, true); -#elif Custom_Current == Custom_HandmadeHero - casey_get_bindings(context); -#endif - - end_bind_helper(context); - return context->write_total; -} - -// BOTTOM diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 8515e9fa..04ed529f 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -235,6 +235,7 @@ CUSTOM_COMMAND_SIG(build_at_launch_location){ exec_command(app, cmdid_command_line); } +#if 0 // NOTE(allen|a4) See 4coder_styles.h for a list of available style tags. // There are style tags corresponding to every color in the theme editor. CUSTOM_COMMAND_SIG(improve_theme){ @@ -264,15 +265,16 @@ CUSTOM_COMMAND_SIG(ruin_theme){ app->set_theme_colors(app, colors, count); } +#endif -void default_get_bindings(Bind_Helper *context, int set_hooks){ +int get_bindings(void *data, int size){ + Bind_Helper context_ = begin_bind_helper(data, size); + Bind_Helper *context = &context_; + // NOTE(allen|a3.1): Hooks have no loyalties to maps. All hooks are global // and once set they always apply, regardless of what map is active. - if (set_hooks){ - set_hook(context, hook_start, my_start); - set_hook(context, hook_open_file, my_file_settings); - //set_hook(context, hook_frame, my_frame); // Example of a frame hook, but disabled by default. - } + set_hook(context, hook_start, my_start); + set_hook(context, hook_open_file, my_file_settings); set_scroll_rule(context, smooth_scroll_rule); @@ -299,9 +301,6 @@ void default_get_bindings(Bind_Helper *context, int set_hooks){ bind(context, 'M', MDFR_ALT | MDFR_CTRL, open_my_files); bind(context, 'M', MDFR_ALT, build_at_launch_location); - bind(context, '`', MDFR_ALT, improve_theme); - bind(context, '~', MDFR_ALT, ruin_theme); - end_map(context); @@ -431,6 +430,9 @@ void default_get_bindings(Bind_Helper *context, int set_hooks){ bind(context, 'T', MDFR_CTRL | MDFR_ALT, begin_html_mode); end_map(context); + + int result = end_bind_helper(context); + return(result); } // BOTTOM diff --git a/4coder_helper.h b/4coder_helper.h index db0cab60..04ccc437 100644 --- a/4coder_helper.h +++ b/4coder_helper.h @@ -172,12 +172,15 @@ set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){ write_unit(helper, unit); } -inline void +inline int end_bind_helper(Bind_Helper *helper){ + int result; if (helper->header){ helper->header->header.total_size = (int)(helper->cursor - helper->start); helper->header->header.error = helper->error; } + result = helper->write_total; + return(result); } // NOTE(allen): Useful functions and overloads on app links diff --git a/4ed.cpp b/4ed.cpp index 10bd933b..d325d58b 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -3959,7 +3959,9 @@ App_Step_Sig(app_step){ for (dll_items(panel, used_panels)){ view = panel->view; if (view->current_scroll){ - gui_get_scroll_vars(&view->gui_target, view->showing_ui, view->current_scroll); + GUI_Scroll_Vars vars = {0}; + gui_get_scroll_vars(&view->gui_target, view->showing_ui, &vars); + view->current_scroll->region = vars.region; } } } diff --git a/buildsuper.sh b/buildsuper.sh index 85f5bba5..23fc510b 100755 --- a/buildsuper.sh +++ b/buildsuper.sh @@ -1,5 +1,11 @@ #!/bin/bash #!/bin/sh -g++ -Wno-write-strings -std=gnu++0x 4coder_custom.cpp -shared -o 4coder_custom.so -fPIC +SOURCE="$1" +if [ -z "$SOURCE" ] +then + SOURCE="4coder_default_bindings.cpp" +fi + +g++ -Wno-write-strings -std=gnu++0x $SOURCE -shared -o 4coder_custom.so -fPIC diff --git a/linux_4ed.cpp b/linux_4ed.cpp index dfffb99e..5149a798 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -23,7 +23,7 @@ #include "4ed_mem.cpp" #include "4ed_math.cpp" -#include "4coder_custom.cpp" +#include "4coder_default_bindings.cpp" #undef exec_command #undef exec_command_keep_stack diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 36250771..d1e0f7c2 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -26,7 +26,7 @@ #include -#include "4coder_custom.cpp" +#include "4coder_default_bindings.cpp" #undef exec_command #undef exec_command_keep_stack