diff --git a/4ed.cpp b/4ed.cpp index 50198168..dd7ea4fc 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -9,11 +9,6 @@ // TOP -#define DEFAULT_DISPLAY_WIDTH 672 -#define DEFAULT_MINIMUM_BASE_DISPLAY_WIDTH 550 - -//////////////////////////////// - Mutex_Lock::Mutex_Lock(System_Functions *s, System_Mutex m){ s->mutex_acquire(m); this->system = s; @@ -893,9 +888,6 @@ App_Init_Sig(app_init){ 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): global_history_init(&models->global_history); text_layout_init(models, &models->text_layouts); diff --git a/4ed_buffer.cpp b/4ed_buffer.cpp index 1ea7d16e..b8152b48 100644 --- a/4ed_buffer.cpp +++ b/4ed_buffer.cpp @@ -725,11 +725,15 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran i64 index = range.first; b32 first_of_the_line = true; + b32 consuming_newline_characters = false; + i64 newline_character_index = -1; + u8 *ptr = text.str; u8 *end_ptr = ptr + text.size; for (;ptr < end_ptr;){ Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr)); u32 render_codepoint = consume.codepoint; + b32 emit_newline = false; switch (consume.codepoint){ case '\t': { @@ -753,14 +757,26 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran first_of_the_line = false; }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': { - f32 next_x = p.x + space_advance; - buffer_layout__write(arena, &list, 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; + if (!consuming_newline_characters){ + consuming_newline_characters = true; + newline_character_index = index; + } + emit_newline = true; ptr += 1; index += 1; }break; @@ -794,6 +810,14 @@ buffer_layout(Arena *scratch, Arena *arena, Gap_Buffer *buffer, Interval_i64 ran first_of_the_line = false; }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; + } } } diff --git a/4ed_working_set.cpp b/4ed_working_set.cpp index 5afc2259..7bcf9057 100644 --- a/4ed_working_set.cpp +++ b/4ed_working_set.cpp @@ -12,9 +12,6 @@ internal void working_set_file_default_settings(Working_Set *working_set, Editing_File *file){ 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; } //////////////////////////////// diff --git a/4ed_working_set.h b/4ed_working_set.h index e79a9800..159ee02f 100644 --- a/4ed_working_set.h +++ b/4ed_working_set.h @@ -41,9 +41,6 @@ struct Working_Set{ System_Mutex mutex; 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) // NOTE(allen): These members have nothing to do with the working set or // the mutex that gaurds the other members.