From 258257eb454e1a523c4f8c6944967f98c0a0f9f4 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 23 Feb 2019 23:22:16 -0800 Subject: [PATCH] 4coder Jamm 1 --- 4coder_API/4coder_custom.h | 2 + 4coder_API/4coder_keycodes.h | 52 +- 4coder_API/4coder_types.h | 89 ++- 4coder_api_transition_30_31.cpp | 28 +- 4coder_base_types.h | 247 ++++++++ 4coder_casey.cpp => 4coder_casey_classic.cpp | 0 4coder_default_hooks.cpp | 67 ++- 4coder_default_include.cpp | 1 + 4coder_experiments.cpp | 2 +- 4coder_function_list.cpp | 8 +- 4coder_generated/app_functions.h | 121 +++- 4coder_generated/command_metadata.h | 22 +- 4coder_generated/remapping.h | 44 +- 4coder_helper.cpp | 46 ++ 4coder_helper.h | 10 + 4coder_insertion.cpp | 101 ++++ 4coder_search.cpp | 21 +- 4ed.cpp | 4 +- 4ed_api_implementation.cpp | 558 ++++++++++++++++--- 4ed_layout.cpp | 109 ++-- 4ed_layout.h | 15 +- 4ed_math.h | 129 +---- 4ed_render_format.cpp | 3 + 4ed_render_target.cpp | 3 + 4ed_render_target.h | 5 +- 4ed_system.h | 12 + 4ed_view.cpp | 2 + meta/4ed_build.cpp | 4 +- opengl/4ed_opengl_render.cpp | 5 +- platform_all/4ed_link_system_functions.cpp | 3 + platform_win32/win32_4ed.cpp | 5 +- platform_win32/win32_4ed_functions.cpp | 155 ++++++ 32 files changed, 1468 insertions(+), 405 deletions(-) create mode 100644 4coder_base_types.h rename 4coder_casey.cpp => 4coder_casey_classic.cpp (100%) create mode 100644 4coder_insertion.cpp diff --git a/4coder_API/4coder_custom.h b/4coder_API/4coder_custom.h index 8faf3ae1..d50760e8 100644 --- a/4coder_API/4coder_custom.h +++ b/4coder_API/4coder_custom.h @@ -8,7 +8,9 @@ #define FCODER_CUSTOM_H #include +#include +#include "4coder_base_types.h" #include "4coder_lib/4coder_arena.h" #include "4coder_lib/4coder_heap.h" #include "4coder_lib/4coder_string.h" diff --git a/4coder_API/4coder_keycodes.h b/4coder_API/4coder_keycodes.h index 9b15fc89..9beeecd2 100644 --- a/4coder_API/4coder_keycodes.h +++ b/4coder_API/4coder_keycodes.h @@ -20,31 +20,32 @@ enum{ key_caps = 55296 + 17, key_num_lock = 55296 + 18, key_scroll_lock = 55296 + 19, - key_mouse_left = 55296 + 20, - key_mouse_right = 55296 + 21, - key_mouse_left_release = 55296 + 22, - key_mouse_right_release = 55296 + 23, - key_mouse_wheel = 55296 + 24, - key_mouse_move = 55296 + 25, - key_animate = 55296 + 26, - key_click_activate_view = 55296 + 27, - key_click_deactivate_view = 55296 + 28, - key_f1 = 55296 + 29, - key_f2 = 55296 + 30, - key_f3 = 55296 + 31, - key_f4 = 55296 + 32, - key_f5 = 55296 + 33, - key_f6 = 55296 + 34, - key_f7 = 55296 + 35, - key_f8 = 55296 + 36, - key_f9 = 55296 + 37, - key_f10 = 55296 + 38, - key_f11 = 55296 + 39, - key_f12 = 55296 + 40, - key_f13 = 55296 + 41, - key_f14 = 55296 + 42, - key_f15 = 55296 + 43, - key_f16 = 55296 + 44, + key_menu = 55296 + 20, + key_mouse_left = 55296 + 21, + key_mouse_right = 55296 + 22, + key_mouse_left_release = 55296 + 23, + key_mouse_right_release = 55296 + 24, + key_mouse_wheel = 55296 + 25, + key_mouse_move = 55296 + 26, + key_animate = 55296 + 27, + key_click_activate_view = 55296 + 28, + key_click_deactivate_view = 55296 + 29, + key_f1 = 55296 + 30, + key_f2 = 55296 + 31, + key_f3 = 55296 + 32, + key_f4 = 55296 + 33, + key_f5 = 55296 + 34, + key_f6 = 55296 + 35, + key_f7 = 55296 + 36, + key_f8 = 55296 + 37, + key_f9 = 55296 + 38, + key_f10 = 55296 + 39, + key_f11 = 55296 + 40, + key_f12 = 55296 + 41, + key_f13 = 55296 + 42, + key_f14 = 55296 + 43, + key_f15 = 55296 + 44, + key_f16 = 55296 + 45, }; static char* global_key_name(uint32_t key_code, int32_t *size){ @@ -70,6 +71,7 @@ global_key_name(uint32_t key_code, int32_t *size){ case key_caps: result = "key_caps"; *size = sizeof("key_caps")-1; break; case key_num_lock: result = "key_num_lock"; *size = sizeof("key_num_lock")-1; break; case key_scroll_lock: result = "key_scroll_lock"; *size = sizeof("key_scroll_lock")-1; break; + case key_menu: result = "key_menu"; *size = sizeof("key_menu")-1; break; case key_mouse_left: result = "key_mouse_left"; *size = sizeof("key_mouse_left")-1; break; case key_mouse_right: result = "key_mouse_right"; *size = sizeof("key_mouse_right")-1; break; case key_mouse_left_release: result = "key_mouse_left_release"; *size = sizeof("key_mouse_left_release")-1; break; diff --git a/4coder_API/4coder_types.h b/4coder_API/4coder_types.h index 75fb514a..eb0a69c0 100644 --- a/4coder_API/4coder_types.h +++ b/4coder_API/4coder_types.h @@ -28,6 +28,8 @@ TYPEDEF int32_t Buffer_ID; /* DOC(View_ID is used to name a 4coder view. Each view has a unique id in the interval [1,16].) */ TYPEDEF int32_t View_ID; +TYPEDEF int32_t Panel_ID; + /* DOC(A Key_Modifier_Index acts as an index for specifying modifiers in arrays.) */ ENUM(int32_t, Key_Modifier_Index){ MDFR_SHIFT_INDEX, @@ -323,9 +325,21 @@ ENUM(int32_t, View_Split_Position){ ViewSplit_Right, }; -ENUM(int32_t, View_Split_Kind){ - ViewSplitKind_Ratio, - ViewSplitKind_FixedPixels, +ENUM(int32_t, Panel_Split_Kind){ + PanelSplitKind_Ratio_Min = 0, + PanelSplitKind_Ratio_Max = 1, + PanelSplitKind_FixedPixels_Min = 2, + PanelSplitKind_FixedPixels_Max = 3, +}; + +ENUM(int32_t, Panel_Split_Orientation){ + PanelSplit_LeftAndRight, + PanelSplit_TopAndBottom, +}; + +ENUM(int32_t, Panel_Child){ + PanelChild_Min, + PanelChild_Max, }; /* DOC(Key_Code is the alias for key codes including raw codes and codes translated to textual input that takes modifiers into account.) */ @@ -484,7 +498,7 @@ ENUM(int32_t, Buffer_Seek_Type){ /* DOC(This value indicates absolute byte index positioning where positions are measured as the number of bytes from the start of the file.) */ buffer_seek_pos, - /* DOC(This value indicates apparent character index positioning + /* DOC(This value indicates apparent character index positioning where positions are measured as the number of apparent characters from the starts of the file.) */ buffer_seek_character_pos, /* DOC(This value indicates xy positioning with wrapped lines where the x and y values are in pixels.) */ @@ -622,27 +636,6 @@ STRUCT Marker{ bool32 lean_right; }; -/* -DOC(A four corner axis aligned rectangle, with integer coordinates.) -*/ -STRUCT i32_Rect{ - int32_t x0; - int32_t y0; - int32_t x1; - int32_t y1; -}; - -/* -DOC(A four corner axis aligned rectangle, with floating point coordinates.) -*/ -STRUCT f32_Rect{ - float x0; - float y0; - float x1; - float y1; -}; - -GLOBAL_VAR f32_Rect null_f32_rect = {}; /* DOC(View_Summary acts as a handle to a view and describes the state of the view.) DOC_SEE(Access_Flag) @@ -673,6 +666,8 @@ STRUCT View_Summary{ /* DOC(This describes the screen position in which this view is displayed.) */ i32_Rect view_region; + /* DOC(TODO) */ + i32_Rect render_region; /* DOC(This describes the screen position in which this view's buffer is displayed. This is different from view_region, because it does not include any fixed height GUI at the top of the view.) */ i32_Rect file_region; /* DOC(This describes the scrolling position inside the view.) */ @@ -810,8 +805,8 @@ ENUM(uint32_t, Marker_Visual_Priority_Level){ /* DOC(Flags that control how font glyphs are modified before drawing.) */ ENUM(uint32_t, Glyph_Flag){ - GlyphFlag_None = 0x0, - GlyphFlag_Rotate90 = 0x1, + GlyphFlag_None = 0x0, + GlyphFlag_Rotate90 = 0x1, }; /* DOC(Query_Bar is a struct used to store information in the user's control that will be displayed as a drop down bar durring an interactive command.) */ @@ -911,7 +906,7 @@ STRUCT UI_Control{ TYPEDEF_FUNC void UI_Quit_Function_Type(struct Application_Links *app, View_Summary view); #define UI_QUIT_FUNCTION(name) void name(struct Application_Links *app, View_Summary view) -/* +/* DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme.) DOC_SEE(Style_Tag) DOC_SEE(int_color) @@ -1110,7 +1105,7 @@ ENUM(int32_t, Hook_ID){ /* DOC(TODO) */ hook_exit, /* DOC(TODO) */ - hook_view_size_change, + hook_buffer_viewer_update, // never below this hook_type_count }; @@ -1230,5 +1225,41 @@ STRUCT Binding_Unit{ typedef int32_t _Get_Version_Function(int32_t maj, int32_t min, int32_t patch); #define _GET_VERSION_SIG(n) int32_t n(int32_t maj, int32_t min, int32_t patch) +STRUCT color_picker +{ + String title; + int_color *dest; + bool32 *finished; +}; + +enum Found_String_Flag +{ + FoundString_Sensitive = 0x1, + FoundString_Insensitive = 0x2, + FoundString_CleanEdges = 0x4, + + FoundString_Straddled = 0x10, +}; + +STRUCT Found_String +{ + Found_String *next; + Buffer_ID buffer_id; + + uint32_t flags; + int32_t string_id; + + int32_t start; + int32_t end; +}; + +// TODO(casey): If this sticks around, there should be a way to export add/remove/merge as inlines that are shared +STRUCT Found_String_List +{ + Found_String *first; + Found_String *last; + int32_t count; +}; + #endif diff --git a/4coder_api_transition_30_31.cpp b/4coder_api_transition_30_31.cpp index 8a31ab27..0345f157 100644 --- a/4coder_api_transition_30_31.cpp +++ b/4coder_api_transition_30_31.cpp @@ -309,9 +309,18 @@ static View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){ View_Summary view = {}; if (view_location != 0 && view_location->exists){ - View_ID id = 0; - if (open_view(app, view_location->view_id, position, &id)){ - get_view_summary(app, id, AccessAll, &view); + Panel_ID panel_id = 0; + if (view_get_panel(app, view_location->view_id, &panel_id)){ + bool32 vertical = (position == ViewSplit_Left || position == ViewSplit_Right); + if (panel_split(app, panel_id, vertical?PanelSplit_LeftAndRight:PanelSplit_TopAndBottom)){ + Panel_ID left_panel_id = 0; + if (panel_get_child(app, panel_id, PanelChild_Min, &left_panel_id)){ + View_ID new_view_id = 0; + if (panel_get_view(app, left_panel_id, &new_view_id)){ + get_view_summary(app, new_view_id, AccessAll, view_location); + } + } + } } } return(view); @@ -362,12 +371,21 @@ view_get_managed_scope(Application_Links *app, View_ID view_id){ return(scope); } +typedef int32_t View_Split_Kind; +enum{ + ViewSplitKind_Ratio, + ViewSplitKind_FixedPixels, +}; + static bool32 view_set_split(Application_Links *app, View_Summary *view, View_Split_Kind kind, float t){ bool32 result = false; if (view != 0 && view->exists){ - result = view_set_split(app, view->view_id, kind, t); - get_view_summary(app, view->view_id, AccessAll, view); + Panel_ID panel_id = 0; + if (view_get_panel(app, view->view_id, &panel_id)){ + result = panel_set_split(app, panel_id, kind, t); + get_view_summary(app, view->view_id, AccessAll, view); + } } return(result); } diff --git a/4coder_base_types.h b/4coder_base_types.h new file mode 100644 index 00000000..62ba1ac4 --- /dev/null +++ b/4coder_base_types.h @@ -0,0 +1,247 @@ +/* + * 4coder base types + */ + +// TOP + +#if !defined(FCODER_BASE_TYPES) +#define FCODER_BASE_TYPES + +#include "4coder_os_comp_cracking.h" + +#if defined(IS_CL) +#if (_MSC_VER == 1500) +#define JUST_GUESS_INTS +#endif +#endif + +#if defined(JUST_GUESS_INTS) +typedef signed char i8; +typedef signed short i16; +typedef signed int i32; +typedef signed long long i64; + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +#else +#include + +typedef int8_t i8; +typedef int16_t i16; +typedef int32_t i32; +typedef int64_t i64; + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +#endif + +typedef i8 b8; +typedef i32 b32; + +#if defined(FTECH_32_BIT) +typedef u32 umem; +typedef i32 imem; +#else +typedef u64 umem; +typedef i64 imem; +#endif + +typedef float f32; +typedef double f64; + +#define Swap(t,a,b) do { t x = a; a = b; b = x; } while(0) + +#define Max(a,b) (((a)>(b))?(a):(b)) +#define Min(a,b) (((a)<(b))?(a):(b)) + +//////////////////////////////// + +struct Vec2_f32{ + union{ + struct{ + f32 x, y; + }; + struct{ + f32 v[2]; + }; + }; +}; + +struct Vec3_f32{ + union{ + struct{ + f32 x, y, z; + }; + struct{ + f32 r, g, b; + }; + struct{ + Vec2_f32 xy; + f32 _z; + }; + struct{ + f32 _x; + Vec2_f32 yz; + }; + struct{ + f32 v[3]; + }; + }; +}; + +struct Vec4_f32{ + union{ + struct{ + f32 r, g, b, a; + }; + struct{ + f32 h, s, l, __a; + }; + struct{ + f32 x, y, z, w; + }; + struct{ + Vec3_f32 xy; + Vec3_f32 zw; + }; + struct{ + Vec3_f32 _x; + Vec3_f32 yz; + Vec3_f32 _w; + }; + struct{ + Vec3_f32 rgb; + f32 __a; + }; + struct{ + Vec3_f32 xyz; + f32 __w; + }; + struct{ + f32 __x; + Vec3_f32 yzw; + }; + struct{ + f32 v[4]; + }; + }; +}; + +struct Vec2_i32{ + union{ + struct{ + i32 x, y; + }; + struct{ + i32 v[2]; + }; + }; +}; + +struct Vec3_i32{ + union{ + struct{ + i32 x, y, z; + }; + struct{ + i32 r, g, b; + }; + struct{ + Vec2_i32 xy; + i32 _z; + }; + struct{ + i32 _x; + Vec2_i32 yz; + }; + struct{ + i32 v[3]; + }; + }; +}; + +struct Vec4_i32{ + union{ + struct{ + i32 r, g, b, a; + }; + struct{ + i32 h, s, l, __a; + }; + struct{ + i32 x, y, z, w; + }; + struct{ + Vec3_i32 xy; + Vec3_i32 zw; + }; + struct{ + Vec3_i32 _x; + Vec3_i32 yz; + Vec3_i32 _w; + }; + struct{ + Vec3_i32 rgb; + i32 __a; + }; + struct{ + Vec3_i32 xyz; + i32 __w; + }; + struct{ + i32 __x; + Vec3_i32 yzw; + }; + struct{ + i32 v[4]; + }; + }; +}; + +typedef Vec2_f32 Vec2; +typedef Vec3_f32 Vec3; +typedef Vec4_f32 Vec4; + +//////////////////////////////// + +struct Rect_f32{ + union{ + struct{ + f32 x0; + f32 y0; + f32 x1; + f32 y1; + }; + struct{ + Vec2_f32 p0; + Vec2_f32 p1; + }; + }; +}; + +struct Rect_i32{ + union{ + struct{ + i32 x0; + i32 y0; + i32 x1; + i32 y1; + }; + struct{ + Vec2_i32 p0; + Vec2_i32 p1; + }; + }; +}; + +typedef Rect_f32 f32_Rect; +typedef Rect_i32 i32_Rect; + +#endif + +// BOTTOM + diff --git a/4coder_casey.cpp b/4coder_casey_classic.cpp similarity index 100% rename from 4coder_casey.cpp rename to 4coder_casey_classic.cpp diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 2ffa3d45..305e82d9 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -24,8 +24,46 @@ START_HOOK_SIG(default_start){ named_map_count = ArrayCount(named_maps_values); default_4coder_initialize(app); + default_4coder_side_by_side_panels(app, files, file_count); +#if 0 + + default_4coder_one_panel(app, files, file_count); + + View_ID left_view = 0; + + Panel_ID left = 0; + Panel_ID right = 0; + Panel_ID bottom = 0; + Panel_ID header = 0; + + get_active_view(app, AccessAll, &left_view); + + view_get_panel(app, left_view, &left); + + Panel_ID h_split_main = 0; + Panel_ID h_split_minor = 0; + + panel_create_split(app, left , ViewSplit_Bottom, &bottom, &h_split_main); + panel_create_split(app, bottom, ViewSplit_Top , &header, &h_split_minor); + panel_create_split(app, left , ViewSplit_Right , &right, 0); + + i32_Rect header_margin = {}; + i32_Rect bottom_margin = {}; + panel_get_margin(app, header, &header_margin); + panel_get_margin(app, header, &bottom_margin); + + int32_t header_vertical_pixels = header_margin.y0 + header_margin.y1; + int32_t margin_vertical_pixels = header_vertical_pixels + bottom_margin.y0 + bottom_margin.y1; + + View_Summary view = {}; + get_view_summary(app, left_view, AccessAll, &view); + float line = view.line_height; + panel_set_split(app, h_split_main , PanelSplitKind_FixedPixels_BR, line*6.f + margin_vertical_pixels); + panel_set_split(app, h_split_minor, PanelSplitKind_FixedPixels_TL, line + header_vertical_pixels); +#endif + if (global_config.automatically_load_project){ load_project(app); } @@ -444,7 +482,33 @@ HOOK_SIG(default_exit){ return(1); } +// TODO(allen): call this hook when a view's buffer is set. +// TODO(allen): how to deal with multiple sizes on a single view +// TODO(allen): expected character advance. HOOK_SIG(default_view_adjust){ + for (View_Summary view = get_view_first(app, AccessAll); + view.exists; + get_view_next(app, &view, AccessAll)){ + Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll); + int32_t view_width = view.render_region.x1 - view.render_region.x0; + Face_ID face_id = get_default_font_for_view(app, view.view_id); + float em = get_string_advance(app, face_id, make_lit_string("m")); + + float wrap_width = view_width - 2.0f*em; + float min_width = 40.0f*em; + if (wrap_width < min_width){ + wrap_width = min_width; + } + + float min_base_width = 20.0f*em; + buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, (int32_t)(wrap_width)); + buffer_set_setting(app, &buffer, BufferSetting_MinimumBaseWrapPosition, (int32_t)(min_base_width)); + } + return(0); +} + +#if 0 +{ int32_t count = 0; int32_t new_wrap_width = 0; for (View_Summary view = get_view_first(app, AccessAll); @@ -467,6 +531,7 @@ HOOK_SIG(default_view_adjust){ // no meaning for return return(0); } +#endif BUFFER_NAME_RESOLVER_SIG(default_buffer_name_resolution){ if (conflict_count > 1){ @@ -884,7 +949,7 @@ SCROLL_RULE_SIG(smooth_scroll_rule){ static void set_all_default_hooks(Bind_Helper *context){ set_hook(context, hook_exit, default_exit); - set_hook(context, hook_view_size_change, default_view_adjust); + set_hook(context, hook_buffer_viewer_update, default_view_adjust); set_start_hook(context, default_start); set_open_file_hook(context, default_file_settings); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 00ec4754..d2795468 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -50,6 +50,7 @@ #include "4coder_font_helper.cpp" #include "4coder_config.cpp" #include "4coder_default_framework.cpp" +#include "4coder_insertion.cpp" #include "4coder_mirror.cpp" #include "4coder_seek.cpp" #include "4coder_base_commands.cpp" diff --git a/4coder_experiments.cpp b/4coder_experiments.cpp index 0fbea6d5..37f3840b 100644 --- a/4coder_experiments.cpp +++ b/4coder_experiments.cpp @@ -806,7 +806,7 @@ get_bindings(void *data, int32_t size){ Bind_Helper context_ = begin_bind_helper(data, size); Bind_Helper *context = &context_; - set_hook(context, hook_view_size_change, default_view_adjust); + set_hook(context, hook_buffer_viewer_update, default_view_adjust); set_start_hook(context, default_start); set_open_file_hook(context, default_file_settings); diff --git a/4coder_function_list.cpp b/4coder_function_list.cpp index fc6b131b..1a867180 100644 --- a/4coder_function_list.cpp +++ b/4coder_function_list.cpp @@ -245,10 +245,10 @@ print_positions_buffered(Application_Links *app, Buffer_Summary *buffer, Functio static void list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *optional_target_buffer){ - String search_name = make_lit_string("*decls*"); - Buffer_Summary decls_buffer = get_buffer_by_name(app, search_name.str, search_name.size, AccessAll); + String decls_name = make_lit_string("*decls*"); + Buffer_Summary decls_buffer = get_buffer_by_name(app, decls_name.str, decls_name.size, AccessAll); if (!decls_buffer.exists){ - decls_buffer = create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew); + decls_buffer = create_buffer(app, decls_name.str, decls_name.size, BufferCreate_AlwaysNew); buffer_set_setting(app, &decls_buffer, BufferSetting_Unimportant, true); buffer_set_setting(app, &decls_buffer, BufferSetting_ReadOnly, true); buffer_set_setting(app, &decls_buffer, BufferSetting_WrapLine, false); @@ -300,7 +300,7 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *opti View_Summary view = get_active_view(app, AccessAll); view_set_buffer(app, &view, decls_buffer.buffer_id, 0); - lock_jump_buffer(search_name.str, search_name.size); + lock_jump_buffer(decls_name.str, decls_name.size); end_temp_memory(temp); diff --git a/4coder_generated/app_functions.h b/4coder_generated/app_functions.h index a7f9e25e..13fa1f23 100644 --- a/4coder_generated/app_functions.h +++ b/4coder_generated/app_functions.h @@ -34,13 +34,23 @@ struct Application_Links; #define GET_VIEW_NEXT_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out) #define GET_VIEW_SUMMARY_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out) #define GET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, Access_Flag access, View_ID *view_id_out) -#define OPEN_VIEW_SIG(n) bool32 n(Application_Links *app, View_ID location, View_Split_Position position, View_ID *view_id_out) +#define GET_ACTIVE_PANEL_SIG(n) bool32 n(Application_Links *app, Panel_ID *panel_id_out) +#define VIEW_GET_PANEL_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out) +#define PANEL_GET_VIEW_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out) +#define PANEL_IS_SPLIT_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id) +#define PANEL_IS_LEAF_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id) +#define PANEL_SPLIT_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation) +#define PANEL_SET_SPLIT_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t) +#define PANEL_SWAP_CHILDREN_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t) +#define PANEL_GET_PARENT_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out) +#define PANEL_GET_CHILD_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out) +#define PANEL_GET_MAX_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out) +#define PANEL_GET_MARGIN_SIG(n) bool32 n(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out) #define VIEW_CLOSE_SIG(n) bool32 n(Application_Links *app, View_ID view_id) #define VIEW_SET_ACTIVE_SIG(n) bool32 n(Application_Links *app, View_ID view_id) #define VIEW_GET_SETTING_SIG(n) bool32 n(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t *value_out) #define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t value) #define VIEW_GET_MANAGED_SCOPE_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Managed_Scope *scope) -#define VIEW_SET_SPLIT_SIG(n) bool32 n(Application_Links *app, View_ID view_id, View_Split_Kind kind, float t) #define VIEW_GET_ENCLOSURE_RECT_SIG(n) bool32 n(Application_Links *app, View_ID view_id, i32_Rect *rect_out) #define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Buffer_Seek seek, Full_Cursor *cursor_out) #define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_ID view_id, Buffer_Seek seek, bool32 set_preferred_x) @@ -136,6 +146,9 @@ struct Application_Links; #define DRAW_RECTANGLE_SIG(n) void n(Application_Links *app, f32_Rect rect, int_color color) #define DRAW_RECTANGLE_OUTLINE_SIG(n) void n(Application_Links *app, f32_Rect rect, int_color color) #define GET_DEFAULT_FONT_FOR_VIEW_SIG(n) Face_ID n(Application_Links *app, View_ID view_id) +#define OPEN_COLOR_PICKER_SIG(n) void n(Application_Links *app, color_picker *picker) +#define ANIMATE_SIG(n) void n(Application_Links *app) +#define FIND_ALL_IN_RANGE_INSENSITIVE_SIG(n) Found_String_List n(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t end, String key, Partition *memory) typedef GLOBAL_SET_SETTING_SIG(Global_Set_Setting_Function); typedef GLOBAL_SET_MAPPING_SIG(Global_Set_Mapping_Function); typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function); @@ -171,13 +184,23 @@ typedef GET_VIEW_FIRST_SIG(Get_View_First_Function); typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function); typedef GET_VIEW_SUMMARY_SIG(Get_View_Summary_Function); typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function); -typedef OPEN_VIEW_SIG(Open_View_Function); +typedef GET_ACTIVE_PANEL_SIG(Get_Active_Panel_Function); +typedef VIEW_GET_PANEL_SIG(View_Get_Panel_Function); +typedef PANEL_GET_VIEW_SIG(Panel_Get_View_Function); +typedef PANEL_IS_SPLIT_SIG(Panel_Is_Split_Function); +typedef PANEL_IS_LEAF_SIG(Panel_Is_Leaf_Function); +typedef PANEL_SPLIT_SIG(Panel_Split_Function); +typedef PANEL_SET_SPLIT_SIG(Panel_Set_Split_Function); +typedef PANEL_SWAP_CHILDREN_SIG(Panel_Swap_Children_Function); +typedef PANEL_GET_PARENT_SIG(Panel_Get_Parent_Function); +typedef PANEL_GET_CHILD_SIG(Panel_Get_Child_Function); +typedef PANEL_GET_MAX_SIG(Panel_Get_Max_Function); +typedef PANEL_GET_MARGIN_SIG(Panel_Get_Margin_Function); typedef VIEW_CLOSE_SIG(View_Close_Function); typedef VIEW_SET_ACTIVE_SIG(View_Set_Active_Function); typedef VIEW_GET_SETTING_SIG(View_Get_Setting_Function); typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function); typedef VIEW_GET_MANAGED_SCOPE_SIG(View_Get_Managed_Scope_Function); -typedef VIEW_SET_SPLIT_SIG(View_Set_Split_Function); typedef VIEW_GET_ENCLOSURE_RECT_SIG(View_Get_Enclosure_Rect_Function); typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function); typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function); @@ -273,6 +296,9 @@ typedef GET_STRING_ADVANCE_SIG(Get_String_Advance_Function); typedef DRAW_RECTANGLE_SIG(Draw_Rectangle_Function); typedef DRAW_RECTANGLE_OUTLINE_SIG(Draw_Rectangle_Outline_Function); typedef GET_DEFAULT_FONT_FOR_VIEW_SIG(Get_Default_Font_For_View_Function); +typedef OPEN_COLOR_PICKER_SIG(Open_Color_Picker_Function); +typedef ANIMATE_SIG(Animate_Function); +typedef FIND_ALL_IN_RANGE_INSENSITIVE_SIG(Find_All_In_Range_Insensitive_Function); struct Application_Links{ #if defined(ALLOW_DEP_4CODER) Global_Set_Setting_Function *global_set_setting; @@ -310,13 +336,23 @@ Get_View_First_Function *get_view_first; Get_View_Next_Function *get_view_next; Get_View_Summary_Function *get_view_summary; Get_Active_View_Function *get_active_view; -Open_View_Function *open_view; +Get_Active_Panel_Function *get_active_panel; +View_Get_Panel_Function *view_get_panel; +Panel_Get_View_Function *panel_get_view; +Panel_Is_Split_Function *panel_is_split; +Panel_Is_Leaf_Function *panel_is_leaf; +Panel_Split_Function *panel_split; +Panel_Set_Split_Function *panel_set_split; +Panel_Swap_Children_Function *panel_swap_children; +Panel_Get_Parent_Function *panel_get_parent; +Panel_Get_Child_Function *panel_get_child; +Panel_Get_Max_Function *panel_get_max; +Panel_Get_Margin_Function *panel_get_margin; View_Close_Function *view_close; View_Set_Active_Function *view_set_active; View_Get_Setting_Function *view_get_setting; View_Set_Setting_Function *view_set_setting; View_Get_Managed_Scope_Function *view_get_managed_scope; -View_Set_Split_Function *view_set_split; View_Get_Enclosure_Rect_Function *view_get_enclosure_rect; View_Compute_Cursor_Function *view_compute_cursor; View_Set_Cursor_Function *view_set_cursor; @@ -412,6 +448,9 @@ Get_String_Advance_Function *get_string_advance; Draw_Rectangle_Function *draw_rectangle; Draw_Rectangle_Outline_Function *draw_rectangle_outline; Get_Default_Font_For_View_Function *get_default_font_for_view; +Open_Color_Picker_Function *open_color_picker; +Animate_Function *animate; +Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive; #else Global_Set_Setting_Function *global_set_setting_; Global_Set_Mapping_Function *global_set_mapping_; @@ -448,13 +487,23 @@ Get_View_First_Function *get_view_first_; Get_View_Next_Function *get_view_next_; Get_View_Summary_Function *get_view_summary_; Get_Active_View_Function *get_active_view_; -Open_View_Function *open_view_; +Get_Active_Panel_Function *get_active_panel_; +View_Get_Panel_Function *view_get_panel_; +Panel_Get_View_Function *panel_get_view_; +Panel_Is_Split_Function *panel_is_split_; +Panel_Is_Leaf_Function *panel_is_leaf_; +Panel_Split_Function *panel_split_; +Panel_Set_Split_Function *panel_set_split_; +Panel_Swap_Children_Function *panel_swap_children_; +Panel_Get_Parent_Function *panel_get_parent_; +Panel_Get_Child_Function *panel_get_child_; +Panel_Get_Max_Function *panel_get_max_; +Panel_Get_Margin_Function *panel_get_margin_; View_Close_Function *view_close_; View_Set_Active_Function *view_set_active_; View_Get_Setting_Function *view_get_setting_; View_Set_Setting_Function *view_set_setting_; View_Get_Managed_Scope_Function *view_get_managed_scope_; -View_Set_Split_Function *view_set_split_; View_Get_Enclosure_Rect_Function *view_get_enclosure_rect_; View_Compute_Cursor_Function *view_compute_cursor_; View_Set_Cursor_Function *view_set_cursor_; @@ -550,6 +599,9 @@ Get_String_Advance_Function *get_string_advance_; Draw_Rectangle_Function *draw_rectangle_; Draw_Rectangle_Outline_Function *draw_rectangle_outline_; Get_Default_Font_For_View_Function *get_default_font_for_view_; +Open_Color_Picker_Function *open_color_picker_; +Animate_Function *animate_; +Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive_; #endif void *memory; int32_t memory_size; @@ -594,13 +646,23 @@ app_links->get_view_first_ = Get_View_First;\ app_links->get_view_next_ = Get_View_Next;\ app_links->get_view_summary_ = Get_View_Summary;\ app_links->get_active_view_ = Get_Active_View;\ -app_links->open_view_ = Open_View;\ +app_links->get_active_panel_ = Get_Active_Panel;\ +app_links->view_get_panel_ = View_Get_Panel;\ +app_links->panel_get_view_ = Panel_Get_View;\ +app_links->panel_is_split_ = Panel_Is_Split;\ +app_links->panel_is_leaf_ = Panel_Is_Leaf;\ +app_links->panel_split_ = Panel_Split;\ +app_links->panel_set_split_ = Panel_Set_Split;\ +app_links->panel_swap_children_ = Panel_Swap_Children;\ +app_links->panel_get_parent_ = Panel_Get_Parent;\ +app_links->panel_get_child_ = Panel_Get_Child;\ +app_links->panel_get_max_ = Panel_Get_Max;\ +app_links->panel_get_margin_ = Panel_Get_Margin;\ app_links->view_close_ = View_Close;\ app_links->view_set_active_ = View_Set_Active;\ app_links->view_get_setting_ = View_Get_Setting;\ app_links->view_set_setting_ = View_Set_Setting;\ app_links->view_get_managed_scope_ = View_Get_Managed_Scope;\ -app_links->view_set_split_ = View_Set_Split;\ app_links->view_get_enclosure_rect_ = View_Get_Enclosure_Rect;\ app_links->view_compute_cursor_ = View_Compute_Cursor;\ app_links->view_set_cursor_ = View_Set_Cursor;\ @@ -695,7 +757,10 @@ app_links->draw_string_ = Draw_String;\ app_links->get_string_advance_ = Get_String_Advance;\ app_links->draw_rectangle_ = Draw_Rectangle;\ app_links->draw_rectangle_outline_ = Draw_Rectangle_Outline;\ -app_links->get_default_font_for_view_ = Get_Default_Font_For_View;} while(false) +app_links->get_default_font_for_view_ = Get_Default_Font_For_View;\ +app_links->open_color_picker_ = Open_Color_Picker;\ +app_links->animate_ = Animate;\ +app_links->find_all_in_range_insensitive_ = Find_All_In_Range_Insensitive;} while(false) #if defined(ALLOW_DEP_4CODER) static bool32 global_set_setting(Application_Links *app, Global_Setting_ID setting, int32_t value){return(app->global_set_setting(app, setting, value));} static bool32 global_set_mapping(Application_Links *app, void *data, int32_t size){return(app->global_set_mapping(app, data, size));} @@ -732,13 +797,23 @@ static bool32 get_view_first(Application_Links *app, Access_Flag access, View_ID static bool32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next(app, view_id, access, view_id_out));} static bool32 get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out){return(app->get_view_summary(app, view_id, access, view_summary_out));} static bool32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view(app, access, view_id_out));} -static bool32 open_view(Application_Links *app, View_ID location, View_Split_Position position, View_ID *view_id_out){return(app->open_view(app, location, position, view_id_out));} +static bool32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel(app, panel_id_out));} +static bool32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel(app, view_id, panel_id_out));} +static bool32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view(app, panel_id, view_id_out));} +static bool32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split(app, panel_id));} +static bool32 panel_is_leaf(Application_Links *app, Panel_ID panel_id){return(app->panel_is_leaf(app, panel_id));} +static bool32 panel_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation){return(app->panel_split(app, panel_id, orientation));} +static bool32 panel_set_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_set_split(app, panel_id, kind, t));} +static bool32 panel_swap_children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_swap_children(app, panel_id, kind, t));} +static bool32 panel_get_parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_parent(app, panel_id, panel_id_out));} +static bool32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){return(app->panel_get_child(app, panel_id, which_child, panel_id_out));} +static bool32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max(app, panel_id, panel_id_out));} +static bool32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin(app, panel_id, margins_out));} static bool32 view_close(Application_Links *app, View_ID view_id){return(app->view_close(app, view_id));} static bool32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active(app, view_id));} static bool32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting(app, view_id, setting, value_out));} static bool32 view_set_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t value){return(app->view_set_setting(app, view_id, setting, value));} static bool32 view_get_managed_scope(Application_Links *app, View_ID view_id, Managed_Scope *scope){return(app->view_get_managed_scope(app, view_id, scope));} -static bool32 view_set_split(Application_Links *app, View_ID view_id, View_Split_Kind kind, float t){return(app->view_set_split(app, view_id, kind, t));} static bool32 view_get_enclosure_rect(Application_Links *app, View_ID view_id, i32_Rect *rect_out){return(app->view_get_enclosure_rect(app, view_id, rect_out));} static bool32 view_compute_cursor(Application_Links *app, View_ID view_id, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor(app, view_id, seek, cursor_out));} static bool32 view_set_cursor(Application_Links *app, View_ID view_id, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor(app, view_id, seek, set_preferred_x));} @@ -834,6 +909,9 @@ static float get_string_advance(Application_Links *app, Face_ID font_id, String static void draw_rectangle(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle(app, rect, color));} static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline(app, rect, color));} static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id){return(app->get_default_font_for_view(app, view_id));} +static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker(app, picker));} +static void animate(Application_Links *app){(app->animate(app));} +static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t end, String key, Partition *memory){return(app->find_all_in_range_insensitive(app, buffer_id, start, end, key, memory));} #else static bool32 global_set_setting(Application_Links *app, Global_Setting_ID setting, int32_t value){return(app->global_set_setting_(app, setting, value));} static bool32 global_set_mapping(Application_Links *app, void *data, int32_t size){return(app->global_set_mapping_(app, data, size));} @@ -870,13 +948,23 @@ static bool32 get_view_first(Application_Links *app, Access_Flag access, View_ID static bool32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next_(app, view_id, access, view_id_out));} static bool32 get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out){return(app->get_view_summary_(app, view_id, access, view_summary_out));} static bool32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view_(app, access, view_id_out));} -static bool32 open_view(Application_Links *app, View_ID location, View_Split_Position position, View_ID *view_id_out){return(app->open_view_(app, location, position, view_id_out));} +static bool32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel_(app, panel_id_out));} +static bool32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel_(app, view_id, panel_id_out));} +static bool32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view_(app, panel_id, view_id_out));} +static bool32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split_(app, panel_id));} +static bool32 panel_is_leaf(Application_Links *app, Panel_ID panel_id){return(app->panel_is_leaf_(app, panel_id));} +static bool32 panel_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation){return(app->panel_split_(app, panel_id, orientation));} +static bool32 panel_set_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_set_split_(app, panel_id, kind, t));} +static bool32 panel_swap_children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_swap_children_(app, panel_id, kind, t));} +static bool32 panel_get_parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_parent_(app, panel_id, panel_id_out));} +static bool32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){return(app->panel_get_child_(app, panel_id, which_child, panel_id_out));} +static bool32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max_(app, panel_id, panel_id_out));} +static bool32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin_(app, panel_id, margins_out));} static bool32 view_close(Application_Links *app, View_ID view_id){return(app->view_close_(app, view_id));} static bool32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active_(app, view_id));} static bool32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting_(app, view_id, setting, value_out));} static bool32 view_set_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, int32_t value){return(app->view_set_setting_(app, view_id, setting, value));} static bool32 view_get_managed_scope(Application_Links *app, View_ID view_id, Managed_Scope *scope){return(app->view_get_managed_scope_(app, view_id, scope));} -static bool32 view_set_split(Application_Links *app, View_ID view_id, View_Split_Kind kind, float t){return(app->view_set_split_(app, view_id, kind, t));} static bool32 view_get_enclosure_rect(Application_Links *app, View_ID view_id, i32_Rect *rect_out){return(app->view_get_enclosure_rect_(app, view_id, rect_out));} static bool32 view_compute_cursor(Application_Links *app, View_ID view_id, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor_(app, view_id, seek, cursor_out));} static bool32 view_set_cursor(Application_Links *app, View_ID view_id, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor_(app, view_id, seek, set_preferred_x));} @@ -972,4 +1060,7 @@ static float get_string_advance(Application_Links *app, Face_ID font_id, String static void draw_rectangle(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_(app, rect, color));} static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline_(app, rect, color));} static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id){return(app->get_default_font_for_view_(app, view_id));} +static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker_(app, picker));} +static void animate(Application_Links *app){(app->animate_(app));} +static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t end, String key, Partition *memory){return(app->find_all_in_range_insensitive_(app, buffer_id, start, end, key, memory));} #endif diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index f461f604..abed3038 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -331,16 +331,16 @@ static Command_Metadata fcoder_metacmd_table[234] = { { PROC_LINKS(list_all_functions_all_buffers_lister, 0), "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 338 }, { PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 309 }, { PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 319 }, -{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 866 }, -{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 880 }, -{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 894 }, -{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 901 }, -{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 908 }, -{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 915 }, -{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 922 }, -{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 933 }, -{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 873 }, -{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 887 }, +{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 871 }, +{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 885 }, +{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 899 }, +{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 906 }, +{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 913 }, +{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 920 }, +{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 927 }, +{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 938 }, +{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 878 }, +{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 892 }, { PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 15 }, { PROC_LINKS(lister__backspace_text_field, 0), "lister__backspace_text_field", 28, "A lister mode command that dispatches to the lister's backspace text field handler.", 83, "w:\\4ed\\code\\4coder_lists.cpp", 28, 41 }, { PROC_LINKS(lister__backspace_text_field__default, 0), "lister__backspace_text_field__default", 37, "A lister mode command that backspaces one character from the text field.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 146 }, @@ -478,7 +478,7 @@ static Command_Metadata fcoder_metacmd_table[234] = { { PROC_LINKS(undo_this_buffer, 0), "undo_this_buffer", 16, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1617 }, { PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1549 }, { PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\4coder_jump_lister.cpp", 34, 108 }, -{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 953 }, +{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 958 }, { PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 744 }, { PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 103 }, { PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 67 }, diff --git a/4coder_generated/remapping.h b/4coder_generated/remapping.h index c6e714fc..e0465d13 100644 --- a/4coder_generated/remapping.h +++ b/4coder_generated/remapping.h @@ -410,7 +410,6 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[43] = { {0, 88, 2, "project_command_lister", 22, LINK_PROCS(project_command_lister)}, {0, 73, 1, "list_all_functions_all_buffers_lister", 37, LINK_PROCS(list_all_functions_all_buffers_lister)}, {0, 69, 2, "exit_4coder", 11, LINK_PROCS(exit_4coder)}, -{0, 55325, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55326, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55327, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55328, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, @@ -426,15 +425,16 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[43] = { {0, 55338, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55339, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55340, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, -{0, 55320, 0, "mouse_wheel_scroll", 18, LINK_PROCS(mouse_wheel_scroll)}, -{0, 55320, 1, "mouse_wheel_change_face_size", 28, LINK_PROCS(mouse_wheel_change_face_size)}, +{0, 55341, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, +{0, 55321, 0, "mouse_wheel_scroll", 18, LINK_PROCS(mouse_wheel_scroll)}, +{0, 55321, 1, "mouse_wheel_change_face_size", 28, LINK_PROCS(mouse_wheel_change_face_size)}, }; static Meta_Key_Bind fcoder_binds_for_default_mapid_file[78] = { {1, 0, 0, "write_character", 15, LINK_PROCS(write_character)}, -{0, 55316, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, -{0, 55323, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, -{0, 55318, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, -{0, 55321, 0, "click_set_cursor_if_lbutton", 27, LINK_PROCS(click_set_cursor_if_lbutton)}, +{0, 55317, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, +{0, 55324, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, +{0, 55319, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, +{0, 55322, 0, "click_set_cursor_if_lbutton", 27, LINK_PROCS(click_set_cursor_if_lbutton)}, {0, 55301, 0, "delete_char", 11, LINK_PROCS(delete_char)}, {0, 55301, 8, "delete_char", 11, LINK_PROCS(delete_char)}, {0, 55296, 0, "backspace_char", 14, LINK_PROCS(backspace_char)}, @@ -554,11 +554,11 @@ static Meta_Key_Bind fcoder_binds_for_default_default_lister_ui_map[16] = { {0, 55298, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, {0, 106, 2, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, {0, 55306, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, -{0, 55320, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, -{0, 55316, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, -{0, 55318, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, -{0, 55321, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55321, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, +{0, 55317, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, +{0, 55319, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, {0, 55322, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55323, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, }; static Meta_Sub_Map fcoder_submaps_for_default[4] = { {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_default_mapid_global, 43}, @@ -589,7 +589,6 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[40] = { {0, 88, 1, "project_command_lister", 22, LINK_PROCS(project_command_lister)}, {0, 73, 4, "list_all_functions_all_buffers_lister", 37, LINK_PROCS(list_all_functions_all_buffers_lister)}, {0, 69, 1, "exit_4coder", 11, LINK_PROCS(exit_4coder)}, -{0, 55325, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55326, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55327, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55328, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, @@ -605,16 +604,17 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[40] = { {0, 55338, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55339, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55340, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, -{0, 55320, 0, "mouse_wheel_scroll", 18, LINK_PROCS(mouse_wheel_scroll)}, -{0, 55320, 4, "mouse_wheel_change_face_size", 28, LINK_PROCS(mouse_wheel_change_face_size)}, +{0, 55341, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, +{0, 55321, 0, "mouse_wheel_scroll", 18, LINK_PROCS(mouse_wheel_scroll)}, +{0, 55321, 4, "mouse_wheel_change_face_size", 28, LINK_PROCS(mouse_wheel_change_face_size)}, }; static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[77] = { {1, 0, 0, "write_character", 15, LINK_PROCS(write_character)}, {1, 0, 2, "write_character", 15, LINK_PROCS(write_character)}, -{0, 55316, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, -{0, 55323, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, -{0, 55318, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, -{0, 55321, 0, "click_set_cursor_if_lbutton", 27, LINK_PROCS(click_set_cursor_if_lbutton)}, +{0, 55317, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, +{0, 55324, 0, "click_set_cursor_and_mark", 25, LINK_PROCS(click_set_cursor_and_mark)}, +{0, 55319, 0, "click_set_cursor", 16, LINK_PROCS(click_set_cursor)}, +{0, 55322, 0, "click_set_cursor_if_lbutton", 27, LINK_PROCS(click_set_cursor_if_lbutton)}, {0, 55301, 0, "delete_char", 11, LINK_PROCS(delete_char)}, {0, 55301, 8, "delete_char", 11, LINK_PROCS(delete_char)}, {0, 55296, 0, "backspace_char", 14, LINK_PROCS(backspace_char)}, @@ -730,11 +730,11 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_lister_ui_map[14] = { {0, 55305, 0, "lister__move_up", 15, LINK_PROCS(lister__move_up)}, {0, 55298, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, {0, 55306, 0, "lister__move_down", 17, LINK_PROCS(lister__move_down)}, -{0, 55320, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, -{0, 55316, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, -{0, 55318, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, -{0, 55321, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55321, 0, "lister__wheel_scroll", 20, LINK_PROCS(lister__wheel_scroll)}, +{0, 55317, 0, "lister__mouse_press", 19, LINK_PROCS(lister__mouse_press)}, +{0, 55319, 0, "lister__mouse_release", 21, LINK_PROCS(lister__mouse_release)}, {0, 55322, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, +{0, 55323, 0, "lister__repaint", 15, LINK_PROCS(lister__repaint)}, }; static Meta_Sub_Map fcoder_submaps_for_mac_default[4] = { {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_mac_default_mapid_global, 40}, diff --git a/4coder_helper.cpp b/4coder_helper.cpp index a1a315ee..28e35ff9 100644 --- a/4coder_helper.cpp +++ b/4coder_helper.cpp @@ -734,6 +734,25 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32 return(read_line(app, part, buffer, line, str, &ignore, &ignore)); } +static String +scratch_read(Application_Links *app, Partition *scratch, Buffer_ID buffer, int32_t start, int32_t end){ + String result = {}; + if (start <= end){ + int32_t len = end - start; + result = string_push(scratch, len); + if (buffer_read_range(app, buffer, start, end, result.str)){ + result.size = len; + } + } + return(result); +} + +static String +scratch_read(Application_Links *app, Partition *scratch, Buffer_ID buffer, Cpp_Token token){ + String result = scratch_read(app, scratch, buffer, token.start, token.start + token.size); + return(result); +} + static int32_t buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){ int32_t result = buffer->size; @@ -1599,5 +1618,32 @@ view_buffer_set(Application_Links *app, Buffer_ID *buffers, int32_t count){ // TODO(allen): do(implement view_buffer_set) } +//////////////////////////////// + +static void +condense_whitespace(String *a) +{ + *a = skip_chop_whitespace(*a); + + int size = a->size; + a->size = 0; + int i = 0; + while(i < size) + { + if(char_is_whitespace(a->str[i])) + { + a->str[a->size++] = ' '; + while((i < size) && char_is_whitespace(a->str[i])) + { + ++i; + } + } + else + { + a->str[a->size++] = a->str[i++]; + } + } +} + // BOTTOM diff --git a/4coder_helper.h b/4coder_helper.h index 14f7c12e..19966817 100644 --- a/4coder_helper.h +++ b/4coder_helper.h @@ -139,6 +139,7 @@ struct Token_Range{ }; struct Token_Iterator{ + // TODO(allen): source buffer Cpp_Token *token; Token_Range range; }; @@ -150,6 +151,15 @@ struct Sort_Pair_i32{ int32_t key; }; +//////////////////////////////// + +struct Buffer_Insertion +{ + Application_Links *app; + Buffer_ID buffer; + int32_t at; +}; + #endif // BOTTOM diff --git a/4coder_insertion.cpp b/4coder_insertion.cpp new file mode 100644 index 00000000..00ecd8ad --- /dev/null +++ b/4coder_insertion.cpp @@ -0,0 +1,101 @@ +/* + * Serial inserts helpers + */ + +// TOP + +static Buffer_Insertion +begin_buffer_insertion_at(Application_Links *app, Buffer_ID buffer_id, int32_t at){ + Buffer_Insertion result = {}; + result.app = app; + result.buffer = buffer_id; + result.at = at; + return(result); +} + +static Buffer_Summary +get_active_buffer(Application_Links *app, Access_Flag access){ + View_Summary view = get_active_view(app, access); + Buffer_Summary result = get_buffer(app, view.buffer_id, access); + return(result); +} + +static Buffer_Insertion +begin_buffer_insertion(Application_Links *app){ + View_Summary view = get_active_view(app, AccessAll); + Buffer_Insertion result = begin_buffer_insertion_at(app, view.buffer_id, view.cursor.pos); + return(result); +} + +static void +insert_string(Buffer_Insertion *insertion, String string){ + buffer_replace_range(insertion->app, insertion->buffer, insertion->at, insertion->at, string); + insertion->at += string.size; +} + +static int32_t +insertf(Buffer_Insertion *insertion, char *format, ...){ + // TODO(casey): Allen, ideally we would have our own formatter here that just outputs into a buffer and can't ever "run out of space". + char temp[1024]; + + va_list args; + va_start(args, format); + int32_t result = vsprintf(temp, format, args); + va_end(args); + + insert_string(insertion, make_string(temp, result)); + + return(result); +} + +static void +insertc(Buffer_Insertion *insertion, char C){ + buffer_replace_range(insertion->app, insertion->buffer, insertion->at, insertion->at, make_string(&C, 1)); + insertion->at += 1; +} + +static bool32 +insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, int32_t line, int32_t truncate_at){ + Partition *part = &global_part; + Temp_Memory temp = begin_temp_memory(part); + + Partial_Cursor begin = {}; + Partial_Cursor end = {}; + + Buffer_Summary buffer = get_buffer(insertion->app, buffer_id, AccessAll); + + bool32 success = false; + if (buffer_compute_cursor(insertion->app, &buffer, seek_line_char(line, 1), &begin)){ + if (buffer_compute_cursor(insertion->app, &buffer, seek_line_char(line, -1), &end)){ + if (begin.line == line){ + if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer.size){ + int32_t size = (end.pos - begin.pos); + if(truncate_at && (size > truncate_at)) + { + size = truncate_at; + } + + char *memory = push_array(part, char, size); + if (memory != 0){ + String str = make_string(memory, 0, size); + success = true; + buffer_read_range(insertion->app, &buffer, begin.pos, end.pos, str.str); + str.size = size; + insert_string(insertion, str); + } + } + } + } + } + + end_temp_memory(temp); + return(success); +} + +static bool32 +insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, int32_t line){ + return(insert_line_from_buffer(insertion, buffer_id, line, 0)); +} + +// BOTTOM + diff --git a/4coder_search.cpp b/4coder_search.cpp index 0ebb7f54..f7eb9ca3 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -642,12 +642,12 @@ static bool32 search_buffer_edit_handler(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t one_past_last, String text); #endif +static String search_name = make_lit_string("*search*"); + static void -list__parameters(Application_Links *app, Heap *heap, Partition *scratch, String *strings, int32_t count, - Search_Range_Flag match_flags, View_Summary default_target_view){ - // Open the search buffer - String search_name = make_lit_string("*search*"); - Buffer_ID search_buffer_id = create_or_switch_to_buffer_by_name(app, search_name.str, search_name.size, default_target_view); +list__parameters_buffer(Application_Links *app, Heap *heap, Partition *scratch, + String *strings, int32_t count, Search_Range_Flag match_flags, + Buffer_ID search_buffer_id){ Buffer_Summary search_buffer = get_buffer(app, search_buffer_id, AccessAll); // Setup the search buffer for 'init' mode - the history will begin only AFTER the buffer is filled @@ -766,9 +766,14 @@ list__parameters(Application_Links *app, Heap *heap, Partition *scratch, String mirror_buffer_set_mode(app, search_buffer_id, MirrorMode_Reflecting); buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, false); buffer_set_setting(app, &search_buffer, BufferSetting_RecordsHistory, true); -#if 0 - buffer_set_edit_handler(app, search_buffer_id, search_buffer_edit_handler); -#endif +} + +static void +list__parameters(Application_Links *app, Heap *heap, Partition *scratch, String *strings, int32_t count, + Search_Range_Flag match_flags, View_Summary default_target_view){ + // Open the search buffer + Buffer_ID search_buffer_id = create_or_switch_to_buffer_by_name(app, search_name.str, search_name.size, default_target_view); + list__parameters_buffer(app, heap, scratch, strings, count, match_flags, search_buffer_id); } static void diff --git a/4ed.cpp b/4ed.cpp index 5bfbad77..a99759a5 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1275,9 +1275,9 @@ App_Step_Sig(app_step){ } // NOTE(allen): send panel size update - if (models->layout.panel_state_dirty && models->hooks[hook_view_size_change] != 0){ + if (models->layout.panel_state_dirty && models->hooks[hook_buffer_viewer_update] != 0){ models->layout.panel_state_dirty = false; - models->hooks[hook_view_size_change](&models->app_links); + models->hooks[hook_buffer_viewer_update](&models->app_links); } // NOTE(allen): step panels diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index e7b85c66..535411fe 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -69,7 +69,10 @@ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live view->preferred_x = vptr->preferred_x; - view->view_region = vptr->panel->rect_inner; + i32_Rect view_region = vptr->panel->rect_inner; + view->view_region = view_region; + view->render_region = i32R(0, 0, rect_width(view_region), rect_height(view_region)); + view->file_region = vptr->file_region; if (vptr->ui_mode){ view->scroll_vars = vptr->ui_scroll; @@ -123,7 +126,7 @@ internal View* imp_get_view(Models *models, View_ID view_id){ Live_Views *live_set = &models->live_set; View *view = 0; - view_id = view_id - 1; + view_id -= 1; if (0 <= view_id && view_id < live_set->max){ view = live_set->views + view_id; if (!view->in_use){ @@ -133,6 +136,25 @@ imp_get_view(Models *models, View_ID view_id){ return(view); } +internal Panel* +imp_get_panel(Models *models, Panel_ID panel_id){ + Layout *layout = &models->layout; + Panel *panel = layout->panel_first + panel_id - 1; + if (!(layout->panel_first <= panel && panel < layout->panel_one_past_last)){ + panel = 0; + } + return(panel); +} + +internal bool32 +panel_api_check_panel(Panel *panel){ + bool32 result = false; + if (panel != 0 && panel->kind != PanelKind_Unused){ + result = true; + } + return(result); +} + API_EXPORT bool32 Global_Set_Setting(Application_Links *app, Global_Setting_ID setting, int32_t value) /* @@ -1638,45 +1660,233 @@ DOC_SEE(Access_Flag) Assert(panel != 0); View *view = panel->view; Assert(view != 0); + bool32 result = false; if (view_api_check_view(view, access)){ *view_id_out = view_get_id(&models->live_set, view); - return(true); + result = true; } - *view_id_out = 0; - return(false); + return(result); } -// TODO(allen): redocument API_EXPORT bool32 -Open_View(Application_Links *app, View_ID location, View_Split_Position position, View_ID *view_id_out) -/* -DOC_PARAM(view_location, The view_location parameter specifies the view to split to open the new view.) -DOC_PARAM(position, The position parameter specifies how to split the view and where to place the new view.) -DOC_RETURN(If this call succeeds it returns a View_Summary describing the newly created view, if it fails it -returns a null summary.) -DOC(4coder is built with a limit of 16 views. If 16 views are already open when this is called the call will fail.) -DOC_SEE(View_Split_Position) -*/{ +Get_Active_Panel(Application_Links *app, Panel_ID *panel_id_out){ + Models *models = (Models*)app->cmd_context; + Panel *panel = layout_get_active_panel(&models->layout); + Assert(panel != 0); + bool32 result = false; + if (panel_api_check_panel(panel)){ + *panel_id_out = panel_get_id(&models->layout, panel); + result = true; + } + else{ + *panel_id_out = 0; + } + return(result); +} + +API_EXPORT bool32 +View_Get_Panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - View *view = imp_get_view(models, location); + bool32 result = false; + View *view = imp_get_view(models, view_id); + *panel_id_out = 0; if (view_api_check_view(view)){ Panel *panel = view->panel; - b32 vertical_split = ((position == ViewSplit_Left) || (position == ViewSplit_Right)); - b32 br_split = ((position == ViewSplit_Bottom) || (position == ViewSplit_Right)); - Panel *new_panel = layout_split_panel(layout, panel, vertical_split, br_split); - if (new_panel != 0){ + *panel_id_out = panel_get_id(layout, panel); + result = true; + } + return(result); +} + +API_EXPORT bool32 +Panel_Get_View(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){ + Models *models = (Models*)app->cmd_context; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + *view_id_out = 0; + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Final){ + View *view = panel->view; + Assert(view != 0); + *view_id_out = view_get_id(&models->live_set, view); + result = true; + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Is_Split(Application_Links *app, Panel_ID panel_id){ + Models *models = (Models*)app->cmd_context; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Intermediate){ + result = true; + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Is_Leaf(Application_Links *app, Panel_ID panel_id){ + Models *models = (Models*)app->cmd_context; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Final){ + result = true; + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + Panel *new_panel = 0; + if (layout_split_panel(layout, panel, (orientation == PanelSplit_LeftAndRight), &new_panel)){ Live_Views *live_set = &models->live_set; View *new_view = live_set_alloc_view(&models->mem.heap, &models->lifetime_allocator, live_set); new_panel->view = new_view; new_view->panel = new_panel; view_set_file(models->system, models, new_view, models->scratch_buffer); - *view_id_out = view_get_id(live_set, new_view); - return(true); + result = true; } } - *view_id_out = 0; - return(false); + return(result); +} + +API_EXPORT bool32 +Panel_Set_Split(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Intermediate){ + panel->split.kind = kind; + switch (kind){ + case PanelSplitKind_Ratio_Max: + case PanelSplitKind_Ratio_Min: + { + panel->split.v_f32 = clamp(0.f, t, 1.f); + }break; + + case PanelSplitKind_FixedPixels_Max: + case PanelSplitKind_FixedPixels_Min: + { + panel->split.v_i32 = round32(t); + }break; + + default: + { + print_message(app, make_lit_string("Invalid split kind passed to panel_set_split, no change made to view layout")); + }break; + } + layout_propogate_sizes_down_from_node(layout, panel); + result = true; + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Swap_Children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Intermediate){ + Swap(Panel*, panel->tl_panel, panel->br_panel); + layout_propogate_sizes_down_from_node(layout, panel); + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Get_Parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + *panel_id_out = 0; + if (panel_api_check_panel(panel)){ + *panel_id_out = panel_get_id(layout, panel->parent); + result = true; + } + return(result); +} + +API_EXPORT bool32 +Panel_Get_Child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + *panel_id_out = 0; + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Intermediate){ + Panel *child = 0; + switch (which_child){ + case PanelChild_Min: + { + child = panel->tl_panel; + }break; + case PanelChild_Max: + { + child = panel->br_panel; + }break; + } + if (child != 0){ + *panel_id_out = panel_get_id(layout, child); + result = true; + } + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Get_Max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Intermediate){ + Panel *child = panel->br_panel; + *panel_id_out = panel_get_id(layout, child); + result = true; + } + } + return(result); +} + +API_EXPORT bool32 +Panel_Get_Margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){ + Models *models = (Models*)app->cmd_context; + Layout *layout = &models->layout; + bool32 result = false; + Panel *panel = imp_get_panel(models, panel_id); + if (panel_api_check_panel(panel)){ + if (panel->kind == PanelKind_Final){ + i32 margin = layout->margin; + margins_out->x0 = margin; + margins_out->x1 = margin; + margins_out->y0 = margin; + margins_out->y1 = margin; + result = true; + } + } + return(result); } // TODO(allen): redocument @@ -1838,67 +2048,6 @@ If the view_id does not specify a valid view, the returned scope is null.) return(false); } -// TODO(allen): redocument -API_EXPORT bool32 -View_Set_Split(Application_Links *app, View_ID view_id, View_Split_Kind kind, float t) -/* -DOC_PARAM(view, The view parameter specifies which view shall have it's size adjusted.) -DOC_PARAM(kind, There are different kinds of split, see View_Split_Kind documentation for more information.) -DOC_PARAM(t, The t parameter specifies the proportion of the containing box that the view should occupy. - -For proportion values, t will be clamped to [0,1]. - -For integer values, t will be rounded to the nearest integer. -) -DOC_SEE(View_Split_Kind) -DOC_RETURN(This call returns non-zero on success.) -*/{ - Models *models = (Models*)app->cmd_context; - Layout *layout = &models->layout; - View *view = imp_get_view(models, view_id); - - bool32 result = false; - if (view_api_check_view(view)){ - Panel *panel = view->panel; - Panel *intermediate = panel->parent; - if (intermediate != 0){ - Assert(intermediate->kind == PanelKind_Intermediate); - switch (kind){ - case ViewSplitKind_Ratio: - { - if (intermediate->br_panel == panel){ - intermediate->split.kind = PanelSplitKind_Ratio_BR; - } - else{ - intermediate->split.kind = PanelSplitKind_Ratio_TL; - } - intermediate->split.v_f32 = clamp(0.f, t, 1.f); - }break; - - case ViewSplitKind_FixedPixels: - { - if (intermediate->br_panel == panel){ - intermediate->split.kind = PanelSplitKind_FixedPixels_BR; - } - else{ - intermediate->split.kind = PanelSplitKind_FixedPixels_TL; - } - intermediate->split.v_i32 = round32(t); - }break; - - default: - { - print_message(app, make_lit_string("Invalid split kind passed to view_set_split, no change made to view layout")); - }break; - } - layout_propogate_sizes_down_from_node(layout, intermediate); - result = true; - } - } - - return(result); -} - // TODO(allen): redocument API_EXPORT bool32 View_Get_Enclosure_Rect(Application_Links *app, View_ID view_id, i32_Rect *rect_out) @@ -2057,7 +2206,6 @@ DOC_SEE(Set_Buffer_Flag) bool32 result = false; if (view_api_check_view(view)){ Editing_File *file = working_set_get_active_file(&models->working_set, buffer_id); - Assert(file != 0); if (buffer_api_check_file(file)){ if (file != view->file_data.file){ view_set_file(models->system, models, view, file); @@ -4101,6 +4249,10 @@ draw_helper__view_space_to_screen_space(Models *models, f32_Rect *rect){ rect->y1 += y_corner; } +// NOTE(allen): Coordinate space of draw calls: +// The render space is such that 0,0 is _always_ the top left corner of the renderable region of the view. +// To make text scroll with the buffer users should read the view's scroll position and subtract it first. + API_EXPORT float Draw_String(Application_Links *app, Face_ID font_id, String str, int32_t x, int32_t y, int_color color, uint32_t flags, float dx, float dy) { @@ -4173,4 +4325,238 @@ Get_Default_Font_For_View(Application_Links *app, View_ID view_id) return(face_id); } +API_EXPORT void +Open_Color_Picker(Application_Links *app, color_picker *picker) +/* +DOC(Opens a color picker using the parameters in the supplied structure.) +*/ +{ + Models *models = (Models*)app->cmd_context; + System_Functions *system = models->system; + + if(picker->finished) + { + *picker->finished = false; + } + system->open_color_picker(picker); +} + +void system_schedule_step(); +API_EXPORT void +Animate(Application_Links *app) +{ + Models *models = (Models*)app->cmd_context; + System_Functions *system = models->system; + + /* TODO(casey): Allen, I don't _really_ need system_schedule_step() here (which is what animate() does), I just need to know that somebody _will_ perform a system_schedule_step(), so multiple people all trying to do a step schedule can all be condensed into one... but it _looks_ like that is what already happens with system_schedule_step, since if it pushes multiple animate messages into the queue, they will all be consumed in a single frame, so it's fine, I think? But I of course don't know how it would work on other platforms, since I haven't looked at the Mac OS / Linux code. + + The more "correct" way to make this work, I suspect, is to just make a way for me to set the app_result.animating flag to "true", but I don't know how I would go about doing that from here :( + */ + system->animate(); +} + +// NOTE(casey): Find_All_In_Range_Insensitive is the only routine supplied, because anyone who would prefer case-sensitive can +// check afterward. +// TODO(casey): Allen, this routine is very intricate and needs to be tested thoroughly before mainlining. I've only done cursory testing on it and have probably missed bugs that only occur in highly segmented buffers. +// TODO(casey): I think this routine could potentially be simplified by making it into something that always works with a partial match list, where the partial matches have 0 characters matched, and they just get moved forward as they go. This would solve the duplicate code problem the routine currently has where it does the same thing in its two halves, but slightly differently. +API_EXPORT Found_String_List +Find_All_In_Range_Insensitive(Application_Links *app, Buffer_ID buffer_id, int32_t start, int32_t end, String key, Partition *memory) +{ + Found_String_List result = {}; + + Found_String *first_partial = 0; + Found_String *first_free = 0; + + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + if((file != 0) && key.size) + { + int32_t total_size = buffer_size(&file->state.buffer); + u32 clean_edegs = FoundString_CleanEdges; + + if (0 <= start && start <= end && end <= total_size) + { + Gap_Buffer *gap = &file->state.buffer; + Gap_Buffer_Stream stream = {}; + i32 i = start; + if (buffer_stringify_loop(&stream, gap, i, end)) + { + b32 still_looping = 0; + do + { + i32 size = stream.end - i; + char *data = stream.data + i; + + // NOTE(casey): Check all partial matches + Found_String **partial = &first_partial; + while(*partial) + { + Found_String *check = *partial; + i32 trailing_char_at = ((check->start + key.size) - check->end); + i32 remaining = trailing_char_at; + b32 valid = true; + b32 full = true; + if(remaining > size) + { + full = false; + remaining = size; + } + + for(i32 test = 0; + test < remaining; + ++test) + { + char a = key.str[test]; + char b = data[test]; + + if(a != b) + { + check->flags &= ~FoundString_Sensitive; + } + + if(char_to_lower(a) != char_to_lower(b)) + { + valid = false; + break; + } + } + check->end += remaining; + + if(valid) + { + // NOTE(casey): Although technically "full matches" are full, we haven't yet checked the trailing edge for tokenization, + // so we need to shunt to partial in the cases where we _can't_ check the overhanging character. + full = full && (trailing_char_at < size); + if(full) + { + if(char_is_alpha_numeric(data[trailing_char_at]) || (data[trailing_char_at] == '_')) + { + check->flags &= ~FoundString_CleanEdges; + } + + // NOTE(casey): This is a full match now, so we can move it to the result list + *partial = check->next; + check->next = 0; + result.last = (result.last ? result.last->next : result.first) = check; + ++result.count; + } + else + { + // NOTE(casey): This is still a partial match, so we just look at the next one + partial = &check->next; + } + } + else + { + // NOTE(casey): This is no longer a potential match, eliminate it. + *partial = check->next; + check->next = first_free; + first_free = check; + } + } + + // NOTE(casey): Check for new matches + // TODO(casey): We could definitely do way more efficient string matching here + for(i32 at = 0; + at < size; + ++at) + { + i32 remaining = size - at; + b32 full = false; + if(remaining >= key.size) + { + full = true; + remaining = key.size; + } + + u32 exact_matched = FoundString_Sensitive; + b32 lower_matched = true; + for(i32 test = 0; + test < remaining; + ++test) + { + char a = key.str[test]; + char b = data[at + test]; + + if(a != b) + { + exact_matched = 0; + } + + if(char_to_lower(a) != char_to_lower(b)) + { + lower_matched = false; + break; + } + } + + if(lower_matched) + { + Found_String *found = first_free; + if(found) + { + first_free = found->next; + } + else + { + found = push_array(memory, Found_String, 1); + } + + if(found) + { + found->next = 0; + found->buffer_id = buffer_id; + found->flags = FoundString_Insensitive | exact_matched | clean_edegs; + found->string_id = 0; + found->start = i + at; + found->end = found->start + remaining; + + // NOTE(casey): Although technically "full matches" are full, we haven't yet checked the trailing edge for tokenization, + // so we need to shunt to partial in the cases where we _can't_ check the overhanging character. + i32 trailing_char_at = (at + key.size); + full = full && (trailing_char_at < size); + + if(full) + { + if(char_is_alpha_numeric(data[trailing_char_at]) || (data[trailing_char_at] == '_')) + { + found->flags &= ~FoundString_CleanEdges; + } + result.last = (result.last ? result.last->next : result.first) = found; + ++result.count; + } + else + { + found->flags |= FoundString_Straddled; + *partial = (*partial ? (*partial)->next : first_partial) = found; + } + } + else + { + // TODO(casey): Allen, this is a non-fatal error that produces bad results - eg., there's not enough + // memory to actually store all the locations found. Hopefully this will never happen once this can + // be fed through a growable arena - right now it happens all the time, because the partition is too f'ing tiny. + } + } + + if(char_is_alpha(data[at]) || (data[at] == '_')) + { + clean_edegs = 0; + } + else + { + clean_edegs = FoundString_CleanEdges; + } + } + + i = stream.end; + still_looping = buffer_stringify_next(&stream); + } while(still_looping); + } + } + } + + return(result); +} + // BOTTOM diff --git a/4ed_layout.cpp b/4ed_layout.cpp index c5cc7df7..b3e700ee 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -27,7 +27,7 @@ make_panel_split(Panel_Split_Kind kind, f32 v){ internal Panel_Split make_panel_split_50_50(void){ - return(make_panel_split(PanelSplitKind_Ratio_TL, 0.5f)); + return(make_panel_split(PanelSplitKind_Ratio_Min, 0.5f)); } internal Panel* @@ -47,6 +47,7 @@ layout__free_panel(Layout *layout, Panel *panel){ Assert(panel != layout->root); dll_remove(&panel->node); dll_insert(&layout->free_panels, &panel->node); + panel->kind = PanelKind_Unused; } internal void @@ -59,19 +60,19 @@ internal i32 layout__evaluate_split(Panel_Split split, i32 v0, i32 v1){ i32 v = 0; switch (split.kind){ - case PanelSplitKind_Ratio_TL: + case PanelSplitKind_Ratio_Min: { v = round32(lerp((f32)v0, split.v_f32, (f32)v1)); }break; - case PanelSplitKind_Ratio_BR: + case PanelSplitKind_Ratio_Max: { v = round32(lerp((f32)v1, split.v_f32, (f32)v0)); }break; - case PanelSplitKind_FixedPixels_TL: + case PanelSplitKind_FixedPixels_Min: { v = clamp_top(v0 + split.v_i32, v1); }break; - case PanelSplitKind_FixedPixels_BR: + case PanelSplitKind_FixedPixels_Max: { v = clamp_bottom(v0, v1 - split.v_i32); }break; @@ -137,67 +138,50 @@ layout_get_active_panel(Layout *layout){ return(layout->active_panel); } -internal Panel* -layout_split_panel(Layout *layout, Panel *panel, b32 vertical_split, b32 br_split){ - Panel *new_panel = 0; +internal bool32 +layout_split_panel(Layout *layout, Panel *panel, b32 vertical_split, Panel **new_panel_out){ + b32 result = false; if (layout->open_panel_count < layout->open_panel_max_count){ - Panel *intermediate = layout__alloc_panel(layout); - new_panel = layout__alloc_panel(layout); + Panel *min_panel = layout__alloc_panel(layout); + Panel *max_panel = layout__alloc_panel(layout); - dll_insert(&layout->open_panels, &new_panel->node); - dll_insert(&layout->intermediate_panels, &intermediate->node); + dll_remove(&panel->node); + dll_insert(&layout->intermediate_panels, &panel->node); - Panel *parent = panel->parent; + dll_insert(&layout->open_panels, &min_panel->node); + dll_insert(&layout->open_panels, &max_panel->node); - // link new intermediate and parent - intermediate->parent = parent; - if (parent != 0){ - Assert(parent->kind == PanelKind_Intermediate); - if (parent->tl_panel == panel){ - parent->tl_panel = intermediate; - } - else{ - Assert(parent->br_panel == panel); - parent->br_panel = intermediate; - } - } - else{ - Assert(layout->root == panel); - layout->root = intermediate; - } + // init min_panel + panel->view->panel = min_panel; + min_panel->parent = panel; + min_panel->kind = PanelKind_Final; + min_panel->view = panel->view; - // link new intermediate and child panels - panel->parent = intermediate; - new_panel->parent = intermediate; - if (br_split){ - intermediate->br_panel = new_panel; - intermediate->tl_panel = panel; - } - else{ - intermediate->tl_panel = new_panel; - intermediate->br_panel = panel; - } + // init max_panel + *new_panel_out = max_panel; + max_panel->parent = panel; + max_panel->kind = PanelKind_Final; + max_panel->view = 0; - // init the intermediate - intermediate->kind = PanelKind_Intermediate; - intermediate->vertical_split = vertical_split; - intermediate->split = make_panel_split_50_50(); - intermediate->screen_region = panel->screen_region; - - // init the new panel - new_panel->kind = PanelKind_Final; - new_panel->view = 0; + // modify panel + panel->kind = PanelKind_Intermediate; + panel->tl_panel = min_panel; + panel->br_panel = max_panel; + panel->vertical_split = vertical_split; + panel->split = make_panel_split_50_50(); // propogate rectangle sizes down from the new intermediate to // resize the panel and the new panel. - layout_propogate_sizes_down_from_node(layout, intermediate); + layout_propogate_sizes_down_from_node(layout, panel); // update layout state layout->open_panel_count += 1; - layout->active_panel = new_panel; + layout->active_panel = max_panel; layout->panel_state_dirty = true; + + result = true; } - return(new_panel); + return(result); } internal b32 @@ -264,6 +248,10 @@ internal Panel* layout_initialize(Partition *part, Layout *layout){ i32 panel_alloc_count = MAX_VIEWS*2 - 1; Panel *panels = push_array(part, Panel, panel_alloc_count); + block_zero(panels, sizeof(*panels)*panel_alloc_count); + + layout->panel_first = panels; + layout->panel_one_past_last = panels + panel_alloc_count; layout->margin = 3; layout->open_panel_count = 0; @@ -403,19 +391,19 @@ layout__reverse_evaluate_panel_split(Panel *panel, i32 position){ v1 = panel->rect_full.y1; } switch (panel->split.kind){ - case PanelSplitKind_Ratio_TL: + case PanelSplitKind_Ratio_Min: { panel->split.v_f32 = unlerp((f32)v0, (f32)position, (f32)v1); }break; - case PanelSplitKind_Ratio_BR: + case PanelSplitKind_Ratio_Max: { panel->split.v_f32 = unlerp((f32)v1, (f32)position, (f32)v0); }break; - case PanelSplitKind_FixedPixels_TL: + case PanelSplitKind_FixedPixels_Min: { panel->split.v_i32 = clamp(v0, position, v1) - v0; }break; - case PanelSplitKind_FixedPixels_BR: + case PanelSplitKind_FixedPixels_Max: { panel->split.v_i32 = v1 - clamp(v0, position, v1); }break; @@ -448,5 +436,14 @@ layout_set_split_absolute_position(Layout *layout, Panel *panel, i32 absolute_po } } +internal Panel_ID +panel_get_id(Layout *layout, Panel *panel){ + Panel_ID id = 0; + if (layout->panel_first <= panel && panel < layout->panel_one_past_last){ + id = (Panel_ID)(panel - layout->panel_first) + 1; + } + return(id); +} + // BOTTOM diff --git a/4ed_layout.h b/4ed_layout.h index 30741824..f7793da2 100644 --- a/4ed_layout.h +++ b/4ed_layout.h @@ -12,14 +12,6 @@ #if !defined(FRED_LAYOUT_H) #define FRED_LAYOUT_H -typedef i32 Panel_Split_Kind; -enum{ - PanelSplitKind_Ratio_TL = 0, - PanelSplitKind_Ratio_BR = 1, - PanelSplitKind_FixedPixels_TL = 2, - PanelSplitKind_FixedPixels_BR = 3, -}; - struct Panel_Split{ Panel_Split_Kind kind; union{ @@ -30,8 +22,9 @@ struct Panel_Split{ typedef i32 Panel_Kind; enum{ - PanelKind_Intermediate = 0, - PanelKind_Final = 1, + PanelKind_Unused = 0, + PanelKind_Intermediate = 1, + PanelKind_Final = 2, }; struct Panel{ @@ -68,6 +61,8 @@ struct Layout{ Panel *root; Panel *active_panel; + Panel *panel_first; + Panel *panel_one_past_last; i32 margin; i32 open_panel_count; diff --git a/4ed_math.h b/4ed_math.h index e66bb519..dfb5dc31 100644 --- a/4ed_math.h +++ b/4ed_math.h @@ -57,130 +57,6 @@ COS(f32 x_degrees){ * Vectors */ -struct Vec2{ - union{ - struct{ - f32 x, y; - }; - struct{ - f32 v[2]; - }; - }; -}; - -struct Vec3{ - union{ - struct{ - f32 x, y, z; - }; - struct{ - f32 r, g, b; - }; - struct{ - Vec2 xy; - f32 _z; - }; - struct{ - f32 _x; - Vec2 yz; - }; - struct{ - f32 v[3]; - }; - }; -}; - -struct Vec4{ - union{ - struct{ - f32 r, g, b, a; - }; - struct{ - f32 h, s, l, __a; - }; - struct{ - f32 x, y, z, w; - }; - struct{ - Vec3 rgb; - f32 _a; - }; - struct{ - Vec3 xyz; - f32 _w; - }; - struct{ - f32 _x; - Vec3 yzw; - }; - struct{ - f32 v[4]; - }; - }; -}; - -struct Vec2_i32{ - union{ - struct{ - i32 x, y; - }; - struct{ - i32 v[2]; - }; - }; -}; - -struct Vec3_i32{ - union{ - struct{ - i32 x, y, z; - }; - struct{ - i32 r, g, b; - }; - struct{ - Vec2 xy; - i32 _z; - }; - struct{ - i32 _x; - Vec2 yz; - }; - struct{ - i32 v[3]; - }; - }; -}; - -struct Vec4_i32{ - union{ - struct{ - i32 r, g, b, a; - }; - struct{ - i32 h, s, l, __a; - }; - struct{ - i32 x, y, z, w; - }; - struct{ - Vec3 rgb; - i32 _a; - }; - struct{ - Vec3 xyz; - i32 _w; - }; - struct{ - i32 _x; - Vec3 yzw; - }; - struct{ - i32 v[4]; - }; - }; -}; - internal Vec2 V2(f32 x, f32 y){ Vec2 result = {}; @@ -771,6 +647,11 @@ i32R(i32 l, i32 t, i32 r, i32 b){ return(rect); } +internal i32_Rect +i32R_xy_wh(i32 x, i32 y, i32 w, i32 h){ + return(i32R(x, y, x + w, y + h)); +} + internal i32_Rect i32R(f32_Rect r){ i32_Rect rect = {}; diff --git a/4ed_render_format.cpp b/4ed_render_format.cpp index e7c4394f..084a4eb5 100644 --- a/4ed_render_format.cpp +++ b/4ed_render_format.cpp @@ -35,6 +35,9 @@ begin_render_section(Render_Target *target, System_Functions *system){ clip.x1 = target->width; clip.y1 = target->height; draw_push_clip(target, clip); + + target->buffer.pos = 0; + target->clear_color = 0xFFFF00FF; } internal void diff --git a/4ed_render_target.cpp b/4ed_render_target.cpp index 7c8be53f..aada11a2 100644 --- a/4ed_render_target.cpp +++ b/4ed_render_target.cpp @@ -23,6 +23,9 @@ Render_Begin_Push_Sig(render_internal_begin_push, t, ptr, size){ if (out != 0){ memcpy(out, ptr, size); } + else{ + t->clear_color = 0xFF00FF00; + } return(out); } diff --git a/4ed_render_target.h b/4ed_render_target.h index 215e6106..c0d4c42c 100644 --- a/4ed_render_target.h +++ b/4ed_render_target.h @@ -21,10 +21,13 @@ struct Render_Target{ i32_Rect clip_boxes[5]; i32 clip_top; b32 clip_all; - i32 width, height; + i32 width; + i32 height; i32 bound_texture; u32 color; + u32 clear_color; + Render_Free_Texture *free_texture_first; Render_Free_Texture *free_texture_last; diff --git a/4ed_system.h b/4ed_system.h index dd9dd923..2f3203a0 100644 --- a/4ed_system.h +++ b/4ed_system.h @@ -75,6 +75,9 @@ typedef Sys_Wake_Up_Timer_Set_Sig(System_Wake_Up_Timer_Set); #define Sys_Wake_Up_Timer_Check_Sig(name) u64 name(Plat_Handle handle) typedef Sys_Wake_Up_Timer_Check_Sig(System_Wake_Up_Timer_Check); +#define Sys_Animate_Sig(name) void name() +typedef Sys_Animate_Sig(System_Animate); + // clipboard #define Sys_Post_Clipboard_Sig(name) void name(String str) typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard); @@ -124,6 +127,11 @@ typedef Sys_Resume_Coroutine_Sig(System_Resume_Coroutine); #define Sys_Yield_Coroutine_Sig(name) void name(Coroutine_Head *head) typedef Sys_Yield_Coroutine_Sig(System_Yield_Coroutine); +// + +#define Sys_Open_Color_Picker_Sig(name) void name(color_picker *picker) +typedef Sys_Open_Color_Picker_Sig(System_Open_Color_Picker); + // thread struct Thread_Context; @@ -245,6 +253,7 @@ struct System_Functions{ System_Wake_Up_Timer_Create *wake_up_timer_create; System_Wake_Up_Timer_Release *wake_up_timer_release; System_Wake_Up_Timer_Set *wake_up_timer_set; + System_Animate *animate; // clipboard: 1 System_Post_Clipboard *post_clipboard; @@ -261,6 +270,9 @@ struct System_Functions{ System_CLI_Update_Step *cli_update_step; System_CLI_End_Update *cli_end_update; + // TODO(allen): + System_Open_Color_Picker *open_color_picker; + // threads: 6 System_Post_Job *post_job; System_Cancel_Job *cancel_job; diff --git a/4ed_view.cpp b/4ed_view.cpp index f650aff4..a6ce54fa 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -334,6 +334,8 @@ view_set_file(System_Functions *system, Models *models, View *view, Editing_File Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id); view->line_height = font.metrics->height; + + models->layout.panel_state_dirty = true; } //////////////////////////////// diff --git a/meta/4ed_build.cpp b/meta/4ed_build.cpp index 8e43dcb8..8959c28f 100644 --- a/meta/4ed_build.cpp +++ b/meta/4ed_build.cpp @@ -194,11 +194,11 @@ get_defines_from_flags(Partition *part, u32 flags){ "-wd4611 -WX -GR- -EHa- -nologo -FC" #define CL_LIBS_X64 \ -"user32.lib winmm.lib gdi32.lib opengl32.lib " \ +"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ FOREIGN_WIN"\\x64\\freetype.lib" #define CL_LIBS_X86 \ -"user32.lib winmm.lib gdi32.lib opengl32.lib " \ +"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ FOREIGN_WIN"\\x86\\freetype.lib" #define CL_ICON "..\\4coder-non-source\\res\\icon.res" diff --git a/opengl/4ed_opengl_render.cpp b/opengl/4ed_opengl_render.cpp index 98d6c8f7..4c2b857f 100644 --- a/opengl/4ed_opengl_render.cpp +++ b/opengl/4ed_opengl_render.cpp @@ -96,7 +96,10 @@ interpret_render_buffer(Render_Target *t, Partition *growable_scratch){ glLoadIdentity(); glOrtho(0, width, height, 0, -1, 1); glScissor(0, 0, width, height); - glClearColor(1.f, 0.f, 1.f, 1.f); + { + Vec4 color = unpack_color4(t->clear_color); + glClearColor(color.r, color.g, color.b, color.a); + } glClear(GL_COLOR_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/platform_all/4ed_link_system_functions.cpp b/platform_all/4ed_link_system_functions.cpp index 31f17792..9f448146 100644 --- a/platform_all/4ed_link_system_functions.cpp +++ b/platform_all/4ed_link_system_functions.cpp @@ -33,6 +33,7 @@ link_system_code(){ SYSLINK(wake_up_timer_set); SYSLINK(post_clipboard); + SYSLINK(animate); SYSLINK(create_coroutine); SYSLINK(launch_coroutine); @@ -44,6 +45,8 @@ link_system_code(){ SYSLINK(cli_update_step); SYSLINK(cli_end_update); + SYSLINK(open_color_picker); + SYSLINK(post_job); SYSLINK(cancel_job); SYSLINK(check_cancel); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 93f8fd80..7ae1f55c 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -22,6 +22,7 @@ #define frame_useconds (1000000 / FPS) #include "4ed_defines.h" +#include "4coder_base_types.h" #include "4coder_API/4coder_version.h" #include @@ -263,7 +264,7 @@ handle_type_ptr(void *ptr){ //////////////////////////////// -internal void +void system_schedule_step(){ PostMessage(win32vars.window_handle, WM_4coder_ANIMATE, 0, 0); } @@ -1422,6 +1423,7 @@ Win32KeycodeInit(void){ keycode_lookup_table[VK_CAPITAL] = key_caps; keycode_lookup_table[VK_NUMLOCK] = key_num_lock; keycode_lookup_table[VK_SCROLL] = key_scroll_lock; + keycode_lookup_table[VK_APPS] = key_menu; keycode_lookup_table[VK_F1] = key_f1; keycode_lookup_table[VK_F2] = key_f2; @@ -2365,7 +2367,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS // NOTE(allen): Application Core Update - target.buffer.pos = 0; Application_Step_Result result = {}; if (app.step != 0){ result = app.step(&sysfunc, &target, &memory_vars, &input); diff --git a/platform_win32/win32_4ed_functions.cpp b/platform_win32/win32_4ed_functions.cpp index d87dcaae..fa05d5a9 100644 --- a/platform_win32/win32_4ed_functions.cpp +++ b/platform_win32/win32_4ed_functions.cpp @@ -439,5 +439,160 @@ system_directory_exists(char *path){ return(attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)); } +// +// Color picker +// + +internal int_color +swap_r_and_b(int_color a) +{ + int_color result = a & 0xff00ff00; + result |= ((a >> 16) & 0xff); + result |= ((a & 0xff) << 16); + return(result); +} + +internal int_color +int_color_from_colorref(COLORREF ref, int_color alpha_from) +{ + int_color rgb = swap_r_and_b(ref & 0xffffff); + + int_color result = ((0xff000000 & alpha_from) | rgb); + return(result); +} + +void system_schedule_step(); +internal UINT_PTR CALLBACK +color_picker_hook(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam) +{ + UINT_PTR result = 0; + switch(Message) + { + case WM_INITDIALOG: + { + CHOOSECOLORW *win32_params = (CHOOSECOLORW *)LParam; + color_picker *picker = (color_picker *)win32_params->lCustData; + SetWindowLongPtr(Window, GWLP_USERDATA, (LONG_PTR)LParam); + + u16_4tech Temp[256]; + Temp[ArrayCount(Temp) - 1] = 0; + + b32_4tech ignored; + utf8_to_utf16_minimal_checking(Temp, ArrayCount(Temp), (u8_4tech *)picker->title.str, picker->title.size, &ignored); + if(picker->title.size < ArrayCount(Temp)) + { + Temp[picker->title.size] = 0; + } + + SetWindowTextW(Window, (LPCWSTR)Temp); + } break; + + case WM_CTLCOLORSTATIC: + { + // NOTE(casey): I can't believe I'm 42 years old and I still have to do this fucking crap. + // Microsoft is so fucking fired every god damn day. Would it have killed you to update rgbResult + // continuously, or at least provide a GetCurrentColor() call??? + // + // Anyway, since the color picker doesn't tell us when the color is changed, what we do is watch for messages + // that repaint the color swatch, which is dialog id 0x2c5, and then we sample it to see what color it is. + // No, I'm not fucking kidding, that's what we do. + HWND swatch_window = (HWND)LParam; + if(GetDlgCtrlID(swatch_window) == 0x2c5) + { + CHOOSECOLORW *win32_params = (CHOOSECOLORW *)GetWindowLongPtr(Window, GWLP_USERDATA); + if(win32_params) + { + color_picker *picker = (color_picker *)win32_params->lCustData; + + RECT rect; + GetClientRect(swatch_window, &rect); + HDC swatch_dc = (HDC)WParam; + COLORREF Probe = GetPixel(swatch_dc, (rect.left + rect.right) / 4, (rect.top + rect.bottom) / 2); + int_color new_color = int_color_from_colorref(Probe, *picker->dest); + + if(*picker->dest != new_color) + { + *picker->dest = new_color; + system_schedule_step(); + } + } + } + } break; + + default: + { +#if 0 + // NOTE(casey): Enable this if you want to dump the color edit dialog messages to the debug log + short Temp[256]; + wsprintf((LPWSTR)Temp, L"%u 0x%x 0x%x\n", Message, WParam, LParam); + OutputDebugStringW((LPWSTR)Temp); +#endif + } break; + } + + return(result); +} + +internal DWORD WINAPI +color_picker_thread(LPVOID Param) +{ + color_picker *picker = (color_picker *)Param; + + int_color color = 0; + if(picker->dest) + { + color = *picker->dest; + } + + COLORREF custom_colors[16] = {}; + + CHOOSECOLORW win32_params = {}; + win32_params.lStructSize = sizeof(win32_params); + //win32_params.hwndOwner = win32vars.window_handle; + win32_params.hInstance = win32vars.window_handle; + win32_params.rgbResult = swap_r_and_b(color) & 0xffffff; + win32_params.lpCustColors = custom_colors; + win32_params.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ANYCOLOR | CC_ENABLEHOOK; + win32_params.lCustData = (LPARAM)picker; + win32_params.lpfnHook = color_picker_hook; + + if(ChooseColorW(&win32_params)) + { + color = int_color_from_colorref(win32_params.rgbResult, color); + } + + if(picker->dest) + { + *picker->dest = color; + } + + if(picker->finished) + { + *picker->finished = true; + } + + system_memory_free(picker, sizeof(*picker)); + + return(0); +} + +internal +Sys_Open_Color_Picker_Sig(system_open_color_picker){ + + // NOTE(casey): Because this is going to be used by a semi-permanent thread, we need to copy + // it to system memory where it can live as long as it wants, no matter what we do over here + // on the 4coder threads. + color_picker *perm = (color_picker *)system_memory_allocate_extended(0, sizeof(color_picker)); + *perm = *picker; + + HANDLE ThreadHandle = CreateThread(0, 0, color_picker_thread, perm, 0, 0); + CloseHandle(ThreadHandle); +} + +internal +Sys_Animate_Sig(system_animate){ + system_schedule_step(); +}; + // BOTTOM