centers view on cursor; cmdid_center_view in customization API\n"
+ "-Set font size on command line with -f N, N = 16 by default\n\n"
+ );
+
+ do_feedback_message(system, models, welcome);
+ }
+
+ // NOTE(allen): panel resizing
+ switch (vars->state){
+ case APP_STATE_EDIT:
+ {
+ if (input->mouse.press_l && mouse_on_divider){
+ vars->state = APP_STATE_RESIZING;
+ Divider_And_ID div = layout_get_divider(&models->layout, mouse_divider_id);
+ vars->resizing.divider = div.divider;
+
+ f32 min = 0;
+ f32 max = 0;
+ {
+ f32 mid = layout_get_position(&models->layout, mouse_divider_id);
+ if (mouse_divider_vertical){
+ max = (f32)models->layout.full_width;
+ }
+ else{
+ max = (f32)models->layout.full_height;
+ }
+
+ i32 divider_id = div.id;
+ do{
+ Divider_And_ID other_div = layout_get_divider(&models->layout, divider_id);
+ b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
+ f32 pos = layout_get_position(&models->layout, divider_id);
+ if (divider_match && pos > mid && pos < max){
+ max = pos;
+ }
+ else if (divider_match && pos < mid && pos > min){
+ min = pos;
+ }
+ divider_id = other_div.divider->parent;
+ }while(divider_id != -1);
+
+ Temp_Memory temp = begin_temp_memory(&models->mem.part);
+ i32 *divider_stack = push_array(&models->mem.part, i32, models->layout.panel_count);
+ i32 top = 0;
+ divider_stack[top++] = div.id;
+
+ while (top > 0){
+ --top;
+ Divider_And_ID other_div = layout_get_divider(&models->layout, divider_stack[top]);
+ b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
+ f32 pos = layout_get_position(&models->layout, divider_stack[top]);
+ if (divider_match && pos > mid && pos < max){
+ max = pos;
+ }
+ else if (divider_match && pos < mid && pos > min){
+ min = pos;
+ }
+ if (other_div.divider->child1 != -1){
+ divider_stack[top++] = other_div.divider->child1;
+ }
+ if (other_div.divider->child2 != -1){
+ divider_stack[top++] = other_div.divider->child2;
+ }
+ }
+
+ end_temp_memory(temp);
+ }
+
+ vars->resizing.min = 0.f;
+ vars->resizing.max = 1.f;
+ }
+ }break;
+
+ case APP_STATE_RESIZING:
+ {
+ 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);
+
+ if (divider->pos < vars->resizing.min){
+ divider->pos = vars->resizing.min;
+ }
+ else if (divider->pos > vars->resizing.max){
+ divider->pos = vars->resizing.max - 1;
+ }
+
+ layout_fix_all_panels(&models->layout);
+ }
+ else{
+ vars->state = APP_STATE_EDIT;
+ }
+ }break;
+ }
+
+ if (mouse_in_edit_area && mouse_panel != 0 && input->mouse.press_l){
+ models->layout.active_panel = (i32)(mouse_panel - models->layout.panels);
+ }
+
+ update_command_data(vars, cmd);
+
+ end_temp_memory(param_stack_temp);
+
+ // NOTE(allen): send resize messages to panels that have changed size
+ {
+ Panel *panel = 0, *used_panels = 0;
+
+ used_panels = &models->layout.used_sentinel;
+ for (dll_items(panel, used_panels)){
+ View *view = panel->view;
+ i32_Rect prev = view->file_region_prev;
+ i32_Rect region = view->file_region;
+ if (!rect_equal(prev, region)){
+ remeasure_file_view(system, panel->view);
+ }
+ view->file_region_prev = region;
+ }
+ }
+
+ // NOTE(allen): send style change messages if the style has changed
+ if (models->global_font.font_changed){
+ models->global_font.font_changed = 0;
+
+ File_Node *node, *used_nodes;
+ Editing_File *file;
+ Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
+ float *advance_data = 0;
+ if (font) advance_data = font->advance_data;
+
+ used_nodes = &models->working_set.used_sentinel;
+ for (dll_items(node, used_nodes)){
+ file = (Editing_File*)node;
+ file_measure_starts_widths(system, &models->mem.general, &file->state.buffer, advance_data);
+ }
+
+ Panel *panel, *used_panels;
+ used_panels = &models->layout.used_sentinel;
+ for (dll_items(panel, used_panels)){
+ remeasure_file_view(system, panel->view);
+ }
+ }
+
+ // NOTE(allen): post scroll vars back to the view's gui targets
+ {
+ Panel *panel = 0, *used_panels = 0;
+
+ used_panels = &models->layout.used_sentinel;
+ for (dll_items(panel, used_panels)){
+ Assert(panel->view);
+ view_end_cursor_scroll_updates(panel->view);
+ }
+ }
+
+ // NOTE(allen): rendering
+ {
+ begin_render_section(target, system);
+
+ target->clip_top = -1;
+ draw_push_clip(target, rect_from_target(target));
+
+ // NOTE(allen): render the panels
+ Panel *panel, *used_panels;
+ used_panels = &models->layout.used_sentinel;
+ for (dll_items(panel, used_panels)){
+ i32_Rect full = panel->full;
+ i32_Rect inner = panel->inner;
+
+ View *view = panel->view;
+ Style *style = main_style(models);
+
+ b32 active = (panel == cmd->panel);
+ u32 back_color = style->main.back_color;
+ draw_rectangle(target, full, back_color);
+
+ draw_push_clip(target, panel->inner);
+ do_render_file_view(system, view, cmd->view,
+ panel->inner, active, target, &dead_input);
+ draw_pop_clip(target);
+
+ u32 margin_color;
+ if (active){
+ margin_color = style->main.margin_active_color;
+ }
+ else if (panel == mouse_panel){
+ margin_color = style->main.margin_hover_color;
+ }
+ else{
+ margin_color = style->main.margin_color;
+ }
+ draw_rectangle(target, i32R(full.x0, full.y0, full.x1, inner.y0), margin_color);
+ draw_rectangle(target, i32R(full.x0, inner.y1, full.x1, full.y1), margin_color);
+ draw_rectangle(target, i32R(full.x0, inner.y0, inner.x0, inner.y1), margin_color);
+ draw_rectangle(target, i32R(inner.x1, inner.y0, full.x1, inner.y1), margin_color);
+ }
+
+ end_render_section(target, system);
+ }
+
+ // NOTE(allen): get cursor type
+ if (mouse_in_edit_area){
+ app_result.mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
+ }
+ else if (mouse_in_margin_area){
+ if (mouse_on_divider){
+ if (mouse_divider_vertical){
+ app_result.mouse_cursor_type = APP_MOUSE_CURSOR_LEFTRIGHT;
+ }
+ else{
+ app_result.mouse_cursor_type = APP_MOUSE_CURSOR_UPDOWN;
+ }
+ }
+ else{
+ app_result.mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
+ }
+ }
+ models->prev_mouse_panel = mouse_panel;
+
+ app_result.lctrl_lalt_is_altgr = models->settings.lctrl_lalt_is_altgr;
+ app_result.perform_kill = !models->keep_playing;
+
+ *result = app_result;
+
+ Assert(general_memory_check(&models->mem.general));
+
+ // end-of-app_step
+}
+
+external App_Get_Functions_Sig(app_get_functions){
+ App_Functions result = {};
+
+ result.read_command_line = app_read_command_line;
+ result.init = app_init;
+ result.step = app_step;
+
+ return(result);
+}
+
+// BOTTOM
+
diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp
index 861754cc..1cb66485 100644
--- a/4ed_api_implementation.cpp
+++ b/4ed_api_implementation.cpp
@@ -67,9 +67,9 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_
view->buffer_id = buffer_id;
- view->mark = view_compute_cursor_from_pos(vptr, vptr->recent->mark);
- view->cursor = vptr->recent->cursor;
- view->preferred_x = vptr->recent->preferred_x;
+ view->mark = view_compute_cursor_from_pos(vptr, vptr->recent.mark);
+ view->cursor = vptr->recent.cursor;
+ view->preferred_x = vptr->recent.preferred_x;
view->file_region = vptr->file_region;
view->scroll_vars = *vptr->current_scroll;
@@ -1193,12 +1193,12 @@ DOC_SEE(Buffer_Seek)
if (seek.type == buffer_seek_line_char && seek.character <= 0){
seek.character = 1;
}
- vptr->recent->cursor = view_compute_cursor(vptr, seek);
+ vptr->recent.cursor = view_compute_cursor(vptr, seek);
if (set_preferred_x){
- vptr->recent->preferred_x = view_get_cursor_x(vptr);
+ vptr->recent.preferred_x = view_get_cursor_x(vptr);
}
fill_view_summary(view, vptr, cmd);
- file->state.cursor_pos = vptr->recent->cursor.pos;
+ file->state.cursor_pos = vptr->recent.cursor.pos;
}
}
@@ -1225,10 +1225,10 @@ DOC_SEE(Buffer_Seek)
result = true;
if (seek.type != buffer_seek_pos){
cursor = view_compute_cursor(vptr, seek);
- vptr->recent->mark = cursor.pos;
+ vptr->recent.mark = cursor.pos;
}
else{
- vptr->recent->mark = seek.pos;
+ vptr->recent.mark = seek.pos;
}
fill_view_summary(view, vptr, cmd);
}
diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp
index be19db1a..2fde5d81 100644
--- a/4ed_file_view.cpp
+++ b/4ed_file_view.cpp
@@ -232,7 +232,7 @@ struct View{
i32_Rect file_region;
i32_Rect scroll_region;
- Recent_File_Data recent[16];
+ Recent_File_Data recent;
GUI_Scroll_Vars *current_scroll;
@@ -1499,7 +1499,7 @@ view_get_cursor_pos(View *view){
result = view->file_data.temp_highlight.pos;
}
else{
- result = view->recent->cursor.pos;
+ result = view->recent.cursor.pos;
}
return result;
}
@@ -1512,7 +1512,7 @@ view_get_cursor_x(View *view){
cursor = &view->file_data.temp_highlight;
}
else{
- cursor = &view->recent->cursor;
+ cursor = &view->recent.cursor;
}
if (view->file_data.unwrapped_lines){
result = cursor->unwrapped_x;
@@ -1529,7 +1529,7 @@ view_get_cursor_y(View *view){
f32 result;
if (view->file_data.show_temp_highlight) cursor = &view->file_data.temp_highlight;
- else cursor = &view->recent->cursor;
+ else cursor = &view->recent.cursor;
if (view->file_data.unwrapped_lines) result = cursor->unwrapped_y;
else result = cursor->wrapped_y;
@@ -1594,8 +1594,8 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll){
else{
cursor_y -= line_height;
}
- view->recent->cursor =
- view_compute_cursor_from_xy(view, view->recent->preferred_x, cursor_y);
+ view->recent.cursor =
+ view_compute_cursor_from_xy(view, view->recent.preferred_x, cursor_y);
}
}
@@ -1660,51 +1660,21 @@ view_set_file(View *view, Editing_File *file, Models *models){
view->file_data.file = file;
if (file){
- u64 unique_buffer_id = file->unique_buffer_id;
- Recent_File_Data *recent = view->recent;
- Recent_File_Data temp_recent = {0};
- i32 i = 0;
- i32 max = ArrayCount(view->recent)-1;
- b32 found_recent_entry = 0;
-
view->file_data.unwrapped_lines = file->settings.unwrapped_lines;
- for (; i < max; ++i, ++recent){
- if (recent->unique_buffer_id == unique_buffer_id){
- temp_recent = *recent;
- memmove(view->recent+1, view->recent, sizeof(*recent)*i);
- view->recent[0] = temp_recent;
- found_recent_entry = 1;
- break;
- }
- }
+ u64 unique_buffer_id = file->unique_buffer_id;
+ Recent_File_Data *recent = &view->recent;
- if (found_recent_entry){
- if (file_is_ready(file)){
- view_measure_wraps(&models->mem.general, view);
- view->recent->cursor = view_compute_cursor_from_pos(view, view->recent->cursor.pos);
- view->recent->scroll.max_y = view_compute_max_target_y(view);
-
- view_move_view_to_cursor(view, &view->recent->scroll);
- }
- }
- else{
- i = 15;
- recent = view->recent + i;
- memmove(view->recent+1, view->recent, sizeof(*recent)*i);
- view->recent[0] = recent_file_data_zero();
+ view->recent = recent_file_data_zero();
+ recent->unique_buffer_id = unique_buffer_id;
+
+ if (file_is_ready(file)){
+ view_measure_wraps(&models->mem.general, view);
+ view->recent.cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos);
+ view->recent.scroll.max_y = view_compute_max_target_y(view);
- recent = view->recent;
- recent->unique_buffer_id = unique_buffer_id;
-
- if (file_is_ready(file)){
- view_measure_wraps(&models->mem.general, view);
- view->recent->cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos);
- view->recent->scroll.max_y = view_compute_max_target_y(view);
-
- view_move_view_to_cursor(view, &view->recent->scroll);
- view->reinit_scrolling = 1;
- }
+ view_move_view_to_cursor(view, &view->recent.scroll);
+ view->reinit_scrolling = 1;
}
}
}
@@ -1718,24 +1688,24 @@ internal Relative_Scrolling
view_get_relative_scrolling(View *view){
Relative_Scrolling result;
f32 cursor_y = view_get_cursor_y(view);
- result.scroll_y = cursor_y - view->recent->scroll.scroll_y;
- result.target_y = cursor_y - view->recent->scroll.target_y;
+ result.scroll_y = cursor_y - view->recent.scroll.scroll_y;
+ result.target_y = cursor_y - view->recent.scroll.target_y;
return(result);
}
internal void
view_set_relative_scrolling(View *view, Relative_Scrolling scrolling){
f32 cursor_y = view_get_cursor_y(view);
- view->recent->scroll.scroll_y = cursor_y - scrolling.scroll_y;
- view->recent->scroll.target_y =
+ view->recent.scroll.scroll_y = cursor_y - scrolling.scroll_y;
+ view->recent.scroll.target_y =
ROUND32(clamp_bottom(0.f, cursor_y - scrolling.target_y));
}
inline void
view_cursor_move(View *view, Full_Cursor cursor){
- view->recent->cursor = cursor;
- view->recent->preferred_x = view_get_cursor_x(view);
- view->file_data.file->state.cursor_pos = view->recent->cursor.pos;
+ view->recent.cursor = cursor;
+ view->recent.preferred_x = view_get_cursor_x(view);
+ view->file_data.file->state.cursor_pos = view->recent.cursor.pos;
view->file_data.show_temp_highlight = 0;
}
@@ -1987,9 +1957,9 @@ file_edit_cursor_fix(System_Functions *system,
view = panel->view;
if (view->file_data.file == file){
view_measure_wraps(general, view);
- write_cursor_with_index(cursors, &cursor_count, view->recent->cursor.pos);
- write_cursor_with_index(cursors, &cursor_count, view->recent->mark - 1);
- write_cursor_with_index(cursors, &cursor_count, view->recent->scroll_i - 1);
+ write_cursor_with_index(cursors, &cursor_count, view->recent.cursor.pos);
+ write_cursor_with_index(cursors, &cursor_count, view->recent.mark - 1);
+ write_cursor_with_index(cursors, &cursor_count, view->recent.scroll_i - 1);
}
}
@@ -2011,24 +1981,26 @@ file_edit_cursor_fix(System_Functions *system,
view = panel->view;
if (view && view->file_data.file == file){
view_cursor_move(view, cursors[cursor_count++].pos);
- view->recent->preferred_x = view_get_cursor_x(view);
+ view->recent.preferred_x = view_get_cursor_x(view);
- view->recent->mark = cursors[cursor_count++].pos + 1;
+ view->recent.mark = cursors[cursor_count++].pos + 1;
i32 new_scroll_i = cursors[cursor_count++].pos + 1;
- if (view->recent->scroll_i != new_scroll_i){
- view->recent->scroll_i = new_scroll_i;
- temp_cursor = view_compute_cursor_from_pos(view, view->recent->scroll_i);
- y_offset = MOD(view->recent->scroll.scroll_y, view->line_height);
+ if (view->recent.scroll_i != new_scroll_i){
+ view->recent.scroll_i = new_scroll_i;
+ temp_cursor = view_compute_cursor_from_pos(view, view->recent.scroll_i);
+ y_offset = MOD(view->recent.scroll.scroll_y, view->line_height);
if (view->file_data.unwrapped_lines){
y_position = temp_cursor.unwrapped_y + y_offset;
- view->recent->scroll.target_y += ROUND32(y_position - view->recent->scroll.scroll_y);
- view->recent->scroll.scroll_y = y_position;
+ view->recent.scroll.target_y +=
+ ROUND32(y_position - view->recent.scroll.scroll_y);
+ view->recent.scroll.scroll_y = y_position;
}
else{
y_position = temp_cursor.wrapped_y + y_offset;
- view->recent->scroll.target_y += ROUND32(y_position - view->recent->scroll.scroll_y);
- view->recent->scroll.scroll_y = y_position;
+ view->recent.scroll.target_y +=
+ ROUND32(y_position - view->recent.scroll.scroll_y);
+ view->recent.scroll.scroll_y = y_position;
}
}
}
@@ -2267,7 +2239,7 @@ view_undo_redo(System_Functions *system,
file_do_single_edit(system, models, file, spec, hist_normal);
view_cursor_move(view, step.edit.start + step.edit.len);
- view->recent->mark = view->recent->cursor.pos;
+ view->recent.mark = view->recent.cursor.pos;
Style *style = main_style(models);
view_post_paste_effect(view, 0.333f, step.edit.start, step.edit.len,
@@ -2399,7 +2371,7 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
view_cursor_move(view, step.edit.start + step.edit.len);
break;
}
- view->recent->mark = view->recent->cursor.pos;
+ view->recent.mark = view->recent.cursor.pos;
}
else{
TentativeAssert(spec.step.special_type == 1);
@@ -2564,8 +2536,11 @@ view_clean_whitespace(System_Functions *system, Models *models, View *view){
char *inv_str = (char*)part->base + part->pos;
Edit_Spec spec =
- file_compute_whitespace_edit(mem, file, view->recent->cursor.pos, edits, str_base, str_size,
- inverse_array, inv_str, part->max - part->pos, edit_count);
+ file_compute_whitespace_edit(mem, file,
+ view->recent.cursor.pos,
+ edits, str_base, str_size,
+ inverse_array, inv_str,
+ part->max - part->pos, edit_count);
file_do_white_batch_edit(system, models, view->file_data.file, spec, hist_normal);
}
@@ -3056,8 +3031,8 @@ remeasure_file_view(System_Functions *system, View *view){
Relative_Scrolling relative = view_get_relative_scrolling(view);
view_measure_wraps(&view->persistent.models->mem.general, view);
if (view->file_data.show_temp_highlight == 0){
- view_cursor_move(view, view->recent->cursor.pos);
- view->recent->preferred_x = view_get_cursor_x(view);
+ view_cursor_move(view, view->recent.cursor.pos);
+ view->recent.preferred_x = view_get_cursor_x(view);
}
view_set_relative_scrolling(view, relative);
}
@@ -3114,8 +3089,8 @@ view_show_file(View *view){
view->map = get_map(view->persistent.models, mapid_global);
}
view->showing_ui = VUI_None;
- view->current_scroll = &view->recent->scroll;
- view->recent->scroll.max_y = view_compute_max_target_y(view);
+ view->current_scroll = &view->recent.scroll;
+ view->recent.scroll.max_y = view_compute_max_target_y(view);
view->changed_context_in_step = 1;
}
@@ -3528,13 +3503,13 @@ view_reinit_scrolling(View *view){
target_y = clamp_bottom(0, FLOOR32(cursor_y - h*.5f));
}
- view->recent->scroll.target_y = target_y;
- view->recent->scroll.scroll_y = (f32)target_y;
- view->recent->scroll.prev_target_y = -1000;
+ view->recent.scroll.target_y = target_y;
+ view->recent.scroll.scroll_y = (f32)target_y;
+ view->recent.scroll.prev_target_y = -1000;
- view->recent->scroll.target_x = target_x;
- view->recent->scroll.scroll_x = (f32)target_x;
- view->recent->scroll.prev_target_x = -1000;
+ view->recent.scroll.target_x = target_x;
+ view->recent.scroll.scroll_x = (f32)target_x;
+ view->recent.scroll.prev_target_x = -1000;
}
enum CursorScroll_State{
@@ -3597,14 +3572,14 @@ view_end_cursor_scroll_updates(View *view){
case CursorScroll_Cursor:
case CursorScroll_Cursor|CursorScroll_Scroll:
if (view->gui_target.did_file){
- view->recent->scroll.max_y = view_compute_max_target_y(view);
+ view->recent.scroll.max_y = view_compute_max_target_y(view);
}
view_move_view_to_cursor(view, view->current_scroll);
gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region);
break;
case CursorScroll_Scroll:
- view_move_cursor_to_view(view, view->recent->scroll);
+ view_move_cursor_to_view(view, view->recent.scroll);
gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region);
break;
}
@@ -4073,11 +4048,11 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
scroll_context.id[1] = view->showing_ui;
scroll_context.id[0] = (u64)(view->file_data.file);
- view->current_scroll = &view->recent->scroll;
+ view->current_scroll = &view->recent.scroll;
gui_get_scroll_vars(target, scroll_context,
- &view->recent->scroll, &view->scroll_region);
+ &view->recent.scroll, &view->scroll_region);
- gui_begin_scrollable(target, scroll_context, view->recent->scroll,
+ gui_begin_scrollable(target, scroll_context, view->recent.scroll,
delta, show_scrollbar);
gui_do_file(target);
gui_end_scrollable(target);
@@ -4945,21 +4920,17 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
SHOW_GUI_BLANK(0);
SHOW_GUI_LINE(1, "recent file data");
{
- i32 recent_index = 0;
- Recent_File_Data *recent = view_ptr->recent + recent_index;
+ Recent_File_Data *recent = &view_ptr->recent;
- {
- 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_U64 (2, h_align, "absolute buffer id", recent->unique_buffer_id);
+ SHOW_GUI_BLANK (2);
+ SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll);
+ SHOW_GUI_BLANK (2);
+ SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor);
+ SHOW_GUI_BLANK (2);
+ SHOW_GUI_INT (2, h_align, "mark", recent->mark);
+ SHOW_GUI_FLOAT (2, h_align, "preferred_x", recent->preferred_x);
+ SHOW_GUI_INT (2, h_align, "scroll_i", recent->scroll_i);
}
SHOW_GUI_BLANK (0);
@@ -5009,7 +4980,7 @@ internal f32
view_get_scroll_y(View *view){
f32 v;
if (view->showing_ui == VUI_None){
- v = view->recent->scroll.scroll_y;
+ v = view->recent.scroll.scroll_y;
}
else{
v = view->gui_scroll.scroll_y;
@@ -5344,8 +5315,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
Buffer_Render_Options opts = {};
f32 *wraps = view->file_data.line_wrap_y;
- f32 scroll_x = view->recent->scroll.scroll_x;
- f32 scroll_y = view->recent->scroll.scroll_y;
+ f32 scroll_x = view->recent.scroll.scroll_x;
+ f32 scroll_y = view->recent.scroll.scroll_y;
// NOTE(allen): For now we will temporarily adjust scroll_y to try
// to prevent the view moving around until floating sections are added
@@ -5358,7 +5329,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
(f32)max_x,
advance_data, (f32)line_height);
- view->recent->scroll_i = render_cursor.pos;
+ view->recent.scroll_i = render_cursor.pos;
buffer_get_render_data(&file->state.buffer, items, max, &count,
(f32)rect.x0, (f32)rect.y0,
@@ -5380,7 +5351,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
at_cursor_color = style->main.at_highlight_color;
}
else{
- cursor_begin = view->recent->cursor.pos;
+ cursor_begin = view->recent.cursor.pos;
cursor_end = cursor_begin + 1;
cursor_color = style->main.cursor_color;
at_cursor_color = style->main.at_cursor_color;
@@ -5470,7 +5441,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
char_color = color_blend(char_color, fade_amount, fade_color);
- if (ind == view->recent->mark && prev_ind != ind){
+ if (ind == view->recent.mark && prev_ind != ind){
draw_rectangle_outline(target, char_rect, mark_color);
}
if (item->glyphid != 0){
@@ -5588,9 +5559,9 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re
char line_number_space[30];
String line_number = make_fixed_width_string(line_number_space);
append(&line_number, " L#");
- append_int_to_str(&line_number, view->recent->cursor.line);
+ append_int_to_str(&line_number, view->recent.cursor.line);
append(&line_number, " C#");
- append_int_to_str(&line_number, view->recent->cursor.character);
+ append_int_to_str(&line_number, view->recent.cursor.character);
intbar_draw_string(target, &bar, line_number, base_color);
@@ -6214,7 +6185,7 @@ inline void
view_change_size(General_Memory *general, View *view){
if (view->file_data.file){
view_measure_wraps(general, view);
- view->recent->cursor = view_compute_cursor_from_pos(view, view->recent->cursor.pos);
+ view->recent.cursor = view_compute_cursor_from_pos(view, view->recent.cursor.pos);
}
}
@@ -6237,7 +6208,7 @@ live_set_alloc_view(Live_Views *live_set, Panel *panel, Models *models){
result.view->panel = panel;
result.view->persistent.models = models;
- result.view->current_scroll = &result.view->recent->scroll;
+ result.view->current_scroll = &result.view->recent.scroll;
init_query_set(&result.view->query_set);
diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp
index b6b219ee..bbb122d3 100644
--- a/4ed_metagen.cpp
+++ b/4ed_metagen.cpp
@@ -657,7 +657,7 @@ perform_doc_parse(String doc_string, Documentation *doc){
}
}
else{
- printf("warning: invalid doc note %.*s\n", doc_note.size, doc_note.str);
+ fprintf(stderr, "warning: invalid doc note %.*s\n", doc_note.size, doc_note.str);
}
}
}while(keep_parsing);
@@ -858,7 +858,7 @@ generate_custom_headers(){
function_set.name[sig_count] = string_zero();
function_set.args[sig_count] = string_zero();
// TODO(allen): get warning line numbers
- printf("custom_api_spec.cpp(???) : generator warning : invalid function signature\n");
+ fprintf(stderr, "custom_api_spec.cpp(???) : generator warning : invalid function signature\n");
}
++sig_count;
}
@@ -997,13 +997,15 @@ generate_custom_headers(){
#define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;"
-#define BACK_COLOR "#FAFAFA"
-#define TEXT_COLOR "#0D0D0D"
-#define CODE_BACK "#DFDFDF"
-#define POP_COLOR_1 "#309030"
-#define POP_BACK_1 "#E0FFD0"
-#define POP_COLOR_2 "#007070"
-#define POP_COLOR_3 "#005000"
+#define BACK_COLOR "#FAFAFA"
+#define TEXT_COLOR "#0D0D0D"
+#define CODE_BACK "#DFDFDF"
+
+#define POP_COLOR_1 "#309030"
+#define POP_BACK_1 "#E0FFD0"
+#define VISITED_LINK "#A0C050"
+
+#define POP_COLOR_2 "#005000"
fprintf(file,
"\n"
@@ -1032,7 +1034,7 @@ generate_custom_headers(){
"text-decoration: none; "
"}\n"
"a:visited { "
- "color: " POP_COLOR_2 "; "
+ "color: " VISITED_LINK "; "
"}\n"
"a:hover { "
"background: " POP_BACK_1 "; "
@@ -1050,7 +1052,7 @@ generate_custom_headers(){
"}\n"
"li:before { "
"content: \"4\"; "
- "color: " POP_COLOR_3 "; "
+ "color: " POP_COLOR_2 "; "
"font-family:\"Webdings\"; "
"}\n"
@@ -1138,7 +1140,7 @@ generate_custom_headers(){
if (function_set.doc_string[i].size == 0){
fprintf(file, "No documentation generated for this function, assume it is non-public.\n");
- printf("warning: no documentation string for %.*s\n", name.size, name.str);
+ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
}
#define DOC_HEAD_OPEN ""
@@ -1220,15 +1222,10 @@ generate_custom_headers(){
int main(){
char *filename = 0;
-
+
filename = generate_keycode_enum();
- printf("gen success: %s\n", filename);
-
filename = generate_style();
- printf("gen success: %s\n", filename);
-
filename = generate_custom_headers();
- printf("gen success: %s\n", filename);
}
// BOTTOM
diff --git a/README.txt b/README.txt
index b20da405..78328251 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,4 @@
-Distribution Date: 24.6.2016 (dd.mm.yyyy)
+Distribution Date: 29.6.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!
diff --git a/SUPERREADME.txt b/SUPERREADME.txt
index ee386676..e5a9cb7e 100644
--- a/SUPERREADME.txt
+++ b/SUPERREADME.txt
@@ -1,4 +1,4 @@
-Distribution Date: 24.6.2016 (dd.mm.yyyy)
+Distribution Date: 29.6.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!
diff --git a/power/4coder_default_building.cpp b/power/4coder_default_building.cpp
index 5c5b4901..d8cf3eea 100644
--- a/power/4coder_default_building.cpp
+++ b/power/4coder_default_building.cpp
@@ -13,6 +13,13 @@
// Basic Build Behavior
//
+struct Prev_Jump{
+ int buffer_id;
+ int line;
+};
+
+static Prev_Jump prev_location = {0};
+
CUSTOM_COMMAND_SIG(build_in_build_panel){
Buffer_Summary buffer =
app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
@@ -32,6 +39,8 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
app->set_active_view(app, &build_view);
exec_command(app, build_search);
app->set_active_view(app, &original_view);
+
+ prev_location = {0};
}
// TODO(allen): This is a bit nasty. I want a system for picking
@@ -203,32 +212,36 @@ jump_to_location(Application_Links *app, View_Summary *view, Jump_Location *l){
}
static int
-msvc_parse_error(String line, Jump_Location *location, int *colon_char){
+msvc_parse_error(String line, Jump_Location *location,
+ int skip_sub_errors, int *colon_char){
int result = false;
int colon_pos = find(line, 0, ')');
colon_pos = find(line, colon_pos, ':');
if (colon_pos < line.size){
String location_str = substr(line, 0, colon_pos);
- location_str = skip_chop_whitespace(location_str);
- int paren_pos = find(location_str, 0, '(');
- if (paren_pos < location_str.size){
- String file = substr(location_str, 0, paren_pos);
- file = skip_chop_whitespace(file);
+ if (!(skip_sub_errors && location_str.str[0] == ' ')){
+ location_str = skip_chop_whitespace(location_str);
- int close_pos = find(location_str, 0, ')') + 1;
- if (close_pos == location_str.size && file.size > 0){
- String line_number = substr(location_str,
- paren_pos+1,
- close_pos-paren_pos-2);
- line_number = skip_chop_whitespace(line_number);
+ int paren_pos = find(location_str, 0, '(');
+ if (paren_pos < location_str.size){
+ String file = substr(location_str, 0, paren_pos);
+ file = skip_chop_whitespace(file);
- if (line_number.size > 0){
- copy(&location->file, file);
- location->line = str_to_int(line_number);
- *colon_char = colon_pos;
- result = true;
+ int close_pos = find(location_str, 0, ')') + 1;
+ if (close_pos == location_str.size && file.size > 0){
+ String line_number = substr(location_str,
+ paren_pos+1,
+ close_pos-paren_pos-2);
+ line_number = skip_chop_whitespace(line_number);
+
+ if (line_number.size > 0){
+ copy(&location->file, file);
+ location->line = str_to_int(line_number);
+ *colon_char = colon_pos;
+ result = true;
+ }
}
}
}
@@ -243,6 +256,7 @@ msvc_next_error(Application_Links *app,
void *memory, int memory_size,
Jump_Location *location,
int direction,
+ int skip_sub_errors,
int *colon_char){
int result = false;
@@ -250,7 +264,7 @@ msvc_next_error(Application_Links *app,
String line_str = make_string(memory, 0, memory_size);
for (;;){
if (read_line(app, comp_out, line, &line_str)){
- if (msvc_parse_error(line_str, location, colon_char)){
+ if (msvc_parse_error(line_str, location, skip_sub_errors, colon_char)){
result = true;
break;
}
@@ -270,41 +284,96 @@ msvc_next_error(Application_Links *app,
return(result);
}
-static void
-msvc_goto_error(Application_Links *app, int direction){
+static int
+msvc_goto_error(Application_Links *app, int direction, int skip_sub_errors, Jump_Location *loc){
+ int result = false;
View_Summary active_view = app->get_active_view(app, AccessAll);
+ Jump_Location location = {0};
Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
if (buffer.exists){
View_Summary view = get_first_view_with_buffer(app, buffer.buffer_id);
int line = view.cursor.line;
int ms = app->memory_size/2;
- Jump_Location location = {0};
location.file = make_string(app->memory, 0, ms);
void *m = (char*)app->memory + ms;
int colon_char = 0;
- if (msvc_next_error(app, &view, &line, m, ms, &location, direction, &colon_char)){
+ if (msvc_next_error(app, &view, &line, m, ms, &location,
+ skip_sub_errors, direction, &colon_char)){
jump_to_location(app, &active_view, &location);
app->view_set_cursor(app, &view, seek_line_char(line, colon_char+1), true);
+ result = true;
+ if (loc){
+ *loc = location;
+ }
}
}
+ return(result);
+}
+
+static Prev_Jump
+jump_location_store(Application_Links *app, Jump_Location loc){
+ Prev_Jump result = {0};
+ Buffer_Summary buffer =
+ app->get_buffer_by_name(app, loc.file.str, loc.file.size, AccessAll);
+
+ if (buffer.exists){
+ result.buffer_id = buffer.buffer_id;
+ result.line = loc.line;
+ }
+
+ return(result);
+}
+
+static int
+skip_this_jump(Prev_Jump prev, Prev_Jump jump){
+ int result = false;
+ if (prev.buffer_id != 0 && prev.buffer_id == jump.buffer_id &&
+ prev.line == jump.line){
+ result = true;
+ }
+ return(result);
}
CUSTOM_COMMAND_SIG(msvc_goto_next_error){
- msvc_goto_error(app, 1);
+ Jump_Location location = {0};
+ Prev_Jump jump = {0};
+
+ do{
+ if (msvc_goto_error(app, true, 1, &location)){
+ jump = jump_location_store(app, location);
+ }
+ else{
+ jump.buffer_id = 0;
+ }
+ }while(skip_this_jump(prev_location, jump));
+ prev_location = jump;
}
CUSTOM_COMMAND_SIG(msvc_goto_prev_error){
- msvc_goto_error(app, -1);
+ Jump_Location location = {0};
+ Prev_Jump jump = {0};
+
+ do{
+ if (msvc_goto_error(app, true, -1, &location)){
+ jump = jump_location_store(app, location);
+ }
+ else{
+ jump.buffer_id = 0;
+ }
+ }while(skip_this_jump(prev_location, jump));
+ prev_location = jump;
}
CUSTOM_COMMAND_SIG(msvc_goto_first_error){
View_Summary active_view = app->get_active_view(app, AccessAll);
app->view_set_cursor(app, &active_view, seek_pos(0), true);
- msvc_goto_error(app, 1);
+ Jump_Location location;
+ msvc_goto_error(app, true, 1, &location);
+ prev_location = jump_location_store(app, location);
}
diff --git a/win32_4ed.cpp b/win32_4ed.cpp
index c8cc2811..e18905f4 100644
--- a/win32_4ed.cpp
+++ b/win32_4ed.cpp
@@ -943,16 +943,15 @@ Sys_CLI_Call_Sig(system_cli_call){
char *env_variables = 0;
char command_line[2048];
- b32 success = 1;
String s = make_fixed_width_string(command_line);
copy(&s, make_lit_string("/C "));
append_partial(&s, script_name);
- success = terminate_with_null(&s);
+ b32 success = terminate_with_null(&s);
if (success){
success = 0;
- SECURITY_ATTRIBUTES sec_attributes = {};
+ SECURITY_ATTRIBUTES sec_attributes = {};
HANDLE out_read;
HANDLE out_write;
@@ -967,14 +966,14 @@ Sys_CLI_Call_Sig(system_cli_call){
startup.hStdError = out_write;
startup.hStdOutput = out_write;
startup.wShowWindow = SW_HIDE;
-
+
PROCESS_INFORMATION info = {};
-
+
Assert(sizeof(Plat_Handle) >= sizeof(HANDLE));
if (CreateProcess(cmd, command_line,
- 0, 0, TRUE, 0,
- env_variables, path,
- &startup, &info)){
+ 0, 0, TRUE, 0,
+ env_variables, path,
+ &startup, &info)){
success = 1;
CloseHandle(info.hThread);
*(HANDLE*)&cli_out->proc = info.hProcess;