summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-02 18:25:03 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-02 18:25:03 -0500
commit35cb8b8cfbd141d4ba2e3f1435a9550864d9e2e1 (patch)
tree192554fde4ce14df9163fdb453fe8932e94dba83 /buffer.c
parent6bafd0d45f63a7618d7822f31b01da7443d9c5e8 (diff)
blinking cursor
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index 0e13ee5..8ad3733 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1774,11 +1774,23 @@ void buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float y2) {
text_chars_end(font);
{ // render cursor
- if (buffer_clip_rect(buffer, &cursor_rect)) {
- gl_color_rgba(colors[COLOR_CURSOR]);
- glBegin(GL_QUADS);
- rect_render(cursor_rect);
- glEnd();
+ float time_on = settings->cursor_blink_time_on;
+ float time_off = settings->cursor_blink_time_off;
+ bool is_on = true;
+ if (time_off > 0) {
+ double absolute_time = time_get_seconds();
+ float period = time_on + time_off;
+ // time in period
+ double t = fmod(absolute_time, period);
+ is_on = t < time_on; // are we in the "on" part of the period?
+ }
+ if (is_on) {
+ if (buffer_clip_rect(buffer, &cursor_rect)) {
+ gl_color_rgba(colors[COLOR_CURSOR]);
+ glBegin(GL_QUADS);
+ rect_render(cursor_rect);
+ glEnd();
+ }
}
}
}