From 6eacad6221d848e97e7eb9e32da4c66ff1680901 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 9 Sep 2016 11:04:38 -0400 Subject: [PATCH] part of the way to making panel positions fixed --- 4coder_API.html | 3 +- 4ed.cpp | 37 +++++++----- 4ed.h | 5 -- 4ed_defines.h | 10 ++-- 4ed_file.cpp | 4 +- 4ed_file_view.cpp | 4 +- 4ed_layout.cpp | 148 ++++++++++++++++++++++++++++++++++++++-------- TODO.txt | 41 ++++++++----- build.c | 4 +- 9 files changed, 182 insertions(+), 74 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index d252ac8b..5683fe6b 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -116,7 +116,8 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

ViewSetting_ShowScrollbar
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.


§3.4.14: Buffer_Create_Flag

enum Buffer_Create_Flag;
Description
A Buffer_Create_Flag field specifies how a buffer should be created.

Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.

BufferCreate_AlwaysNew = 0x2
When BufferCreate_AlwaysNew is set it indicates the buffer should be cleared to empty even if it's associated file already has content.

BufferCreate_NeverNew = 0x4
When BufferCreate_NeverNew is set it indicates that the buffer should - only be created if it is an existing file or an open buffer.


§3.4.15: Buffer_Kill_Flag

enum Buffer_Kill_Flag;
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.

Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.

BufferKill_AlwaysKill = 0x2
When BufferKill_AlwaysKill is set it indicates the buffer should be killed + only be created if it is an existing file or if a buffer with the given name + is already open.


§3.4.15: Buffer_Kill_Flag

enum Buffer_Kill_Flag;
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.

Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.

BufferKill_AlwaysKill = 0x2
When BufferKill_AlwaysKill is set it indicates the buffer should be killed without asking, even when the buffer is dirty.


§3.4.16: Access_Flag

