aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--interactive-test.c12
-rw-r--r--libterminput.c18
-rw-r--r--libterminput.h7
3 files changed, 33 insertions, 4 deletions
diff --git a/interactive-test.c b/interactive-test.c
index 6e21cb3..e38b638 100644
--- a/interactive-test.c
+++ b/interactive-test.c
@@ -22,6 +22,18 @@ main(void)
fprintf(stderr, "LIBTERMINPUT_DECSET_1005 set\n");
libterminput_set_flags(&ctx, LIBTERMINPUT_DECSET_1005);
}
+ if (getenv("TEST_LIBTERMINPUT_MACRO_ON_CSI_M")) {
+ fprintf(stderr, "LIBTERMINPUT_MACRO_ON_CSI_M set\n");
+ libterminput_set_flags(&ctx, LIBTERMINPUT_MACRO_ON_CSI_M);
+ }
+ if (getenv("TEST_LIBTERMINPUT_PAUSE_ON_CSI_P")) {
+ fprintf(stderr, "LIBTERMINPUT_PAUSE_ON_CSI_P set\n");
+ libterminput_set_flags(&ctx, LIBTERMINPUT_PAUSE_ON_CSI_P);
+ }
+ if (getenv("TEST_LIBTERMINPUT_INS_ON_CSI_AT")) {
+ fprintf(stderr, "LIBTERMINPUT_INS_ON_CSI_AT set\n");
+ libterminput_set_flags(&ctx, LIBTERMINPUT_INS_ON_CSI_AT);
+ }
if (tcgetattr(STDERR_FILENO, &stty)) {
perror("tcgetattr STDERR_FILENO");
diff --git a/libterminput.c b/libterminput.c
index aa0814b..95a4e03 100644
--- a/libterminput.c
+++ b/libterminput.c
@@ -315,7 +315,6 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
switch (keylen) {
case 2:
switch (ctx->key[1]) {
- /* case '@': input->keypress.key = LIBTERMINPUT_INS; break; (incompatible with rxvt) */
case 'A': input->keypress.key = LIBTERMINPUT_UP; break;
case 'B': input->keypress.key = LIBTERMINPUT_DOWN; break;
case 'C': input->keypress.key = LIBTERMINPUT_RIGHT; break;
@@ -325,7 +324,10 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
case 'G': input->keypress.key = LIBTERMINPUT_BEGIN; break;
case 'H': input->keypress.key = LIBTERMINPUT_HOME; break;
case 'M':
- if (nnums >= 3) { /* Parsing for \e[?1000;1015h output. */
+ if (ctx->flags & LIBTERMINPUT_MACRO_ON_CSI_M) {
+ input->keypress.key = LIBTERMINPUT_MACRO;
+ } else if (nnums >= 3) {
+ /* Parsing for \e[?1000;1015h output. */
nums[0] -= 32ULL;
decimal_mouse_tracking_set_press:
input->mouseevent.event = LIBTERMINPUT_PRESS;
@@ -388,7 +390,11 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
goto suppress;
}
break;
- case 'P': input->keypress.key = LIBTERMINPUT_F1; break;
+ case 'P':
+ input->keypress.key = LIBTERMINPUT_F1;
+ if (ctx->flags & LIBTERMINPUT_PAUSE_ON_CSI_P)
+ input->keypress.key = LIBTERMINPUT_PAUSE;
+ break;
case 'Q': input->keypress.key = LIBTERMINPUT_F2; break;
case 'R': input->keypress.key = LIBTERMINPUT_F3; break;
case 'S': input->keypress.key = LIBTERMINPUT_F4; break;
@@ -474,6 +480,10 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
goto suppress;
goto tilde_case;
case '@':
+ if (ctx->flags & LIBTERMINPUT_INS_ON_CSI_AT) {
+ input->keypress.key = LIBTERMINPUT_INS;
+ break;
+ }
input->keypress.mods |= LIBTERMINPUT_SHIFT;
/* fall through */
case '^':
@@ -749,6 +759,8 @@ again:
} else if (ctx->key[0] == '[' && ctx->key[1] == '<' && p == &ctx->key[2]) {
input->type = LIBTERMINPUT_NONE;
return 1;
+ } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_MACRO_ON_CSI_M)) {
+ /* complete */
} else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_DECSET_1005)) {
ctx->mouse_tracking = 1;
if (ctx->stored_head == ctx->stored_tail) {
diff --git a/libterminput.h b/libterminput.h
index 58c2976..7e94564 100644
--- a/libterminput.h
+++ b/libterminput.h
@@ -12,7 +12,10 @@
* terminal support this flag if set.
*/
enum libterminput_flags {
- LIBTERMINPUT_DECSET_1005 = 0x0001
+ LIBTERMINPUT_DECSET_1005 = 0x0001,
+ LIBTERMINPUT_MACRO_ON_CSI_M = 0x0002,
+ LIBTERMINPUT_PAUSE_ON_CSI_P = 0x0004,
+ LIBTERMINPUT_INS_ON_CSI_AT = 0x0008
};
enum libterminput_mod {
@@ -50,6 +53,8 @@ enum libterminput_key {
LIBTERMINPUT_ERASE, /* backspace */
LIBTERMINPUT_ENTER, /* return */
LIBTERMINPUT_ESC,
+ LIBTERMINPUT_MACRO,
+ LIBTERMINPUT_PAUSE,
LIBTERMINPUT_KEYPAD_0,
LIBTERMINPUT_KEYPAD_1,
LIBTERMINPUT_KEYPAD_2,