Fix label jump skipping bug

master
Allen Webster 2016-10-24 13:22:22 -04:00
parent 43d6c29e8b
commit 39dbddfa3f
2 changed files with 66 additions and 66 deletions

View File

@ -4,7 +4,7 @@
#include "4coder_mem.h"
#define MEMORY_DEBUG
//#define MEMORY_DEBUG
static void
general_memory_open(System_Functions *system, General_Memory *general, void *memory, int32_t size){
@ -57,7 +57,7 @@ general_memory_allocate(System_Functions *system, General_Memory *general, int32
return(result);
}
#else
return general_memory_allocate(general, memory, size);
return general_memory_allocate(general, size);
#endif
}
@ -68,7 +68,7 @@ general_memory_free(System_Functions *system, General_Memory *general, void *mem
system->memory_free(0, memory, 0);
}
#else
return general_memory_free(general, memory, size);
return general_memory_free(general, memory);
#endif
}
@ -82,7 +82,7 @@ general_memory_reallocate(System_Functions *system, General_Memory *general, voi
return(result);
}
#else
return general_memory_reallocate(general, memory, size);
return general_memory_reallocate(general, old, old_size, size);
#endif
}
@ -94,7 +94,7 @@ general_memory_reallocate_nocopy(System_Functions *system, General_Memory *gener
return general_memory_allocate(system, general, size);
}
#else
return general_memory_reallocate_nocopy(general, memory, size);
return general_memory_reallocate_nocopy(general, old, size);
#endif
}

View File

@ -761,68 +761,68 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
S.size = buffer_size(params.buffer);
// Get cursor hint
i32 line_index = 0;
switch (params.seek.type){
case buffer_seek_pos:
{
if (params.seek.pos > S.size){
params.seek.pos = S.size;
}
if (params.seek.pos < 0){
params.seek.pos = 0;
}
line_index = buffer_get_line_index(params.buffer, params.seek.pos);
}break;
case buffer_seek_character_pos:
{
i32 line_count = params.buffer->line_count;
i32 max_character = params.character_starts[line_count] - 1;
if (params.seek.pos > max_character){
params.seek.pos = max_character;
}
if (params.seek.pos < 0){
params.seek.pos = 0;
}
line_index = buffer_get_line_index_from_character_pos(params.character_starts, params.seek.pos,
0, params.buffer->line_count);
}break;
case buffer_seek_line_char:
{
line_index = params.seek.line - 1;
if (line_index >= params.buffer->line_count){
line_index = params.buffer->line_count - 1;
}
if (line_index < 0){
line_index = 0;
}
}break;
case buffer_seek_unwrapped_xy:
{
line_index = (i32)(params.seek.y / params.font_height);
if (line_index >= params.buffer->line_count){
line_index = params.buffer->line_count - 1;
}
if (line_index < 0){
line_index = 0;
}
}break;
case buffer_seek_wrapped_xy:
{
line_index = buffer_get_line_index_from_wrapped_y(params.wrap_line_index, params.seek.y, params.font_height,
0, params.buffer->line_count);
}break;
default: InvalidCodePath;
}
// Build the cursor hint
{
i32 line_index = 0;
switch (params.seek.type){
case buffer_seek_pos:
{
if (params.seek.pos > S.size){
params.seek.pos = S.size;
}
if (params.seek.pos < 0){
params.seek.pos = 0;
}
line_index = buffer_get_line_index(params.buffer, params.seek.pos);
}break;
case buffer_seek_character_pos:
{
i32 line_count = params.buffer->line_count;
i32 max_character = params.character_starts[line_count] - 1;
if (params.seek.pos > max_character){
params.seek.pos = max_character;
}
if (params.seek.pos < 0){
params.seek.pos = 0;
}
line_index = buffer_get_line_index_from_character_pos(params.character_starts, params.seek.pos,
0, params.buffer->line_count);
}break;
case buffer_seek_line_char:
{
line_index = params.seek.line - 1;
if (line_index >= params.buffer->line_count){
line_index = params.buffer->line_count - 1;
}
if (line_index < 0){
line_index = 0;
}
}break;
case buffer_seek_unwrapped_xy:
{
line_index = (i32)(params.seek.y / params.font_height);
if (line_index >= params.buffer->line_count){
line_index = params.buffer->line_count - 1;
}
if (line_index < 0){
line_index = 0;
}
}break;
case buffer_seek_wrapped_xy:
{
line_index = buffer_get_line_index_from_wrapped_y(params.wrap_line_index, params.seek.y, params.font_height,
0, params.buffer->line_count);
}break;
default: InvalidCodePath;
}
// Build the cursor hint
S.next_cursor.pos = params.buffer->line_starts[line_index];
S.next_cursor.character_pos = params.character_starts[line_index];
S.next_cursor.line = line_index + 1;