about summary refs log tree commit diff stats
path: root/termbox/output.inl
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-09 20:01:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-09 20:01:42 -0700
commite709c65e67f873541b958ba43e425b08f3e073e3 (patch)
tree37d7203b4f2874e41e178938f1f00917dae949c8 /termbox/output.inl
parent6fef33fd0872ffcb5141a926d1dae5b0eded3071 (diff)
downloadmu-e709c65e67f873541b958ba43e425b08f3e073e3.tar.gz
1964 - don't mess up paste
It took me a long time to fix termbox because the escape codes it was
seeing seemed all wrong. Had to stop calling tb_shutdown/printf and put
in the extra 3 lines to log to a file. Then everything cleared up.
Weird.
Diffstat (limited to 'termbox/output.inl')
-rw-r--r--termbox/output.inl28
1 files changed, 16 insertions, 12 deletions
diff --git a/termbox/output.inl b/termbox/output.inl
index 427f221c..277817fa 100644
--- a/termbox/output.inl
+++ b/termbox/output.inl
@@ -13,6 +13,8 @@ enum {
   T_EXIT_KEYPAD,
   T_ENTER_MOUSE,
   T_EXIT_MOUSE,
+  T_ENTER_BRACKETED_PASTE,
+  T_EXIT_BRACKETED_PASTE,
   T_FUNCS_NUM,
 };
 
@@ -23,7 +25,7 @@ static const char *rxvt_256color_keys[] = {
   "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
 };
 static const char *rxvt_256color_funcs[] = {
-  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l",
+  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
 };
 
 // Eterm
@@ -31,7 +33,7 @@ static const char *eterm_keys[] = {
   "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
 };
 static const char *eterm_funcs[] = {
-  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "",
+  "\0337\033[?47h", "\033[2J\033[?47l\0338", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "", "", "",
 };
 
 // screen
@@ -39,7 +41,7 @@ static const char *screen_keys[] = {
   "\033OP", "\033OQ", "\033OR", "\033OS", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[1~", "\033[4~", "\033[5~", "\033[6~", "\033OA", "\033OB", "\033OD", "\033OC", 0
 };
 static const char *screen_funcs[] = {
-  "\033[?1049h", "\033[?1049l", "\033[34h\033[?25h", "\033[?25l", "\033[H\033[J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l",
+  "\033[?1049h", "\033[?1049l", "\033[34h\033[?25h", "\033[?25l", "\033[H\033[J", "\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
 };
 
 // rxvt-unicode
@@ -47,7 +49,7 @@ static const char *rxvt_unicode_keys[] = {
   "\033[11~", "\033[12~", "\033[13~", "\033[14~", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[7~", "\033[8~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
 };
 static const char *rxvt_unicode_funcs[] = {
-  "\033[?1049h", "\033[r\033[?1049l", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m\033(B", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l",
+  "\033[?1049h", "\033[r\033[?1049l", "\033[?25h", "\033[?25l", "\033[H\033[2J", "\033[m\033(B", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033=", "\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
 };
 
 // linux
@@ -55,7 +57,7 @@ static const char *linux_keys[] = {
   "\033[[A", "\033[[B", "\033[[C", "\033[[D", "\033[[E", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033[1~", "\033[4~", "\033[5~", "\033[6~", "\033[A", "\033[B", "\033[D", "\033[C", 0
 };
 static const char *linux_funcs[] = {
-  "", "", "\033[?25h\033[?0c", "\033[?25l\033[?1c", "\033[H\033[J", "\033[0;10m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "",
+  "", "", "\033[?25h\033[?0c", "\033[?25l\033[?1c", "\033[H\033[J", "\033[0;10m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "", "", "", "", "", "",
 };
 
 // xterm
@@ -63,7 +65,7 @@ static const char *xterm_keys[] = {
   "\033OP", "\033OQ", "\033OR", "\033OS", "\033[15~", "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", "\033[23~", "\033[24~", "\033[2~", "\033[3~", "\033OH", "\033OF", "\033[5~", "\033[6~", "\033OA", "\033OB", "\033OD", "\033OC", 0
 };
 static const char *xterm_funcs[] = {
-  "\033[?1049h", "\033[?1049l", "\033[?12l\033[?25h", "\033[?25l", "\033[H\033[2J", "\033(B\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l",
+  "\033[?1049h", "\033[?1049l", "\033[?12l\033[?25h", "\033[?25l", "\033[H\033[2J", "\033(B\033[m", "\033[4m", "\033[1m", "\033[5m", "\033[7m", "\033[?1h\033=", "\033[?1l\033>", "\033[?1000h", "\033[?1000l", "\033[?2004h", "\033[?2004l",
 };
 
 static struct term {
@@ -273,15 +275,17 @@ static int init_term(void) {
   keys[TB_KEYS_NUM] = 0;
 
   funcs = malloc(sizeof(const char*) * T_FUNCS_NUM);
-  // the last two entries are reserved for mouse. because the table offset is
+  // the last four entries are reserved for mouse, bracketed paste. because the table offset is
   // not there, the two entries have to fill in manually
-  for (i = 0; i < T_FUNCS_NUM-2; i++) {
+  for (i = 0; i < T_FUNCS_NUM-4; i++) {
     funcs[i] = terminfo_copy_string(data,
       str_offset + 2 * ti_funcs[i], table_offset);
   }
 
-  funcs[T_FUNCS_NUM-2] = "\033[?1000h";
-  funcs[T_FUNCS_NUM-1] = "\033[?1000l";
+  funcs[T_FUNCS_NUM-4] = "\033[?1000h";
+  funcs[T_FUNCS_NUM-3] = "\033[?1000l";
+  funcs[T_FUNCS_NUM-2] = "\033[?2004h";
+  funcs[T_FUNCS_NUM-1] = "\033[?2004l";
 
   init_from_terminfo = true;
   free(data);
@@ -294,10 +298,10 @@ static void shutdown_term(void) {
     for (i = 0; i < TB_KEYS_NUM; i++) {
       free((void*)keys[i]);
     }
-    // the last two entries are reserved for mouse. because the table offset
+    // the last four entries are reserved for mouse, bracketed paste. because the table offset
     // is not there, the two entries have to fill in manually and do not
     // need to be freed.
-    for (i = 0; i < T_FUNCS_NUM-2; i++) {
+    for (i = 0; i < T_FUNCS_NUM-4; i++) {
       free((void*)funcs[i]);
     }
     free(keys);