diff options
author | pgen <p.gen.progs@gmail.com> | 2022-10-31 21:35:02 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2022-11-02 00:19:54 +0100 |
commit | 38b1ea72c75bcda7be2afa9dbf2f29e418e08f7a (patch) | |
tree | d02c928112f8cad340ad807c556962d8cf8f296a /smenu.c | |
parent | 9b488c0c71348ab8914d2974cc1c5a87a5a4b93e (diff) |
Prevent mouse paste from sending spurious commands
Enables bracketed pastes and traps the starting sequence constituting
the first bracket to ignore the pasted text with the mouse.
Diffstat (limited to 'smenu.c')
-rw-r--r-- | smenu.c | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -10053,11 +10053,11 @@ main(int argc, char * argv[]) if (!toggles.no_mouse) { if (term.has_kmous && strncmp(tigetstr("kmous"), "\x1b[<", 3) == 0) - mouse_trk_on = "\x1b[?1000;1006h"; + mouse_trk_on = "\x1b[?1000;1006h\x1b[?2004h"; else - mouse_trk_on = "\x1b[?1000;1006;1015h"; + mouse_trk_on = "\x1b[?1000;1006;1015h\x1b[?2004h"; - mouse_trk_off = "\x1b[?1000;1006;1015l"; + mouse_trk_off = "\x1b[?1000;1006;1015l\x1b[?2004l"; printf("%s", mouse_trk_on); } @@ -10456,6 +10456,27 @@ main(int argc, char * argv[]) break; case 0x1b: /* ESC */ + + /* Ignore mouse pastes when bracketed pastes is enabled. */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (memcmp("\x1b[200~", buffer, 6) == 0) + { + int c, eb[6]; + + /* Consume stdin until a closing bracket is found. */ + /* ''''''''''''''''''''''''''''''''''''''''''''''' */ + while (1) + { + while ((c = my_fgetc(stdin)) != EOF && c != 0x1b) + ; /* Null action. */ + + if (c == EOF || scanf("[201~", eb)) + break; + } + + continue; + } + /* An escape sequence or a UTF-8 sequence has been pressed. */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ if (memcmp("\x1bOH", buffer, 3) == 0 |