enum Access_Flag;
Description
An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is diff --git a/4ed.cpp b/4ed.cpp index 5807e002..6eae824a 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -20,7 +20,6 @@ typedef enum App_State{ typedef struct App_State_Resizing{ Panel_Divider *divider; - f32 min, max; } App_State_Resizing; typedef struct CLI_Process{ @@ -2608,9 +2607,6 @@ App_Step_Sig(app_step){ end_temp_memory(temp); } - - vars->resizing.min = 0.f; - vars->resizing.max = 1.f; } }break; @@ -2618,20 +2614,29 @@ App_Step_Sig(app_step){ { if (input->mouse.l){ Panel_Divider *divider = vars->resizing.divider; - i32 pos = 0; - if (divider->v_divider){ - pos = clamp(0, mx, models->layout.full_width); - } - else{ - pos = clamp(0, my, models->layout.full_height); - } - divider->pos = layout_compute_position(&models->layout, divider, pos); + i32 mouse_position = 0; - if (divider->pos < vars->resizing.min){ - divider->pos = vars->resizing.min; + b32 do_absolute_positions = 0; + if (do_absolute_positions){ + i32 absolute_positions[MAX_VIEWS]; + i32 min = 0, max = 0; + i32 div_id = (i32)(divider - models->layout.dividers); + + layout_compute_absolute_positions(&models->layout, absolute_positions); + mouse_position = (divider->v_divider)?(mx):(my); + layout_get_min_max(&models->layout, divider, absolute_positions, &min, &max); + absolute_positions[div_id] = clamp(min, mouse_position, max); + layout_update_all_positions(&models->layout, absolute_positions); } - else if (divider->pos > vars->resizing.max){ - divider->pos = vars->resizing.max - 1; + + else{ + if (divider->v_divider){ + mouse_position = clamp(0, mx, models->layout.full_width); + } + else{ + mouse_position = clamp(0, my, models->layout.full_height); + } + divider->pos = layout_compute_position(&models->layout, divider, ); } layout_fix_all_panels(&models->layout); diff --git a/4ed.h b/4ed.h index eccc2a29..719f02f6 100644 --- a/4ed.h +++ b/4ed.h @@ -34,11 +34,6 @@ struct Key_Input_Data{ char modifiers[MDFR_INDEX_COUNT]; }; -inline Key_Input_Data -key_input_data_zero(){ - Key_Input_Data data={0}; - return(data); -} struct Key_Summary{ i32 count; diff --git a/4ed_defines.h b/4ed_defines.h index 2ae6067d..07900f88 100644 --- a/4ed_defines.h +++ b/4ed_defines.h @@ -87,11 +87,11 @@ TMin(u32); TMin(u64); #undef TMin -#define TMin(t,v) globalconst t min_##t = ((t)v) -TMin(i8, -0xF0); -TMin(i16, -0xF000); -TMin(i32, -0xF00000); -TMin(i64, -0xF0000000LL); +#define TMin(t,v) globalconst t min_##t = ((t)(v)) +TMin(i8, -127-1); +TMin(i16, -32767-1); +TMin(i32, -2147483647-1); +TMin(i64, -9223372036854775807-1); #undef TMin internal i32 diff --git a/4ed_file.cpp b/4ed_file.cpp index eab17260..a479513b 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -754,10 +754,10 @@ struct Hot_Directory_Match{ }; internal b32 -filename_match(String query, Absolutes *absolutes, String filename, b32 case_sensitive){ +filename_match(String query, Absolutes *absolutes, String filename){ b32 result; result = (query.size == 0); - if (!result) result = wildcard_match_s(absolutes, filename, case_sensitive); + if (!result) result = wildcard_match_s(absolutes, filename, 0); return result; } diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 49daf824..2f28b064 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -3211,7 +3211,7 @@ get_exhaustive_info(System_Functions *system, Working_Set *working_set, Exhausti result.info->filename_len, result.info->filename_len+1); result.is_folder = (result.info->folder != 0); - result.name_match = (filename_match(loop->front_name, &loop->absolutes, filename, 0) != 0); + result.name_match = (filename_match(loop->front_name, &loop->absolutes, filename) != 0); result.is_loaded = (file != 0 && file_is_ready(file)); result.message = null_string; @@ -4024,7 +4024,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su Editing_File *file = (Editing_File*)node; Assert(!file->is_dummy); - if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){ + if (filename_match(view->dest, &absolutes, file->name.live_name)){ View_Iter iter = file_view_iter_init(layout, file, 0); if (file_view_iter_good(iter)){ reserved_files[reserved_top++] = file; diff --git a/4ed_layout.cpp b/4ed_layout.cpp index c3d3da64..6497001a 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -28,7 +28,7 @@ struct Screen_Region{ struct Panel{ Panel *next; Panel *prev; - + struct View *view; i32 parent; i32 which_child; @@ -210,7 +210,7 @@ panel_fix_internal_area(Panel *panel){ internal i32_Rect layout_get_rect(Editing_Layout *layout, i32 id, i32 which_child){ - i32 divider_chain[16]; + i32 divider_chain[MAX_VIEWS]; i32 chain_count = 0; Panel_Divider *dividers = layout->dividers; @@ -232,26 +232,18 @@ layout_get_rect(Editing_Layout *layout, i32 id, i32 which_child){ Panel_Divider *div = dividers + divider_chain[i]; if (div->v_divider){ if (div->child1 == divider_chain[i-1]){ - r.x1 = ROUND32(lerp((f32)r.x0, - div->pos, - (f32)r.x1)); + r.x1 = ROUND32(lerp((f32)r.x0, div->pos, (f32)r.x1)); } else{ - r.x0 = ROUND32(lerp((f32)r.x0, - div->pos, - (f32)r.x1)); + r.x0 = ROUND32(lerp((f32)r.x0, div->pos, (f32)r.x1)); } } else{ if (div->child1 == divider_chain[i-1]){ - r.y1 = ROUND32(lerp((f32)r.y0, - div->pos, - (f32)r.y1)); + r.y1 = ROUND32(lerp((f32)r.y0, div->pos, (f32)r.y1)); } else{ - r.y0 = ROUND32(lerp((f32)r.y0, - div->pos, - (f32)r.y1)); + r.y0 = ROUND32(lerp((f32)r.y0, div->pos, (f32)r.y1)); } } } @@ -260,28 +252,20 @@ layout_get_rect(Editing_Layout *layout, i32 id, i32 which_child){ case 1: { if (original_div->v_divider){ - r.x0 = ROUND32(lerp((f32)r.x0, - original_div->pos, - (f32)r.x1)); + r.x0 = ROUND32(lerp((f32)r.x0, original_div->pos, (f32)r.x1)); } else{ - r.y0 = ROUND32(lerp((f32)r.y0, - original_div->pos, - (f32)r.y1)); + r.y0 = ROUND32(lerp((f32)r.y0, original_div->pos, (f32)r.y1)); } }break; case -1: { if (original_div->v_divider){ - r.x1 = ROUND32(lerp((f32)r.x0, - original_div->pos, - (f32)r.x1)); + r.x1 = ROUND32(lerp((f32)r.x0, original_div->pos, (f32)r.x1)); } else{ - r.y1 = ROUND32(lerp((f32)r.y0, - original_div->pos, - (f32)r.y1)); + r.y1 = ROUND32(lerp((f32)r.y0, original_div->pos, (f32)r.y1)); } }break; } @@ -384,5 +368,117 @@ layout_compute_position(Editing_Layout *layout, Panel_Divider *divider, i32 pos) return(l); } +internal void +layout_compute_abs_step(Editing_Layout *layout, i32 divider_id, i32_Rect rect, i32 *abs_pos){ + Panel_Divider *div = layout->dividers + divider_id; + i32 p0 = 0, p1 = 0; + + if (div->v_divider){ + p0 = rect.x0; p1 = rect.x1; + } + else{ + p0 = rect.y0; p1 = rect.y1; + } + + i32 pos = lerp(p0, div->pos, p1); + i32_Rect r1, r2; + r1 = rect; r2 = rect; + + abs_pos[divider_id] = pos; + + if (div->v_divider){ + r1.x1 = pos; r2.x0 = pos; + } + else{ + r1.y1 = pos; r2.y0 = pos; + } + + if (div->child1 != -1){ + layout_compute_abs_step(layout, div->child1, r1, abs_pos); + } + + if (div->child2 != -1){ + layout_compute_abs_step(layout, div->child2, r2, abs_pos); + } +} + +internal void +layout_compute_absolute_positions(Editing_Layout *layout, i32 *abs_pos){ + i32_Rect r; + r.x0 = 0; + r.y0 = 0; + r.x1 = layout->full_width; + r.y1 = layout->full_height; + if (layout->panel_count > 1){ + layout_compute_abs_step(layout, layout->root, r, abs_pos); + } +} + +internal void +layout_get_min_max_step_up(Editing_Layout *layout, b32 v, i32 divider_id, i32 which_child, + i32 *abs_pos, i32 *min_out, i32 *max_out){ + Panel_Divider *divider = layout->dividers + divider_id; + + if (divider->v_divider == v){ + if (which_child == -1){ + if (*max_out > abs_pos[divider_id]){ + *max_out = abs_pos[divider_id]; + } + } + else{ + if (*min_out < abs_pos[divider_id]){ + *min_out = abs_pos[divider_id]; + } + } + } + + if (divider->parent != -1){ + layout_get_min_max_step_up(layout, v, divider->parent, divider->which_child, + abs_pos, min_out, max_out); + } +} + +internal void +layout_get_min_max_step_down(Editing_Layout *layout, b32 v, i32 divider_id, i32 which_child, + i32 *abs_pos, i32 *min_out, i32 *max_out){ + +} + +internal void +layout_get_min_max(Editing_Layout *layout, Panel_Divider *divider, i32 *abs_pos, i32 *min_out, i32 *max_out){ + *min_out = 0; + *max_out = max_i32; + + if (layout->panel_count > 1){ + if (divider->parent != -1){ + layout_get_min_max_step_up(layout, divider->v_divider, divider->parent, divider->which_child, + abs_pos, min_out, max_out); + } + + if (divider->child1 != -1){ + layout_get_min_max_step_down(layout, divider->v_divider, divider->child1, -1, + abs_pos, min_out, max_out); + } + + if (divider->child2 != -1){ + layout_get_min_max_step_down(layout, divider->v_divider, divider->child1, 1, + abs_pos, min_out, max_out); + } + } + else{ + if (divider->v_divider){ + *max_out = layout->full_width; + } + else{ + *max_out = layout->full_height; + } + } +} + +internal void +layout_update_all_positions(Editing_Layout *layout, i32 *abs_pos){ + +} + // BOTTOM diff --git a/TODO.txt b/TODO.txt index bf0c3f77..f5641225 100644 --- a/TODO.txt +++ b/TODO.txt @@ -86,6 +86,7 @@ ; BEFORE I SHIP ; +; [X] case insensitive interactive switch buffer ; [X] tokens in the custom API ; [X] token seeking on custom side ; [X] auto indent on the custom side @@ -97,7 +98,6 @@ ; [] make panel resizing not whacky with child panels ; [] mouse down/up distinction ; [] occasionally missing the (!) mark on files on windows -; [] case insensitive interactive switch buffer ; [] scroll down on compilation buffer durring compilation ; [] why are command line files not loading any more? ; @@ -139,7 +139,10 @@ ; [X] add to APIs ; [X] try to make win32 version better ; [X] don't execute frames on events dealing only with ctrl/alt/shift -; [X] hook on exit +; [X] additional hooks +; [X] new file +; [X] hook on exit +; [X] file out of sync ; ; [] binary buffers @@ -159,22 +162,25 @@ ; [] break buffer name ties by adding parent directories instead of <#> ; [] undo groups ; [] cursor/scroll grouping -; [] file status in custom API ; [] allow for arbitrary wrap positions independent of view width -; [] word level wrapping ~ temporary measure really want to have totally formatted code -; [] additional hooks -; [X] new file -; [] file out of sync +; [] word level wrapping ~ temporary measure really want to have totally formatted code presentation ; [] double binding warnings ; +; +; [] the "main_4coder" experiment ; [] multi-line editing ; [] multi-cursor editing ; + ; meta programming system +; [X] condense system into single meta compiler +; [] formalize the rewriter for the 4coder_string.h so it can be used for other single header libs +; [] formalize the documentation writer so the TOC can be better and so it's easier to shoot off other docs ; [] profile and optimize the current metagen system ; [] expand the use of 4coder_types.h to also allow static variable and function declarations ; [] get more of the helper functions going through the documentation system ; + ; GUI related tech ; [X] consolidate all GUI code properly ; [X] rewrite GUI @@ -182,6 +188,7 @@ ; [] scroll bar position and size options ; [] GUI API ; + ; search related tech ; [X] replace word (incremental and/or in range) ; [X] caps insensitivety @@ -190,11 +197,13 @@ ; [] optimize search ; [] smarter isearch behavior ; + ; theme related business ; [] fix the versioning system for themes ; [] theme switch per panel? ; [] allow multiple font faces with effects ; + ; control schemes ; [] emacs style sub-maps ; [] vim style modes @@ -203,6 +212,7 @@ ; [] command meta data ; [] macros ; + ; code engine ; [X] lexer with multiple chunk input ; [X] more correct auto-indentation @@ -210,6 +220,15 @@ ; [] preprocessor ; [] AST generator ; + +; "virtual text" +; [] line numbers +; [] macro expansion +; [] error text at line +; [] word complete ghosting +; [] fancy code presentation mode +; + ; [X] cuber's return to previous buffer idea ; [] miblo's various number editors ; @@ -221,14 +240,6 @@ ; [] explicit panel layout ; [] polish for hot directories ; -; "virtual text" -; [] line numbers -; [] macro expansion -; [] error text at line -; [] word complete ghosting -; -; [] the "main_4coder" experiment -; ; [] tutorials ; [] 4edT thing ; [] unicode/UTF support diff --git a/build.c b/build.c index 5b6008dd..785d432f 100644 --- a/build.c +++ b/build.c @@ -680,9 +680,9 @@ metagen(char *cdir){ static void do_buildsuper(char *cdir){ BEGIN_TIME_SECTION(); - buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp"); + //buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp"); #if defined(IS_WINDOWS) - //buildsuper(cdir, BUILD_DIR, "../code/internal_4coder_tests.cpp"); + buildsuper(cdir, BUILD_DIR, "../code/internal_4coder_tests.cpp"); #else buildsuper(cdir, BUILD_DIR, "../code/power/4coder_experiments.cpp"); #endif