bug fixing

This commit is contained in:
Allen Webster 2016-06-22 13:53:31 -04:00
parent 75b56c94c3
commit c8fcd07d16
3 changed files with 96 additions and 102 deletions

View File

@ -10,25 +10,19 @@
inline float
get_view_y(View_Summary view){
float y;
float y = view.cursor.wrapped_y;
if (view.unwrapped_lines){
y = view.cursor.unwrapped_y;
}
else{
y = view.cursor.wrapped_y;
}
return(y);
}
inline float
get_view_x(View_Summary view){
float x;
float x = view.cursor.wrapped_x;
if (view.unwrapped_lines){
x = view.cursor.unwrapped_x;
}
else{
x = view.cursor.wrapped_x;
}
return(x);
}
@ -852,23 +846,22 @@ isearch(Application_Links *app, int start_reversed){
if (app->start_query_bar(app, &bar, 0) == 0) return;
Range match;
int reverse = start_reversed;
int pos;
pos = view.cursor.pos;
match = make_range(pos, pos);
int pos = view.cursor.pos;
Range match = make_range(pos, pos);
char bar_string_space[256];
bar.string = make_fixed_width_string(bar_string_space);
String isearch = make_lit_string("I-Search: ");
String rsearch = make_lit_string("Reverse-I-Search: ");
String isearch_str = make_lit_string("I-Search: ");
String rsearch_str = make_lit_string("Reverse-I-Search: ");
for (;;){
app->view_set_highlight(app, &view, match.start, match.end, 1);
while (1){
// NOTE(allen): Change the bar's prompt to match the current direction.
if (reverse) bar.prompt = rsearch;
else bar.prompt = isearch;
if (reverse) bar.prompt = rsearch_str;
else bar.prompt = isearch_str;
in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
if (in.abort) break;
@ -952,8 +945,6 @@ isearch(Application_Links *app, int start_reversed){
match.end = match.start + bar.string.size;
}
}
app->view_set_highlight(app, &view, match.start, match.end, 1);
}
app->view_set_highlight(app, &view, 0, 0, 0);
if (in.abort) return;
@ -1053,7 +1044,10 @@ CUSTOM_COMMAND_SIG(query_replace){
in = app->get_user_input(app, EventOnAnyKey, EventOnButton);
if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break;
if (in.key.character == 'y' || in.key.character == 'Y' || in.key.character == '\n' || in.key.character == '\t'){
if (in.key.character == 'y' ||
in.key.character == 'Y' ||
in.key.character == '\n' ||
in.key.character == '\t'){
app->buffer_replace_range(app, &buffer, match.min, match.max, w.str, w.size);
pos = match.start + w.size;
}

View File

@ -1583,7 +1583,7 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll){
i32 line_height = view->line_height;
f32 old_cursor_y = view_get_cursor_y(view);
f32 cursor_y = old_cursor_y;
f32 target_y = scroll.target_y;
f32 target_y = scroll.target_y + view->widget_height;
Cursor_Limits limits = view_cursor_limits(view);
@ -3076,8 +3076,10 @@ remeasure_file_view(System_Functions *system, View *view){
if (file_is_ready(view->file_data.file)){
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_set_relative_scrolling(view, relative);
}
}
@ -5345,8 +5347,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
float *advance_data = 0;
if (font) advance_data = font->advance_data;
i32 count;
Full_Cursor render_cursor;
i32 count = 0;
Full_Cursor render_cursor = {0};
Buffer_Render_Options opts = {};
f32 *wraps = view->file_data.line_wrap_y;
@ -5377,8 +5379,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
Assert(count > 0);
i32 cursor_begin, cursor_end;
u32 cursor_color, at_cursor_color;
i32 cursor_begin = 0, cursor_end = 0;
u32 cursor_color = 0, at_cursor_color = 0;
if (view->file_data.show_temp_highlight){
cursor_begin = view->file_data.temp_highlight.pos;
cursor_end = view->file_data.temp_highlight_end_pos;
@ -5437,13 +5439,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
u32 char_color = main_color;
if (item->flags & BRFlag_Special_Character) char_color = special_color;
#if 0
i32_Rect char_rect = i32R(item->x0, item->y0,
item->x1, item->y1);
#else
f32_Rect char_rect = f32R(item->x0, item->y0,
item->x1, item->y1);
#endif
if (view->file_data.show_whitespace && highlight_color == 0 &&
char_is_whitespace((char)item->glyphid)){

View File

@ -1080,6 +1080,9 @@ buffer_cursor_from_pos(Buffer_Type *buffer, int pos, float *wraps,
Full_Cursor result;
int line_index;
if (pos > buffer->size) pos = buffer->size;
if (pos < 0) pos = 0;
line_index = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
result = make_cursor_hint(line_index, buffer->line_starts, wraps, font_height);
result = buffer_cursor_seek(buffer, seek_pos(pos), max_width, font_height,