summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-11-26 09:00:32 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-11-26 09:00:32 -0500
commit370b74e5335745ea01fc7bb6d5425360d26ca0ce (patch)
tree56bf42a10f7ab9e910ab494eadca56e26652e914 /buffer.c
parent346acd202547c3ecb315ff7980f505643bacc77e (diff)
do tabs properly
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 0a19aa5..f98e3f3 100644
--- a/buffer.c
+++ b/buffer.c
@@ -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;
}
}