CR characters absorbed into LF characters

master
Allen Webster 2019-09-27 17:07:37 -07:00
parent 36d9e899ae
commit da9d1235b4
4 changed files with 30 additions and 20 deletions

View File

@ -9,11 +9,6 @@
// TOP // TOP
#define DEFAULT_DISPLAY_WIDTH 672
#define DEFAULT_MINIMUM_BASE_DISPLAY_WIDTH 550
////////////////////////////////
Mutex_Lock::Mutex_Lock(System_Functions *s, System_Mutex m){ Mutex_Lock::Mutex_Lock(System_Functions *s, System_Mutex m){
s->mutex_acquire(m); s->mutex_acquire(m);
this->system = s; this->system = s;
@ -893,9 +888,6 @@ App_Init_Sig(app_init){
Mutex_Lock file_order_lock(system, models->working_set.mutex); Mutex_Lock file_order_lock(system, models->working_set.mutex);
models->working_set.default_display_width = DEFAULT_DISPLAY_WIDTH;
models->working_set.default_minimum_base_display_width = DEFAULT_MINIMUM_BASE_DISPLAY_WIDTH;
// NOTE(allen): // NOTE(allen):
global_history_init(&models->global_history); global_history_init(&models->global_history);
text_layout_init(models, &models->text_layouts); text_layout_init(models, &models->text_layouts);

View File

@ -725,11 +725,15 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran
i64 index = range.first; i64 index = range.first;
b32 first_of_the_line = true; b32 first_of_the_line = true;
b32 consuming_newline_characters = false;
i64 newline_character_index = -1;
u8 *ptr = text.str; u8 *ptr = text.str;
u8 *end_ptr = ptr + text.size; u8 *end_ptr = ptr + text.size;
for (;ptr < end_ptr;){ for (;ptr < end_ptr;){
Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr)); Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr));
u32 render_codepoint = consume.codepoint; u32 render_codepoint = consume.codepoint;
b32 emit_newline = false;
switch (consume.codepoint){ switch (consume.codepoint){
case '\t': case '\t':
{ {
@ -753,14 +757,26 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran
first_of_the_line = false; first_of_the_line = false;
}break; }break;
case '\r':
{
if (!consuming_newline_characters){
consuming_newline_characters = true;
newline_character_index = index;
}
if (ptr + 1 == end_ptr){
emit_newline = true;
}
ptr += 1;
index += 1;
}break;
case '\n': case '\n':
{ {
f32 next_x = p.x + space_advance; if (!consuming_newline_characters){
buffer_layout__write(arena, &list, index, ' ', 0, Rf32(p, V2f32(next_x, line_y))); consuming_newline_characters = true;
p.y = line_y; newline_character_index = index;
p.x = 0.f; }
line_y += line_height; emit_newline = true;
first_of_the_line = true;
ptr += 1; ptr += 1;
index += 1; index += 1;
}break; }break;
@ -794,6 +810,14 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran
first_of_the_line = false; first_of_the_line = false;
}break; }break;
} }
if (emit_newline){
f32 next_x = p.x + space_advance;
buffer_layout__write(arena, &list, newline_character_index, ' ', 0, Rf32(p, V2f32(next_x, line_y)));
p.y = line_y;
p.x = 0.f;
line_y += line_height;
first_of_the_line = true;
}
} }
} }

View File

@ -12,9 +12,6 @@
internal void internal void
working_set_file_default_settings(Working_Set *working_set, Editing_File *file){ working_set_file_default_settings(Working_Set *working_set, Editing_File *file){
block_zero_struct(&file->settings); block_zero_struct(&file->settings);
//file->settings.display_width = working_set->default_display_width;
//file->settings.minimum_base_display_width = working_set->default_minimum_base_display_width;
//file->settings.wrap_indicator = WrapIndicator_Show_At_Wrap_Edge;
} }
//////////////////////////////// ////////////////////////////////

View File

@ -41,9 +41,6 @@ struct Working_Set{
System_Mutex mutex; System_Mutex mutex;
System_Thread file_change_thread; System_Thread file_change_thread;
i32 default_display_width;
i32 default_minimum_base_display_width;
// TODO(allen): do(update clipboard system to exist fully in the custom layer) // TODO(allen): do(update clipboard system to exist fully in the custom layer)
// NOTE(allen): These members have nothing to do with the working set or // NOTE(allen): These members have nothing to do with the working set or
// the mutex that gaurds the other members. // the mutex that gaurds the other members.