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

@ -1,15 +1,15 @@
/*
* Mr. 4th Dimention - Allen Webster
* Four Tech
*
* public domain -- no warranty is offered or implied; use this code at your own risk
*
* 24.10.2015
*
* Buffer data object
* type - Golden Array
*
*/
* Mr. 4th Dimention - Allen Webster
* Four Tech
*
* public domain -- no warranty is offered or implied; use this code at your own risk
*
* 24.10.2015
*
* Buffer data object
* type - Golden Array
*
*/
// TOP
@ -212,7 +212,7 @@ buffer_seek_word_right_assume_on_word(Buffer_Type *buffer, int pos){
if (!is_alphanumeric(data[pos])) goto double_break;
}
}
double_break:
double_break:
return(pos);
}
@ -236,7 +236,7 @@ buffer_seek_alphanumeric_right(Buffer_Type *buffer, int pos){
}
}
buffer_seek_alphanumeric_right_mid:
buffer_seek_alphanumeric_right_mid:
for (;buffer_stringify_good(&loop);
buffer_stringify_next(&loop)){
end = loop.size + loop.absolute_pos;
@ -246,7 +246,7 @@ buffer_seek_alphanumeric_right_mid:
}
}
buffer_seek_alphanumeric_right_end:
buffer_seek_alphanumeric_right_end:
return(pos);
}
@ -271,7 +271,7 @@ buffer_seek_alphanumeric_left(Buffer_Type *buffer, int pos){
}
}
buffer_seek_alphanumeric_left_mid:
buffer_seek_alphanumeric_left_mid:
for (;buffer_backify_good(&loop);
buffer_backify_next(&loop)){
end = loop.absolute_pos;
@ -288,7 +288,7 @@ buffer_seek_alphanumeric_left_mid:
pos = 0;
}
buffer_seek_alphanumeric_left_end:
buffer_seek_alphanumeric_left_end:
return(pos);
}
@ -326,7 +326,7 @@ buffer_seek_range_camel_right(Buffer_Type *buffer, int pos, int an_pos){
pos = an_pos;
}
buffer_seek_alphanumeric_or_camel_right_end:
buffer_seek_alphanumeric_or_camel_right_end:
return(pos);
}
@ -358,7 +358,7 @@ buffer_seek_range_camel_left(Buffer_Type *buffer, int pos, int an_pos){
}
}
buffer_seek_alphanumeric_or_camel_left_end:
buffer_seek_alphanumeric_or_camel_left_end:
return(pos);
}
@ -420,7 +420,7 @@ buffer_find_hard_start(Buffer_Type *buffer, int line_start, int tab_width){
}
}
buffer_find_hard_start_end:
buffer_find_hard_start_end:
return(result);
}
@ -447,7 +447,7 @@ buffer_find_string(Buffer_Type *buffer, int start_pos, int end_pos, char *str, i
}
}
buffer_find_string_end:
buffer_find_string_end:
if (pos >= end_pos - len + 1) pos = end_pos;
return(pos);
}
@ -480,7 +480,7 @@ buffer_rfind_string(Buffer_Type *buffer, int start_pos, char *str, int len, char
}
}
buffer_rfind_string_end:
buffer_rfind_string_end:
return(pos);
}
@ -507,7 +507,7 @@ buffer_find_string_insensitive(Buffer_Type *buffer, int start_pos, int end_pos,
}
}
buffer_find_string_end:
buffer_find_string_end:
if (pos >= end_pos - len + 1) pos = end_pos;
return(pos);
}
@ -540,7 +540,7 @@ buffer_rfind_string_insensitive(Buffer_Type *buffer, int start_pos, char *str, i
}
}
buffer_rfind_string_end:
buffer_rfind_string_end:
return(pos);
}
@ -611,7 +611,7 @@ buffer_measure_starts_widths_(Buffer_Measure_Starts *state, Buffer_Type *buffer,
*width_ptr++ = 0;
result = 0;
buffer_measure_starts_widths_end:
buffer_measure_starts_widths_end:
state->i = i;
state->count = (int)(start_ptr - buffer->line_starts);
state->start = start;
@ -672,7 +672,7 @@ buffer_measure_starts_zero_widths_(Buffer_Measure_Starts *state, Buffer_Type *bu
*width_ptr++ = 0;
result = 0;
buffer_measure_starts_zero_widths_end:
buffer_measure_starts_zero_widths_end:
state->i = i;
state->count = (int)(start_ptr - buffer->line_starts);
state->start = start;
@ -751,7 +751,7 @@ buffer_remeasure_starts(Buffer_Type *buffer, int line_start, int line_end, int l
starts[line_i++] = start;
}
buffer_remeasure_starts_end:
buffer_remeasure_starts_end:
assert_4tech(line_count >= 1);
buffer->line_count = line_count;
}
@ -1070,7 +1070,7 @@ buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, float max_width,
}
}
buffer_cursor_seek_end:
buffer_cursor_seek_end:
return(state.cursor);
}
@ -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,