From 494eba365a0db03614e277a80ea7b6e35ac9878c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 10 Jun 2016 11:19:29 -0400 Subject: [PATCH] more view debug variables --- 4coder_default_bindings.cpp | 1 + 4coder_default_include.cpp | 32 ++++++--- 4ed_file_view.cpp | 135 +++++++++++++++++++++++++++++++----- 3 files changed, 141 insertions(+), 27 deletions(-) diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index d5f94cd9..7fe9a63b 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -337,6 +337,7 @@ default_keys(Bind_Helper *context){ bind(context, key_down, MDFR_ALT, move_down_10); bind(context, key_back, MDFR_CTRL, backspace_word); + bind(context, key_del, MDFR_CTRL, delete_word); bind(context, key_back, MDFR_ALT, snipe_token_or_word); bind(context, ' ', MDFR_CTRL, set_mark); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 403fe8d0..32b74622 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -476,22 +476,22 @@ CUSTOM_COMMAND_SIG(if0_off){ view = app->get_active_view(app); buffer = app->get_buffer(app, view.buffer_id); - + range = get_range(&view); pos = range.min; - + app->buffer_replace_range(app, &buffer, pos, pos, text1, size1); - + push_parameter(app, par_range_start, pos); push_parameter(app, par_range_end, pos); exec_command(app, cmdid_auto_tab_range); - + app->refresh_view(app, &view); range = get_range(&view); pos = range.max; - + app->buffer_replace_range(app, &buffer, pos, pos, text2, size2); - + push_parameter(app, par_range_start, pos); push_parameter(app, par_range_end, pos); exec_command(app, cmdid_auto_tab_range); @@ -501,14 +501,30 @@ CUSTOM_COMMAND_SIG(backspace_word){ View_Summary view; Buffer_Summary buffer; int pos2, pos1; - + view = app->get_active_view(app); - + pos2 = view.cursor.pos; exec_command(app, seek_alphanumeric_left); app->refresh_view(app, &view); pos1 = view.cursor.pos; + + buffer = app->get_buffer(app, view.buffer_id); + app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0); +} +CUSTOM_COMMAND_SIG(delete_word){ + View_Summary view; + Buffer_Summary buffer; + int pos2, pos1; + + view = app->get_active_view(app); + + pos1 = view.cursor.pos; + exec_command(app, seek_alphanumeric_right); + app->refresh_view(app, &view); + pos2 = view.cursor.pos; + buffer = app->get_buffer(app, view.buffer_id); app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0); } diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index ddd013f3..074fb067 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -3928,9 +3928,20 @@ show_gui_int(GUI_Target *target, String *string, gui_do_text_field(target, *string, string_zero()); } +internal void +show_gui_u64(GUI_Target *target, String *string, + i32 indent_level, i32 h_align, char *message, u64 x){ + string->size = 0; + append_label(string, indent_level, message); + append_padding(string, '-', h_align); + append(string, ' '); + append_u64_to_str(string, x); + gui_do_text_field(target, *string, string_zero()); +} + internal void show_gui_int_int(GUI_Target *target, String *string, - i32 indent_level, i32 h_align, char *message, i32 x, i32 m){ + i32 indent_level, i32 h_align, char *message, i32 x, i32 m){ string->size = 0; append_label(string, indent_level, message); append_padding(string, '-', h_align); @@ -3941,6 +3952,20 @@ show_gui_int_int(GUI_Target *target, String *string, gui_do_text_field(target, *string, string_zero()); } +internal void +show_gui_id(GUI_Target *target, String *string, + i32 indent_level, i32 h_align, char *message, GUI_id id){ + string->size = 0; + append_label(string, indent_level, message); + append_padding(string, '-', h_align); + append(string, " [0]: "); + append_u64_to_str(string, id.id[0]); + append_padding(string, ' ', h_align + 26); + append(string, " [1]: "); + append_u64_to_str(string, id.id[1]); + gui_do_text_field(target, *string, string_zero()); +} + internal void show_gui_float(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message, float x){ @@ -3952,6 +3977,45 @@ show_gui_float(GUI_Target *target, String *string, gui_do_text_field(target, *string, string_zero()); } +internal void +show_gui_scroll(GUI_Target *target, String *string, + i32 indent_level, i32 h_align, char *message, + GUI_Scroll_Vars scroll){ + show_gui_line (target, string, indent_level, 0, message, 0); + show_gui_float(target, string, indent_level+1, h_align, " scroll_y ", scroll.scroll_y); + show_gui_float(target, string, indent_level+1, h_align, " target_y ", scroll.target_y); + show_gui_float(target, string, indent_level+1, h_align, " prev_target_y ", scroll.prev_target_y); + show_gui_float(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_float(target, string, indent_level+1, h_align, " target_x ", scroll.target_x); + show_gui_float(target, string, indent_level+1, h_align, " prev_target_x ", scroll.prev_target_x); +} + +internal void +show_gui_cursor(GUI_Target *target, String *string, + i32 indent_level, i32 h_align, char *message, + Full_Cursor cursor){ + show_gui_line (target, string, indent_level, 0, message, 0); + show_gui_int (target, string, indent_level+1, h_align, " pos ", cursor.pos); + show_gui_int (target, string, indent_level+1, h_align, " line ", cursor.line); + show_gui_int (target, string, indent_level+1, h_align, " column ", cursor.character); + show_gui_float(target, string, indent_level+1, h_align, " unwrapped_x ", cursor.unwrapped_x); + show_gui_float(target, string, indent_level+1, h_align, " unwrapped_y ", cursor.unwrapped_y); + show_gui_float(target, string, indent_level+1, h_align, " wrapped_x ", cursor.wrapped_x); + show_gui_float(target, string, indent_level+1, h_align, " wrapped_y ", cursor.wrapped_y); +} + +internal void +show_gui_region(GUI_Target *target, String *string, + i32 indent_level, i32 h_align, char *message, + i32_Rect region){ + show_gui_line(target, string, indent_level, 0, message, 0); + show_gui_int (target, string, indent_level+1, h_align, " x0", region.x0); + show_gui_int (target, string, indent_level+1, h_align, " y0", region.y0); + show_gui_int (target, string, indent_level+1, h_align, " x1", region.x1); + show_gui_int (target, string, indent_level+1, h_align, " y1", region.y1); +} + struct View_Step_Result{ b32 animating; b32 consume_keys; @@ -4819,18 +4883,24 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su } else{ -#define SHOW_GUI_BLANK() gui_do_text_field(target, empty_str, empty_str) -#define SHOW_GUI_LINE(n, str) show_gui_line(target, &string, n, 0, " " str, 0); -#define SHOW_GUI_STRING(n, h, str, mes) show_gui_line(target, &string, n, h, " " str " ", mes); -#define SHOW_GUI_INT(n, h, str, v) show_gui_int(target, &string, n, h, " " str " ", v); -#define SHOW_GUI_INT_INT(n, h, str, v, m) show_gui_int_int(target, &string, n, h, " " str " ", v, m); -#define SHOW_GUI_FLOAT(n, h, str, v) show_gui_float(target, &string, n, h, " " str " ", v); +#define SHOW_GUI_BLANK(n) show_gui_line(target, &string, n, 0, "", 0) +#define SHOW_GUI_LINE(n, str) show_gui_line(target, &string, n, 0, " " str, 0) +#define SHOW_GUI_STRING(n, h, str, mes) show_gui_line(target, &string, n, h, " " str " ", mes) +#define SHOW_GUI_INT(n, h, str, v) show_gui_int(target, &string, n, h, " " str " ", v) +#define SHOW_GUI_INT_INT(n, h, str, v, m) show_gui_int_int(target, &string, n, h, " " str " ", v, m) +#define SHOW_GUI_U64(n, h, str, v) show_gui_u64(target, &string, n, h, " " str " ", v) +#define SHOW_GUI_ID(n, h, str, v) show_gui_id(target, &string, n, h, " " str, v) +#define SHOW_GUI_FLOAT(n, h, str, v) show_gui_float(target, &string, n, h, " " str " ", v) #define SHOW_GUI_BOOL(n, h, str, v) do { if (v) { show_gui_line(target, &string, n, h, " " str " ", "true"); }\ else { show_gui_line(target, &string, n, h, " " str " ", "false"); } } while(false) +#define SHOW_GUI_SCROLL(n, h, str, v) show_gui_scroll(target, &string, n, h, " " str, v) +#define SHOW_GUI_CURSOR(n, h, str, v) show_gui_cursor(target, &string, n, h, " " str, v) +#define SHOW_GUI_REGION(n, h, str, v) show_gui_region(target, &string, n, h, " " str, v) + i32 h_align = 31; - SHOW_GUI_BLANK(); + SHOW_GUI_BLANK(0); { Command_Map *map = view_ptr->map; @@ -4854,7 +4924,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su } } - SHOW_GUI_BLANK(); + SHOW_GUI_BLANK(0); SHOW_GUI_LINE(1, "file data:"); SHOW_GUI_BOOL(2, h_align, "has file", view_ptr->file_data.file); SHOW_GUI_BOOL(2, h_align, "show temp highlight", view_ptr->file_data.show_temp_highlight); @@ -4869,18 +4939,45 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su GUI_Scroll_Vars scroll = *view_ptr->current_scroll; - SHOW_GUI_BLANK(); - SHOW_GUI_LINE(1, "current scroll:"); - SHOW_GUI_FLOAT(2, h_align, "scroll_y", scroll.scroll_y); - SHOW_GUI_FLOAT(2, h_align, "target_y", scroll.target_y); - SHOW_GUI_FLOAT(2, h_align, "prev_target_y", scroll.prev_target_y); - SHOW_GUI_FLOAT(2, h_align, "max_y", scroll.max_y); + SHOW_GUI_BLANK(0); + SHOW_GUI_LINE(1, "recent file data"); + { + i32 recent_index = 0; + Recent_File_Data *recent = view_ptr->recent + recent_index; + + { + SHOW_GUI_INT (2, h_align, "recent", recent_index); + SHOW_GUI_U64 (3, h_align, "absolute buffer id", recent->unique_buffer_id); + SHOW_GUI_BLANK (3); + SHOW_GUI_SCROLL(3, h_align, "scroll:", recent->scroll); + SHOW_GUI_BLANK (3); + SHOW_GUI_CURSOR(3, h_align, "cursor:", recent->cursor); + SHOW_GUI_BLANK (3); + SHOW_GUI_INT (3, h_align, "mark", recent->mark); + SHOW_GUI_FLOAT (3, h_align, "preferred_x", recent->preferred_x); + SHOW_GUI_INT (3, h_align, "scroll_i", recent->scroll_i); + } + } - SHOW_GUI_FLOAT(2, h_align, "scroll_x", scroll.scroll_x); - SHOW_GUI_FLOAT(2, h_align, "target_x", scroll.target_x); - SHOW_GUI_FLOAT(2, h_align, "prev_target_x", scroll.prev_target_x); + SHOW_GUI_BLANK (0); + SHOW_GUI_SCROLL(1, h_align, "curent scroll:", scroll); - // TODO(allen): cursor + SHOW_GUI_BLANK (0); + SHOW_GUI_LINE (1, "gui target"); + SHOW_GUI_INT_INT(2, h_align, "gui partition", + view_ptr->gui_target.push.pos, + view_ptr->gui_target.push.max); + SHOW_GUI_ID (2, h_align, "active", view_ptr->gui_target.active); + SHOW_GUI_ID (2, h_align, "mouse_hot", view_ptr->gui_target.mouse_hot); + SHOW_GUI_ID (2, h_align, "auto_hot", view_ptr->gui_target.auto_hot); + SHOW_GUI_ID (2, h_align, "hover", view_ptr->gui_target.hover); + SHOW_GUI_SCROLL (2, h_align, "scroll_original", view_ptr->gui_target.scroll_original); + SHOW_GUI_REGION (2, h_align, "region_original", view_ptr->gui_target.region_original); + SHOW_GUI_SCROLL (2, h_align, "scroll_updated", view_ptr->gui_target.scroll_updated); + SHOW_GUI_REGION (2, h_align, "region_updated", view_ptr->gui_target.region_updated); + + + SHOW_GUI_SCROLL (1, h_align, "gui scroll", view_ptr->gui_scroll); } }