diff options
-rw-r--r-- | buffer.c | 8 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | test.txt | 3 |
3 files changed, 11 insertions, 2 deletions
@@ -163,6 +163,8 @@ void text_buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float // what x coordinate to start rendering the text from float render_start_x = x1 - (float)buffer->scroll_x * char_height; + u32 column = 0; + TextRenderState text_state = { .x = render_start_x, .y = y1 + text_font_char_height(font), .min_x = x1, .min_y = y1, @@ -199,14 +201,18 @@ void text_buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float case L'\n': text_state.x = render_start_x; text_state.y += text_font_char_height(font); + column = 0; break; case L'\r': break; // for CRLF line endings case L'\t': - for (int i = 0; i < 4; ++i) + do { text_render_char(font, L' ', &text_state); + ++column; + } while (column % 4); break; default: text_render_char(font, c, &text_state); + ++column; break; } } @@ -69,7 +69,7 @@ int main(void) { text_buffer_create(&text_buffer, font); { - FILE *fp = fopen("main.c", "r"); + FILE *fp = fopen("test.txt", "r"); assert(fp); bool success = text_buffer_load_file(&text_buffer, fp); fclose(fp); diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..b5d2be8 --- /dev/null +++ b/test.txt @@ -0,0 +1,3 @@ +12 33 100 4 +7 66 2 88 +3 33 333 3333 |