fixed a lot of bugs in the token smart wrapping system, still more to fix
parent
9a4609c8d5
commit
2e341edd41
|
@ -1266,15 +1266,16 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv
|
||||||
{
|
{
|
||||||
if (use_tokens){
|
if (use_tokens){
|
||||||
|
|
||||||
if (stage < real_count-1){
|
if (stage == 0){
|
||||||
do_wrap = 1;
|
do_wrap = 0;
|
||||||
wrap_unit_end = wrap_indent_marks[stage].wrap_position;
|
wrap_unit_end = wrap_indent_marks[stage+1].wrap_position;
|
||||||
file_allocate_wrap_positions_as_needed(general, file, wrap_position_index);
|
++stage;
|
||||||
file->state.wrap_positions[wrap_position_index++] = stop.pos;
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
do_wrap = 0;
|
do_wrap = 1;
|
||||||
wrap_unit_end = wrap_indent_marks[stage].wrap_position;
|
wrap_unit_end = wrap_indent_marks[stage+1].wrap_position;
|
||||||
|
file_allocate_wrap_positions_as_needed(general, file, wrap_position_index);
|
||||||
|
file->state.wrap_positions[wrap_position_index++] = stop.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1300,7 +1301,7 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv
|
||||||
else{
|
else{
|
||||||
Buffer_Stream_Type stream = {0};
|
Buffer_Stream_Type stream = {0};
|
||||||
|
|
||||||
i32 stage = 0;
|
i32 word_stage = 0;
|
||||||
i32 i = stop.pos;
|
i32 i = stop.pos;
|
||||||
f32 x = stop.x;
|
f32 x = stop.x;
|
||||||
f32 self_x = 0;
|
f32 self_x = 0;
|
||||||
|
@ -1310,11 +1311,11 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv
|
||||||
for (; i < stream.end; ++i){
|
for (; i < stream.end; ++i){
|
||||||
char ch = stream.data[i];
|
char ch = stream.data[i];
|
||||||
|
|
||||||
switch (stage){
|
switch (word_stage){
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
if (char_is_whitespace(ch)){
|
if (char_is_whitespace(ch)){
|
||||||
stage = 1;
|
word_stage = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
f32 adv = params.adv[ch];
|
f32 adv = params.adv[ch];
|
||||||
|
@ -1457,7 +1458,7 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv
|
||||||
|
|
||||||
wrap_state = original_wrap_state;
|
wrap_state = original_wrap_state;
|
||||||
for (;;){
|
for (;;){
|
||||||
Code_Wrap_Step step = wrap_state_consume_token(&wrap_state, wrap_position);
|
step = wrap_state_consume_token(&wrap_state, wrap_position);
|
||||||
if (step.position_end >= wrap_position){
|
if (step.position_end >= wrap_position){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1476,10 +1477,17 @@ file_measure_wraps(Models *models, Editing_File *file, f32 font_height, f32 *adv
|
||||||
wrap_indent_marks[real_count].wrap_position = next_line_start;
|
wrap_indent_marks[real_count].wrap_position = next_line_start;
|
||||||
wrap_indent_marks[real_count].line_shift = 0;
|
wrap_indent_marks[real_count].line_shift = 0;
|
||||||
++real_count;
|
++real_count;
|
||||||
|
|
||||||
|
for (i32 l = 0; wrap_state.i < next_line_start && l < 3; ++l){
|
||||||
|
wrap_state_consume_token(&wrap_state, next_line_start);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line_shift = wrap_indent_marks[stage].line_shift;
|
line_shift = wrap_indent_marks[stage].line_shift;
|
||||||
|
|
||||||
|
if (stage > 0){
|
||||||
++stage;
|
++stage;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (; wrap_state.token_ptr < wrap_state.end_token; ){
|
for (; wrap_state.token_ptr < wrap_state.end_token; ){
|
||||||
|
|
Loading…
Reference in New Issue