diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-05-20 19:17:40 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-05-20 19:17:40 +0000 |
commit | 32dbf68cc6dcbdd07ed1076c10c5c5e7f32039bd (patch) | |
tree | c5682219fbb5c8ae7f270653d3e01900844fc08f | |
parent | 75e7ea3f727bdebb3d1032f42e25592f7fa9d9a1 (diff) |
Support DECSCUSR sequence to set the cursor style with two new
terminfo(5) extensions, Cs and Csr. Written by Ailin Nemui.
-rw-r--r-- | usr.bin/tmux/input.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/options-table.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/screen.c | 11 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 15 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tty-term.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 19 |
7 files changed, 60 insertions, 7 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index c465df2efd8..816b1244f00 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.38 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.39 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -126,6 +126,7 @@ enum input_csi_type { INPUT_CSI_CUU, INPUT_CSI_DA, INPUT_CSI_DCH, + INPUT_CSI_DECSCUSR, INPUT_CSI_DECSTBM, INPUT_CSI_DL, INPUT_CSI_DSR, @@ -168,6 +169,7 @@ const struct input_table_entry input_csi_table[] = { { 'l', "?", INPUT_CSI_RM_PRIVATE }, { 'm', "", INPUT_CSI_SGR }, { 'n', "", INPUT_CSI_DSR }, + { 'q', " ", INPUT_CSI_DECSCUSR }, { 'r', "", INPUT_CSI_DECSTBM }, }; @@ -1259,6 +1261,10 @@ input_csi_dispatch(struct input_ctx *ictx) n = input_get(ictx, 0, 1, 1); screen_write_cursormove(sctx, s->cx, n - 1); break; + case INPUT_CSI_DECSCUSR: + n = input_get(ictx, 0, 0, 0); + screen_set_cursor_style(s, n); + break; } return (0); diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index bcdd3afca87..1ef94480fb1 100644 --- a/usr.bin/tmux/options-table.c +++ b/usr.bin/tmux/options-table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-table.c,v 1.9 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.10 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -368,6 +368,7 @@ const struct options_table_entry session_options_table[] = { .default_str = "*88col*:colors=88,*256col*:colors=256" ",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007" ":Cc=\\E]12;%p1%s\\007:Cr=\\E]112\\007" + ":Cs=\\E[%p1%d q:Csr=\\E[2 q" }, { .name = "update-environment", diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c index bb6270e2dc9..6c9b4412112 100644 --- a/usr.bin/tmux/screen.c +++ b/usr.bin/tmux/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.20 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.21 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -40,6 +40,7 @@ screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit) else s->title = xstrdup(""); + s->cstyle = 0; s->ccolour = xstrdup(""); s->tabs = NULL; @@ -91,6 +92,14 @@ screen_reset_tabs(struct screen *s) bit_set(s->tabs, i); } +/* Set screen cursor style. */ +void +screen_set_cursor_style(struct screen *s, u_int style) +{ + if (style <= 4) + s->cstyle = style; +} + /* Set screen cursor colour. */ void screen_set_cursor_colour(struct screen *s, const char *colour_string) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 98ae3b31652..7b243c66532 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.229 2011/05/20 19:03:58 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.230 2011/05/20 19:17:39 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -2832,6 +2832,19 @@ See the option above and the .Xr xterm 1 man page. +.It Em Cs, Csr +Change the cursor style. +If set allows a sequence such as: +.Bd -literal -offset indent +$ printf '\e033[4 q' +.Ed +.Pp +To change the cursor to an underline. +If +.Em Csr +is set, it will be used to reset the cursor style instead +of +.Em Cs . .It Em Cc, Cr The first takes one string argument and is used to set the cursor colour; the second takes no arguments and restores the default cursor colour. diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 6be5bdfc147..233c7f0f7c6 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.287 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.288 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -189,7 +189,9 @@ enum tty_code_code { TTYC_CNORM, /* cursor_normal, ve */ TTYC_COLORS, /* max_colors, Co */ TTYC_CR, /* restore cursor colour, Cr */ + TTYC_CS1, /* set cursor style, Cs */ TTYC_CSR, /* change_scroll_region, cs */ + TTYC_CSR1, /* reset cursor style, Csr */ TTYC_CUB, /* parm_left_cursor, LE */ TTYC_CUB1, /* cursor_left, le */ TTYC_CUD, /* parm_down_cursor, DO */ @@ -716,6 +718,7 @@ struct screen { u_int cx; /* cursor x */ u_int cy; /* cursor y */ + u_int cstyle; /* cursor style */ char *ccolour; /* cursor colour string */ u_int rupper; /* scroll region top */ @@ -1014,6 +1017,7 @@ struct tty { u_int cx; u_int cy; + u_int cstyle; char *ccolour; int mode; @@ -1850,6 +1854,7 @@ void screen_init(struct screen *, u_int, u_int, u_int); void screen_reinit(struct screen *); void screen_free(struct screen *); void screen_reset_tabs(struct screen *); +void screen_set_cursor_style(struct screen *, u_int); void screen_set_cursor_colour(struct screen *, const char *); void screen_set_title(struct screen *, const char *); void screen_resize(struct screen *, u_int, u_int); diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c index 7d22c7e97ce..bca5681a236 100644 --- a/usr.bin/tmux/tty-term.c +++ b/usr.bin/tmux/tty-term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-term.c,v 1.24 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.25 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,7 +44,9 @@ const struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_CNORM, TTYCODE_STRING, "cnorm" }, { TTYC_COLORS, TTYCODE_NUMBER, "colors" }, { TTYC_CR, TTYCODE_STRING, "Cr" }, + { TTYC_CS1, TTYCODE_STRING, "Cs" }, { TTYC_CSR, TTYCODE_STRING, "csr" }, + { TTYC_CSR1, TTYCODE_STRING, "Csr" }, { TTYC_CUB, TTYCODE_STRING, "cub" }, { TTYC_CUB1, TTYCODE_STRING, "cub1" }, { TTYC_CUD, TTYCODE_STRING, "cud" }, diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 29a1aaa7312..73bf5b5035f 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.107 2011/05/20 19:03:58 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.108 2011/05/20 19:17:39 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -69,6 +69,7 @@ tty_init(struct tty *tty, int fd, char *term) if ((path = ttyname(fd)) == NULL) fatalx("ttyname failed"); tty->path = xstrdup(path); + tty->cstyle = 0; tty->ccolour = xstrdup(""); tty->flags = 0; @@ -244,6 +245,12 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX)); tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR)); + if (tty_term_has(tty->term, TTYC_CS1) && tty->cstyle != 0) { + if (tty_term_has(tty->term, TTYC_CSR1)) + tty_raw(tty, tty_term_string(tty->term, TTYC_CSR1)); + else if (tty_term_has(tty->term, TTYC_CS1)) + tty_raw(tty, tty_term_string1(tty->term, TTYC_CS1, 0)); + } tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); @@ -429,6 +436,16 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s) else tty_putcode(tty, TTYC_CIVIS); } + if (tty->cstyle != s->cstyle) { + if (tty_term_has(tty->term, TTYC_CS1)) { + if (s->cstyle == 0 && + tty_term_has(tty->term, TTYC_CSR1)) + tty_putcode(tty, TTYC_CSR1); + else + tty_putcode1(tty, TTYC_CS1, s->cstyle); + } + tty->cstyle = s->cstyle; + } if (changed & ALL_MOUSE_MODES) { if (mode & ALL_MOUSE_MODES) { if (mode & MODE_MOUSE_UTF8) |