fixed cursor seek control flow so that the step is just in one spot again

This commit is contained in:
Allen Webster 2016-09-22 22:30:29 -04:00
parent 28b6132be5
commit e2bb11ad8d
2 changed files with 28 additions and 5 deletions

View File

@ -529,6 +529,9 @@ buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, f32 max_width,
xy_seek = (seek.type == buffer_seek_wrapped_xy || seek.type == buffer_seek_unwrapped_xy);
result = 1;
stream.use_termination_character = 1;
stream.terminator = 0;
if (buffer_stringify_loop(&stream, buffer, i, size)){
b32 still_looping = 0;
do{
@ -544,11 +547,7 @@ buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, f32 max_width,
}while(still_looping);
}
if (result){
result = cursor_seek_step(&state, seek, xy_seek, max_width,
font_height, adv, size, 0);
assert_4tech(result == 0);
}
assert_4tech(result == 0);
}
buffer_cursor_seek_end:;

View File

@ -104,6 +104,9 @@ typedef struct Gap_Buffer_Stream{
i32 end;
i32 separated;
i32 absolute_end;
b32 use_termination_character;
char terminator;
} Gap_Buffer_Stream;
internal_4tech b32
@ -142,6 +145,17 @@ buffer_stringify_loop(Gap_Buffer_Stream *stream, Gap_Buffer *buffer, i32 start,
result = 1;
}
if (result == 0){
if (stream->use_termination_character){
stream->buffer = buffer;
stream->absolute_end = end;
stream->use_termination_character = 0;
stream->data = (&stream->terminator) - buffer->size1 - buffer->size2;
stream->end = stream->absolute_end + 1;
result = 1;
}
}
return(result);
}
@ -155,6 +169,16 @@ buffer_stringify_next(Gap_Buffer_Stream *stream){
stream->separated = 0;
result = 1;
}
if (result == 0){
if (stream->use_termination_character){
stream->use_termination_character = 0;
stream->data = (&stream->terminator) - buffer->size1 - buffer->size2;
stream->end = stream->absolute_end + 1;
result = 1;
}
}
return(result);
}