summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authornicm <nicm>2021-11-01 09:34:49 +0000
committernicm <nicm>2021-11-01 09:34:49 +0000
commit8d2286b76917debc4f6c3b0903ad2807ae254bb5 (patch)
tree5eb3353a6ecebeb3defb4701f63b75cbcfd81a61 /input.c
parent4fe5aa99fb203ddb25089955d8814e1065e11a60 (diff)
Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.
Diffstat (limited to 'input.c')
-rw-r--r--input.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/input.c b/input.c
index 8a16281c..b2769e31 100644
--- a/input.c
+++ b/input.c
@@ -137,10 +137,12 @@ static void input_reset_cell(struct input_ctx *);
static void input_osc_4(struct input_ctx *, const char *);
static void input_osc_10(struct input_ctx *, const char *);
static void input_osc_11(struct input_ctx *, const char *);
+static void input_osc_12(struct input_ctx *, const char *);
static void input_osc_52(struct input_ctx *, const char *);
static void input_osc_104(struct input_ctx *, const char *);
static void input_osc_110(struct input_ctx *, const char *);
static void input_osc_111(struct input_ctx *, const char *);
+static void input_osc_112(struct input_ctx *, const char *);
/* Transition entry/exit handlers. */
static void input_clear(struct input_ctx *);
@@ -2310,8 +2312,7 @@ input_exit_osc(struct input_ctx *ictx)
input_osc_11(ictx, p);
break;
case 12:
- if (utf8_isvalid(p) && *p != '?') /* ? is colour request */
- screen_set_cursor_colour(sctx->s, p);
+ input_osc_12(ictx, p);
break;
case 52:
input_osc_52(ictx, p);
@@ -2326,8 +2327,7 @@ input_exit_osc(struct input_ctx *ictx)
input_osc_111(ictx, p);
break;
case 112:
- if (*p == '\0') /* no arguments allowed */
- screen_set_cursor_colour(sctx->s, "");
+ input_osc_112(ictx, p);
break;
default:
log_debug("%s: unknown '%u'", __func__, option);
@@ -2489,7 +2489,9 @@ input_osc_colour_reply(struct input_ctx *ictx, u_int n, int c)
u_char r, g, b;
const char *end;
- if (c == 8 || (~c & COLOUR_FLAG_RGB))
+ if (c != -1)
+ c = colour_force_rgb(c);
+ if (c == -1)
return;
colour_split_rgb(c, &r, &g, &b);
@@ -2564,7 +2566,7 @@ input_osc_10(struct input_ctx *ictx, const char *p)
}
}
-/* Handle the OSC 110 sequence for resetting background colour. */
+/* Handle the OSC 110 sequence for resetting foreground colour. */
static void
input_osc_110(struct input_ctx *ictx, const char *p)
{
@@ -2624,6 +2626,39 @@ input_osc_111(struct input_ctx *ictx, const char *p)
}
}
+/* Handle the OSC 12 sequence for setting and querying cursor colour. */
+static void
+input_osc_12(struct input_ctx *ictx, const char *p)
+{
+ struct window_pane *wp = ictx->wp;
+ int c;
+
+ if (strcmp(p, "?") == 0) {
+ if (wp != NULL) {
+ c = ictx->ctx.s->ccolour;
+ if (c == -1)
+ c = ictx->ctx.s->default_ccolour;
+ input_osc_colour_reply(ictx, 12, c);
+ }
+ return;
+ }
+
+ if ((c = input_osc_parse_colour(p)) == -1) {
+ log_debug("bad OSC 12: %s", p);
+ return;
+ }
+ screen_set_cursor_colour(ictx->ctx.s, c);
+}
+
+/* Handle the OSC 112 sequence for resetting cursor colour. */
+static void
+input_osc_112(struct input_ctx *ictx, const char *p)
+{
+ if (*p == '\0') /* no arguments allowed */
+ screen_set_cursor_colour(ictx->ctx.s, -1);
+}
+
+
/* Handle the OSC 52 sequence for setting the clipboard. */
static void
input_osc_52(struct input_ctx *ictx, const char *p)