term: implement cursor blinking

Blinking can be enabled either by setting the cursor style with

 CSI Ps SP q

and selecting a blinking style.

Or, with 'CSI ? 12 h'

Note that both affect the same internal state. I.e. you can disable
blinking with CSI ? 12l after having selected a blinking cursor
style. This is consistent with XTerm behavior.
This commit is contained in:
Daniel Eklöf 2019-12-15 15:07:56 +01:00
parent 5106937c7b
commit 7d29435d86
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 93 additions and 9 deletions

View file

@ -232,7 +232,10 @@ struct terminal {
struct cursor alt_saved_cursor;
enum cursor_style default_cursor_style;
enum cursor_style cursor_style;
bool cursor_blinking;
struct {
enum { CURSOR_BLINK_ON, CURSOR_BLINK_OFF } state;
int fd;
} cursor_blink;
struct {
uint32_t text;
uint32_t cursor;
@ -292,6 +295,7 @@ struct terminal {
struct coord actual; /* Absolute */
struct coord in_view; /* Offset by view */
struct cell *cell; /* For easy access to content */
int blink_state;
} last_cursor;
struct buffer *last_buf; /* Buffer we rendered to last time */
@ -345,6 +349,8 @@ void term_cursor_left(struct terminal *term, int count);
void term_cursor_right(struct terminal *term, int count);
void term_cursor_up(struct terminal *term, int count);
void term_cursor_down(struct terminal *term, int count);
void term_cursor_blink_enable(struct terminal *term);
void term_cursor_blink_disable(struct terminal *term);
void term_scroll(struct terminal *term, int rows);
void term_scroll_reverse(struct terminal *term, int rows);