From 42cab1b573dc5e42d027654a74cac7f259dd4e8a Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 6 Jul 2016 18:04:31 -0400 Subject: [PATCH] eliminated max_y --- 4coder_API.html | 7 +- 4coder_types.h | 2 - 4coder_version.h | 2 +- 4ed.cpp | 47 +++++++-- 4ed_api_implementation.cpp | 4 +- 4ed_file_view.cpp | 203 +++++++++++++++++++------------------ 4ed_gui.cpp | 6 +- build_all.bat | 4 +- power/4coder_casey.cpp | 48 +++------ win32_4ed.cpp | 8 +- 10 files changed, 169 insertions(+), 162 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index 991baa53..e4344020 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -22,7 +22,7 @@ ul { list-style: none; padding: 0; margin: 0; }

§1 Introduction

-This is the documentation for alpha 4.0.9 super! The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.

+This is the documentation for alpha 4.0.10 super! The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.

If you have questions or discover errors please contact editor@4coder.net or to get help from community members you can post on the 4coder forums hosted on handmade.network at 4coder.handmade.network

@@ -1703,7 +1703,6 @@ can either be a name or an id. If the
TODO
-
max_y
-
TODO
-
-
scroll_x
TODO
diff --git a/4coder_types.h b/4coder_types.h index 1463b613..3cd11926 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -458,8 +458,6 @@ struct GUI_Scroll_Vars{ int32_t target_y; /* DOC(TODO) */ int32_t prev_target_y; - /* DOC(TODO) */ - int32_t max_y; /* DOC(TODO) */ float scroll_x; diff --git a/4coder_version.h b/4coder_version.h index 024273b1..25a13817 100644 --- a/4coder_version.h +++ b/4coder_version.h @@ -1,6 +1,6 @@ #define MAJOR 4 #define MINOR 0 -#define PATCH 9 +#define PATCH 10 #define VN__(a,b,c) #a"."#b"."#c #define VN_(a,b,c) VN__(a,b,c) diff --git a/4ed.cpp b/4ed.cpp index a2379e29..c702fac4 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -230,11 +230,7 @@ app_resume_coroutine(System_Functions *system, Application_Links *app, Coroutine inline void output_file_append(System_Functions *system, Models *models, Editing_File *file, String value, b32 cursor_at_end){ i32 end = buffer_size(&file->state.buffer); - i32 next_cursor = 0; - if (cursor_at_end){ - next_cursor = end + value.size; - } - file_replace_range(system, models, file, end, end, value.str, value.size, next_cursor, 1); + file_replace_range(system, models, file, end, end, value.str, value.size); } inline void @@ -471,7 +467,7 @@ COMMAND_DECL(word_complete){ buffer_stringify(match.buffer, match.start, match.end, spare); if (search_hit_add(general, &complete_state->hits, &complete_state->str, spare, match_size)){ - view_replace_range(system, models, view, word_start, word_end, spare, match_size, word_end); + view_replace_range(system, models, view, word_start, word_end, spare, match_size); complete_state->word_end = word_start + match_size; complete_state->set.ranges[1].start = word_start + match_size; @@ -489,7 +485,7 @@ COMMAND_DECL(word_complete){ match_size = complete_state->iter.word.size; view_replace_range(system, models, view, word_start, word_end, - complete_state->iter.word.str, match_size, word_end); + complete_state->iter.word.str, match_size); complete_state->word_end = word_start + match_size; complete_state->set.ranges[1].start = word_start + match_size; @@ -573,9 +569,29 @@ COMMAND_DECL(reopen){ if (system->file_load_end(loading, buffer)){ General_Memory *general = &models->mem.general; - file_close(system, general, file); + File_Edit_Positions edit_poss[16]; + View *vptrs[16]; + i32 vptr_count = 0; + for (View_Iter iter = file_view_iter_init(&models->layout, file, 0); + file_view_iter_good(iter); + iter = file_view_iter_next(iter)){ + vptrs[vptr_count] = iter.view; + edit_poss[vptr_count] = *iter.view->edit_pos; + iter.view->edit_pos = 0; + ++vptr_count; + } + file_close(system, general, file); init_normal_file(system, models, file, buffer, loading.size); + + for (i32 i = 0; + i < vptr_count; + ++i){ + view_set_file(vptrs[i], file, models); + *vptrs[i]->edit_pos = edit_poss[i]; + view_set_cursor(vptrs[i], edit_poss[i].cursor, + true, view->file_data.unwrapped_lines); + } } end_temp_memory(temp); @@ -2498,9 +2514,18 @@ App_Step_Sig(app_step){ } } + i32 max_y = 0; + if (view->showing_ui == VUI_None){ + max_y = view_compute_max_target_y(view); + } + else{ + max_y = view->gui_max_y; + } + Input_Process_Result ip_result = do_step_file_view(system, view, panel->inner, active, - &summary, *scroll_vars, view->scroll_region); + &summary, *scroll_vars, view->scroll_region, max_y); + if (ip_result.is_animating){ app_result.animating = 1; } @@ -2513,6 +2538,10 @@ App_Step_Sig(app_step){ "file view step"); } + if (ip_result.has_max_y_suggestion){ + view->gui_max_y = ip_result.max_y; + } + if (!gui_scroll_eq(scroll_vars, &ip_result.vars)){ if (file_scroll){ view_set_scroll(view, ip_result.vars); diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 98550e76..990927e3 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -266,7 +266,7 @@ DOC_SEE(Command_Line_Input_Flag) } if (file){ - file_clear(system, models, file, 1); + file_clear(system, models, file); file->settings.unimportant = 1; if (!(flags & CLI_AlwaysBindToView)){ @@ -693,7 +693,7 @@ DOC_SEE(4coder_Buffer_Positioning_System) result = true; file_replace_range(cmd->system, cmd->models, - file, start, end, str, len, 0); + file, start, end, str, len); } fill_buffer_summary(buffer, file, cmd); } diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 97475e06..4f70e395 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -221,6 +221,7 @@ struct View{ GUI_Target gui_target; void *gui_mem; GUI_Scroll_Vars gui_scroll; + i32 gui_max_y; i32 list_i; b32 hide_scrollbar; @@ -473,10 +474,57 @@ view_compute_cursor_from_xy(View *view, f32 seek_x, f32 seek_y){ return result; } +inline i32 +view_wrapped_line_span(f32 line_width, f32 max_width){ + i32 line_count = CEIL32(line_width / max_width); + if (line_count == 0) line_count = 1; + return line_count; +} + +internal i32 +view_compute_lowest_line(View *view){ + i32 lowest_line = 0; + i32 last_line = view->file_data.line_count - 1; + if (last_line > 0){ + if (view->file_data.unwrapped_lines){ + lowest_line = last_line; + } + else{ + f32 wrap_y = view->file_data.line_wrap_y[last_line]; + lowest_line = FLOOR32(wrap_y / view->line_height); + f32 max_width = view_file_width(view); + + Editing_File *file = view->file_data.file; + Assert(!file->is_dummy); + f32 width = file->state.buffer.line_widths[last_line]; + i32 line_span = view_wrapped_line_span(width, max_width); + lowest_line += line_span - 1; + } + } + return lowest_line; +} + +inline i32 +view_compute_max_target_y(i32 lowest_line, i32 line_height, f32 view_height){ + f32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f; + max_target_y = clamp_bottom(0.f, max_target_y); + return(CEIL32(max_target_y)); +} + +inline i32 +view_compute_max_target_y(View *view){ + i32 lowest_line = view_compute_lowest_line(view); + i32 line_height = view->line_height; + f32 view_height = clamp_bottom((f32)line_height, view_file_height(view)); + i32 max_target_y = view_compute_max_target_y(lowest_line, line_height, view_height); + return(max_target_y); +} + internal b32 view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){ b32 result = false; f32 max_x = view_file_width(view); + i32 max_y = view_compute_max_target_y(view); f32 cursor_y = view_get_cursor_y(view); f32 cursor_x = view_get_cursor_x(view); @@ -504,7 +552,7 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){ } } - target_y = clamp(0, target_y, scroll_vars.max_y); + target_y = clamp(0, target_y, max_y); if (cursor_x >= target_x + max_x){ target_x = CEIL32(cursor_x - max_x/2); @@ -940,52 +988,6 @@ file_measure_starts_widths(System_Functions *system, General_Memory *general, buffer->widths_count = state.count; } -inline i32 -view_wrapped_line_span(f32 line_width, f32 max_width){ - i32 line_count = CEIL32(line_width / max_width); - if (line_count == 0) line_count = 1; - return line_count; -} - -internal i32 -view_compute_lowest_line(View *view){ - i32 lowest_line = 0; - i32 last_line = view->file_data.line_count - 1; - if (last_line > 0){ - if (view->file_data.unwrapped_lines){ - lowest_line = last_line; - } - else{ - f32 wrap_y = view->file_data.line_wrap_y[last_line]; - lowest_line = FLOOR32(wrap_y / view->line_height); - f32 max_width = view_file_width(view); - - Editing_File *file = view->file_data.file; - Assert(!file->is_dummy); - f32 width = file->state.buffer.line_widths[last_line]; - i32 line_span = view_wrapped_line_span(width, max_width); - lowest_line += line_span - 1; - } - } - return lowest_line; -} - -inline i32 -view_compute_max_target_y(i32 lowest_line, i32 line_height, f32 view_height){ - f32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f; - max_target_y = clamp_bottom(0.f, max_target_y); - return(CEIL32(max_target_y)); -} - -inline i32 -view_compute_max_target_y(View *view){ - i32 lowest_line = view_compute_lowest_line(view); - i32 line_height = view->line_height; - f32 view_height = clamp_bottom((f32)line_height, view_file_height(view)); - i32 max_target_y = view_compute_max_target_y(lowest_line, line_height, view_height); - return(max_target_y); -} - internal void view_measure_wraps(General_Memory *general, View *view){ Buffer_Type *buffer; @@ -1730,7 +1732,6 @@ view_set_file(View *view, Editing_File *file, Models *models){ if (file_is_ready(file)){ view_measure_wraps(&models->mem.general, view); - view->edit_pos->scroll.max_y = view_compute_max_target_y(view); } } } @@ -2080,8 +2081,7 @@ file_edit_cursor_fix(System_Functions *system, internal void file_do_single_edit(System_Functions *system, Models *models, Editing_File *file, - Edit_Spec spec, History_Mode history_mode, b32 use_high_permission = 0){ - if (!use_high_permission && file->settings.read_only) return; + Edit_Spec spec, History_Mode history_mode){ Mem_Options *mem = &models->mem; Editing_Layout *layout = &models->layout; @@ -2156,8 +2156,7 @@ file_do_single_edit(System_Functions *system, internal void file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File *file, - Edit_Spec spec, History_Mode history_mode, b32 use_high_permission = 0){ - if (!use_high_permission && file->settings.read_only) return; + Edit_Spec spec, History_Mode history_mode){ Mem_Options *mem = &models->mem; Editing_Layout *layout = &models->layout; @@ -2244,26 +2243,25 @@ file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File inline void file_replace_range(System_Functions *system, Models *models, Editing_File *file, - i32 start, i32 end, char *str, i32 len, i32 next_cursor, b32 use_high_permission = 0){ + i32 start, i32 end, char *str, i32 len){ Edit_Spec spec = {}; spec.step.type = ED_NORMAL; spec.step.edit.start = start; spec.step.edit.end = end; - spec.step.edit.len = len; spec.str = (u8*)str; - file_do_single_edit(system, models, file, spec, hist_normal, use_high_permission); + file_do_single_edit(system, models, file, spec, hist_normal); } inline void -file_clear(System_Functions *system, Models *models, Editing_File *file, b32 use_high_permission = 0){ - file_replace_range(system, models, file, 0, buffer_size(&file->state.buffer), 0, 0, 0, use_high_permission); +file_clear(System_Functions *system, Models *models, Editing_File *file){ + file_replace_range(system, models, file, 0, buffer_size(&file->state.buffer), 0, 0); } inline void view_replace_range(System_Functions *system, Models *models, View *view, - i32 start, i32 end, char *str, i32 len, i32 next_cursor){ - file_replace_range(system, models, view->file_data.file, start, end, str, len, next_cursor); + i32 start, i32 end, char *str, i32 len){ + file_replace_range(system, models, view->file_data.file, start, end, str, len); } inline void @@ -3198,7 +3196,7 @@ view_save_file(System_Functions *system, Models *models, } } - if (file && buffer_get_sync(file) != SYNC_GOOD){ + if (file && (buffer_get_sync(file) != SYNC_GOOD || save_as)){ if (file_save(system, mem, file, filename_string.str)){ if (save_as){ file_set_name(working_set, file, filename_string.str); @@ -4001,7 +3999,6 @@ show_gui_scroll(GUI_Target *target, String *string, show_gui_float(target, string, indent_level+1, h_align, " scroll_y ", scroll.scroll_y); show_gui_int (target, string, indent_level+1, h_align, " target_y ", scroll.target_y); show_gui_int (target, string, indent_level+1, h_align, " prev_target_y ", scroll.prev_target_y); - show_gui_int (target, string, indent_level+1, h_align, " max_y ", scroll.max_y); show_gui_float(target, string, indent_level+1, h_align, " scroll_x ", scroll.scroll_x); show_gui_int (target, string, indent_level+1, h_align, " target_x ", scroll.target_x); show_gui_int (target, string, indent_level+1, h_align, " prev_target_x ", scroll.prev_target_x); @@ -4515,7 +4512,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su File_Node *node = 0, *used_nodes = 0; Editing_File **reserved_files = 0; i32 reserved_top = 0, i = 0; - View_Iter iter = {0}; partition_align(part, sizeof(i32)); reserved_files = (Editing_File**)partition_current(part); @@ -4526,7 +4522,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su Assert(!file->is_dummy); if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){ - iter = file_view_iter_init(layout, file, 0); + View_Iter iter = file_view_iter_init(layout, file, 0); if (file_view_iter_good(iter)){ reserved_files[reserved_top++] = file; } @@ -5091,13 +5087,16 @@ struct Input_Process_Result{ b32 is_animating; b32 consumed_l; b32 consumed_r; + + b32 has_max_y_suggestion; + i32 max_y; }; internal Input_Process_Result do_step_file_view(System_Functions *system, View *view, i32_Rect rect, b32 is_active, Input_Summary *user_input, - GUI_Scroll_Vars vars, i32_Rect region){ + GUI_Scroll_Vars vars, i32_Rect region, i32 max_y){ Input_Process_Result result = {0}; b32 is_file_scroll = 0; @@ -5106,7 +5105,7 @@ do_step_file_view(System_Functions *system, GUI_Target *target = &view->gui_target; GUI_Interpret_Result interpret_result = {0}; - vars.target_y = clamp(0, vars.target_y, vars.max_y); + vars.target_y = clamp(0, vars.target_y, max_y); result.vars = vars; result.region = region; @@ -5120,7 +5119,7 @@ do_step_file_view(System_Functions *system, h->type; h = NextHeader(h)){ interpret_result = gui_interpret(target, &gui_session, h, - result.vars, result.region); + result.vars, result.region, max_y); if (interpret_result.has_region){ result.region = interpret_result.region; @@ -5161,7 +5160,6 @@ do_step_file_view(System_Functions *system, result.vars = view_reinit_scrolling(view); result.is_animating = true; } - result.vars.max_y = view_compute_max_target_y(view); if (file_step(view, gui_session.rect, user_input, is_active, &result.consumed_l)){ result.is_animating = true; @@ -5208,17 +5206,17 @@ do_step_file_view(System_Functions *system, activation_key = char_to_upper(activation_key); if (activation_key != 0){ - count = keys->count; - for (i = 0; i < count; ++i){ - key = get_single_key(keys, i); - if (char_to_upper(key.character) == activation_key){ - target->active = b->id; - result.is_animating = true; - break; + count = keys->count; + for (i = 0; i < count; ++i){ + key = get_single_key(keys, i); + if (char_to_upper(key.character) == activation_key){ + target->active = b->id; + result.is_animating = true; + break; + } } } } - } }break; case guicom_scrollable_slider: @@ -5244,7 +5242,7 @@ do_step_file_view(System_Functions *system, v = unlerp(gui_session.scroll_top, (f32)my, gui_session.scroll_bottom); v = clamp(0.f, v, 1.f); - result.vars.target_y = ROUND32(lerp(0.f, v, (f32)result.vars.max_y)); + result.vars.target_y = ROUND32(lerp(0.f, v, (f32)max_y)); gui_activate_scrolling(target); result.is_animating = true; @@ -5258,7 +5256,7 @@ do_step_file_view(System_Functions *system, result.vars.target_y += user_input->mouse.wheel*target->delta; result.vars.target_y = - clamp(0, result.vars.target_y, result.vars.max_y); + clamp(0, result.vars.target_y, max_y); gui_activate_scrolling(target); result.is_animating = true; } @@ -5281,7 +5279,7 @@ do_step_file_view(System_Functions *system, if (scroll_button_input(target, &gui_session, user_input, id, &result.is_animating)){ result.vars.target_y += clamp_bottom(1, target->delta >> 2); - result.vars.target_y = clamp_top(result.vars.target_y, result.vars.max_y); + result.vars.target_y = clamp_top(result.vars.target_y, max_y); result.consumed_l = true; } }break; @@ -5289,7 +5287,8 @@ do_step_file_view(System_Functions *system, case guicom_end_scrollable_section: { if (!is_file_scroll){ - result.vars.max_y = gui_session.suggested_max_y; + result.has_max_y_suggestion = true; + result.max_y = gui_session.suggested_max_y; } }break; } @@ -5528,7 +5527,7 @@ draw_text_field(Render_Target *target, View *view, i32_Rect rect, String p, Stri draw_rectangle(target, rect, back_color); x = CEIL32(draw_string(target, font_id, p, x, y, text2_color)); draw_string(target, font_id, t, x, y, text1_color); - } + } } internal void @@ -5573,7 +5572,7 @@ draw_text_with_cursor(Render_Target *target, View *view, i32_Rect rect, String s else{ draw_string(target, font_id, s, FLOOR32(x), y, text_color); } - } + } } internal void @@ -5583,21 +5582,21 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re Style_Font *font = &models->global_font; Style *style = main_style(models); Interactive_Style bar_style = style->main.file_info_style; - + u32 back_color = bar_style.bar_color; u32 base_color = bar_style.base_color; u32 pop1_color = bar_style.pop1_color; u32 pop2_color = bar_style.pop2_color; - + bar.rect = rect; - + if (target){ bar.font_id = font->font_id; bar.pos_x = (f32)bar.rect.x0; bar.pos_y = (f32)bar.rect.y0; bar.text_shift_y = 2; bar.text_shift_x = 0; - + draw_rectangle(target, bar.rect, back_color); if (!file){ intbar_draw_string(target, &bar, make_lit_string("*NULL*"), base_color); @@ -5616,22 +5615,22 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re append_int_to_str(&line_number, view->edit_pos->cursor.line); append(&line_number, " C#"); append_int_to_str(&line_number, view->edit_pos->cursor.character); - + intbar_draw_string(target, &bar, line_number, base_color); - + intbar_draw_string(target, &bar, make_lit_string(" -"), base_color); - + if (file->settings.dos_write_mode){ intbar_draw_string(target, &bar, make_lit_string(" dos"), base_color); } else{ intbar_draw_string(target, &bar, make_lit_string(" nix"), base_color); } - + if (file->state.still_lexing){ intbar_draw_string(target, &bar, make_lit_string(" parsing"), pop1_color); } - + if (!file->settings.unimportant){ switch (buffer_get_sync(file)){ case SYNC_BEHIND_OS: @@ -5639,7 +5638,7 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re persist String out_of_sync = make_lit_string(" !"); intbar_draw_string(target, &bar, out_of_sync, pop2_color); }break; - + case SYNC_UNSAVED: { persist String out_of_sync = make_lit_string(" *"); @@ -5655,7 +5654,7 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re u32 get_margin_color(i32 active_level, Style *style){ u32 margin = 0xFFFFFFFF; - + switch (active_level){ default: margin = style->main.margin_color; @@ -5668,19 +5667,19 @@ get_margin_color(i32 active_level, Style *style){ case 3: case 4: margin = style->main.margin_active_color; break; - } - + } + return(margin); } internal void draw_color_button(GUI_Target *gui_target, Render_Target *target, View *view, - i32_Rect rect, GUI_id id, u32 fore, u32 back, String text){ + i32_Rect rect, GUI_id id, u32 fore, u32 back, String text){ Models *models = view->persistent.models; i32 active_level = gui_active_level(gui_target, id); i16 font_id = models->global_font.font_id; - + if (active_level > 0){ Swap(u32, back, fore); } @@ -5691,7 +5690,7 @@ draw_color_button(GUI_Target *gui_target, Render_Target *target, View *view, internal void draw_font_button(GUI_Target *gui_target, Render_Target *target, View *view, - i32_Rect rect, GUI_id id, i16 font_id, String text){ + i32_Rect rect, GUI_id id, i16 font_id, String text){ Models *models = view->persistent.models; Style *style = main_style(models); @@ -5700,7 +5699,7 @@ draw_font_button(GUI_Target *gui_target, Render_Target *target, View *view, u32 margin = get_margin_color(active_level, style); u32 back = style->main.back_color; u32 text_color = style->main.default_color; - + draw_rectangle(target, rect, back); draw_rectangle_outline(target, rect, margin); draw_string(target, font_id, text, rect.x0, rect.y0 + 1, text_color); @@ -5708,7 +5707,7 @@ draw_font_button(GUI_Target *gui_target, Render_Target *target, View *view, internal void draw_fat_option_block(GUI_Target *gui_target, Render_Target *target, View *view, i32_Rect rect, GUI_id id, - String text, String pop, i8 checkbox = -1){ + String text, String pop, i8 checkbox = -1){ Models *models = view->persistent.models; Style *style = main_style(models); @@ -5830,7 +5829,9 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol GUI_Target *gui_target = &view->gui_target; GUI_Interpret_Result interpret_result = {0}; - f32 v; + f32 v = {0}; + + i32 max_y = view_compute_max_target_y(view); if (gui_target->push.pos > 0){ gui_session_init(&gui_session, gui_target, rect, view->line_height); @@ -5844,7 +5845,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol h->type; h = NextHeader(h)){ interpret_result = gui_interpret(gui_target, &gui_session, h, - *scroll, view->scroll_region); + *scroll, view->scroll_region, max_y); if (interpret_result.has_info){ if (gui_session.clip_y > clip_rect.y0){ diff --git a/4ed_gui.cpp b/4ed_gui.cpp index 069be04d..5cbf559b 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -946,7 +946,7 @@ struct GUI_Interpret_Result{ internal GUI_Interpret_Result gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h, - GUI_Scroll_Vars vars, i32_Rect region){ + GUI_Scroll_Vars vars, i32_Rect region, i32 max_y){ GUI_Interpret_Result result = {0}; GUI_Section *section = 0; GUI_Section *new_section = 0; @@ -1135,11 +1135,11 @@ gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h, lerp_space_scroll_v = unlerp(0, (f32)target->scroll_original.target_y, - (f32)target->scroll_original.max_y); + (f32)max_y); gui_scrollbar_slider(session->scroll_rect, &rect, lerp_space_scroll_v, &session->scroll_top, &session->scroll_bottom, - 0, target->scroll_original.max_y); + 0, max_y); scroll_v = 0; break; diff --git a/build_all.bat b/build_all.bat index a301aac2..f0cc8bbb 100644 --- a/build_all.bat +++ b/build_all.bat @@ -27,8 +27,8 @@ pushd ..\build REM call "%CODE_DIR%\buildsuper.bat" ..\code\4coder_default_bindings.cpp call "%CODE_DIR%\buildsuper.bat" ..\code\power\4coder_experiments.cpp -call "%CODE_DIR%\buildsuper.bat" ..\code\power\4coder_casey.cpp -call "%CODE_DIR%\buildsuper.bat" ..\4vim\4coder_chronal.cpp +REM call "%CODE_DIR%\buildsuper.bat" ..\code\power\4coder_casey.cpp +REM call "%CODE_DIR%\buildsuper.bat" ..\4vim\4coder_chronal.cpp if %ERRORLEVEL% neq 0 (set FirstError=1) set EXPORTS=/EXPORT:app_get_functions diff --git a/power/4coder_casey.cpp b/power/4coder_casey.cpp index 22c3516b..d3062c4a 100644 --- a/power/4coder_casey.cpp +++ b/power/4coder_casey.cpp @@ -11,31 +11,17 @@ merchantability, fitness for a particular purpose, or non-infringement. */ -/* BUGS - -Assertion: w:\apps\4coder\source\build\4ed_app.dll - w:\apps\4coder\source\code\4ed_file_view.cpp - Line: 3261 - Expression: view->prev_cursor_pos == view_get_cursor_pos(view) - - -Crash in buffer_get_line_index_range - it doesn't check for lines == 0, which can be the case? - -*/ - /* TODO(casey): Here are our current issues - High priority: - Buffer switching still seems a little bit broken. I find I can't reliably hit switch-return and switch to the most recently viewed file that wasn't one of the two currently viewed buffers? - - High-DPI settings break rendering and all fonts just show up as solid squares + + - High-DPI settings break rendering and all fonts just show up as solid squares <<< Check this again + - Pretty sure auto-indent has some bugs. Things that should be pretty easy to indent properly even from only a few surrounding lines seem to be indented improperly at the moment - Multi-line comments should default to indenting to the indentation of the line prior? - - Would like the option to indent to hanging parentheses, equals signs, etc. instead of - always just "one tab in from the previous line". - - Actually, maybe just expose the dirty state, so that the user can decide whether to - save or not? Not sure... - Replace: - Needs to be case-insensitive, or at least have the option to be - Needs to replace using the case of the thing being replaced, or at least have the option to do so @@ -57,16 +43,18 @@ Crash in buffer_get_line_index_range - it doesn't check for lines == 0, which ca - Display: - When switching _back_ to a buffer, it seems like it loses the scroll position, instead preferring - to center the cursor? This is undesirable IMO... + to center the cursor? This is undesirable IMO... <<< Check this again + - I'd like to be able to hide the mark in text entry mode, and show the whole highlighted region in edit mode - perhaps even with a magic split at the top or bottom that shows where the mark is if it's off screen? - There are often repaint bugs with 4coder coming to the front / unminimizing, etc. I think this might have something to do with the way you're doing lots of semaphore - locking but I haven't investigated yet. + locking but I haven't investigated yet. <<< How are we doing on this bug? It might be fixed but I haven't heard from anyone. + - Need a word-wrap mode that wraps at word boundaries instead of characters - Need to be able to set a word wrap length at something other than the window -?FIXED First go-to-line for a file seems to still just go to the beginning of the buffer? + - First go-to-line for a file seems to still just go to the beginning of the buffer? Not sure Allen's right about the slash problem, but either way, we need some way to fix it. - NOTE / IMPORTANT / TODO highlighting? Ability to customize? Whatever. @@ -85,22 +73,18 @@ Crash in buffer_get_line_index_range - it doesn't check for lines == 0, which ca be nice if it go _better_ than Emacs, with no need to manually flow comments, etc. - It should never reindent text in comments that it doesn't know how to indent - eg., in a comment block, it shouldn't decide to move things around if it doesn't know what they are - - Sometimes when I hit [ it inserts a [ _and_ a space? I think this is related to the auto-indent? + - Sometimes when I hit [ it inserts a [ _and_ a space? I think this is related to the auto-indent? <<< Check this again - Buffer management: - I'd like to be able to set a buffer to "auto-revert", so it reloads automatically whenever it changes externally - If you undo back to where there are no changes, the "buffer changed" flag should be cleared - Seems like there's no way to switch to buffers whose names are substrings of other - buffers' names without using the mouse? - - Also, mouse-clicking on buffers doesn't seem to work reliably? Often it just goes to a - blank window? - - Buffer switch display should always show the buffer _it will switch to when you hit return_ - as the first buffer in the list. + buffers' names without using the mouse? <<< Check this again - File system - When switching to a buffer that has changed on disk, notify? Really this can just be some way to query the modification flag and then the customization layer can do it? - - Still can't seem to open a zero-length file? + - Still can't seem to open a zero-length file? <<< Check this again - I'd prefer it if file-open could create new files, and that I could get called on that so I can insert my boilerplate headers on new files - I'd prefer it if file-open deleted per-character instead of deleting entire path sections @@ -641,9 +625,9 @@ CUSTOM_COMMAND_SIG(casey_find_corresponding_file_other_window) CUSTOM_COMMAND_SIG(casey_save_and_make_without_asking) { exec_command(app, change_active_panel); - + Buffer_Summary buffer = {}; - + unsigned int access = AccessAll; for(buffer = app->get_buffer_first(app, access); buffer.exists; @@ -800,6 +784,7 @@ casey_parse_error(Application_Links *app, Buffer_Summary buffer, View_Summary vi break; } } + free(ParsingRegion); return(result); } @@ -1370,7 +1355,6 @@ Casey_Scroll_Velocity casey_scroll_velocity_[16] = {0}; Casey_Scroll_Velocity *casey_scroll_velocity = casey_scroll_velocity_; SCROLL_RULE_SIG(casey_smooth_scroll_rule){ - dt = 1.0f/60.0f; Casey_Scroll_Velocity *velocity = casey_scroll_velocity + view_id; int result = 0; if(is_new_target) @@ -1526,7 +1510,7 @@ extern "C" GET_BINDING_DATA(get_bindings) bind(context, key_page_up, MDFR_NONE, search); bind(context, key_page_down, MDFR_NONE, reverse_search); bind(context, 'm', MDFR_NONE, casey_save_and_make_without_asking); - + // NOTE(allen): Added this so mouse would keep working rougly as before. // Of course now there could be a modal click behavior if that will be useful. // As well as right click. @@ -1635,4 +1619,4 @@ extern "C" GET_BINDING_DATA(get_bindings) end_bind_helper(context); return context->write_total; -} +} \ No newline at end of file diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 605068b1..88e06f18 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -693,14 +693,14 @@ Sys_File_Load_End_Sig(system_file_load_end){ internal Sys_File_Save_Sig(system_file_save){ - b32 success = 0; + b32 success = false; HANDLE file = CreateFile((char*)filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (!file || file == INVALID_HANDLE_VALUE){ - success = 0; + success = false; } else{ BOOL write_result = 0; @@ -712,8 +712,8 @@ Sys_File_Save_Sig(system_file_save){ CloseHandle(file); - if (!write_result || bytes_written != (u32)size){ - success = 0; + if (write_result && bytes_written == (u32)size){ + success = true; } }