To: vim_dev@googlegroups.com Subject: Patch 8.0.0738 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0738 Problem: Cannot use the mouse to resize window while the focus is in a terminal window. Solution: Recognize nice mouse events in the terminal window. A few more fixes for the terminal window. Files: src/terminal.c *** ../vim-8.0.0737/src/terminal.c 2017-07-18 22:53:16.823259309 +0200 --- src/terminal.c 2017-07-19 23:18:32.111791542 +0200 *************** *** 29,36 **** * while, if the terminal window is visible, the screen contents is drawn. * * TODO: - * - pressing Enter sends two CR and/or NL characters to "bash -i"? - * Passing Enter as NL seems to work. * - set buffer options to be scratch, hidden, nomodifiable, etc. * - set buffer name to command, add (1) to avoid duplicates. * - If [command] is not given the 'shell' option is used. --- 29,34 ---- *************** *** 251,257 **** /* * Wait for input and send it to the job. ! * Return when a CTRL-W command is typed that moves to another window. */ void terminal_loop(void) --- 249,256 ---- /* * Wait for input and send it to the job. ! * Return when the start of a CTRL-W command is typed or anything else that ! * should be handled as a Normal mode command. */ void terminal_loop(void) *************** *** 259,264 **** --- 258,265 ---- char buf[KEY_BUF_LEN]; int c; size_t len; + static int mouse_was_outside = FALSE; + int dragging_outside = FALSE; for (;;) { *************** *** 268,278 **** out_flush(); c = vgetc(); ! if (c == Ctrl_W) { ! stuffcharReadbuff(Ctrl_W); ! return; } /* Convert the typed key to a sequence of bytes for the job. */ len = term_convert_key(c, buf); --- 269,317 ---- out_flush(); c = vgetc(); ! /* Catch keys that need to be handled as in Normal mode. */ ! switch (c) { ! case Ctrl_W: ! case NUL: ! case K_ZERO: ! stuffcharReadbuff(c); ! return; ! ! case K_IGNORE: continue; ! ! case K_LEFTDRAG: ! case K_MIDDLEDRAG: ! case K_RIGHTDRAG: ! case K_X1DRAG: ! case K_X2DRAG: ! dragging_outside = mouse_was_outside; ! /* FALLTHROUGH */ ! case K_LEFTMOUSE: ! case K_LEFTMOUSE_NM: ! case K_LEFTRELEASE: ! case K_LEFTRELEASE_NM: ! case K_MIDDLEMOUSE: ! case K_MIDDLERELEASE: ! case K_RIGHTMOUSE: ! case K_RIGHTRELEASE: ! case K_X1MOUSE: ! case K_X1RELEASE: ! case K_X2MOUSE: ! case K_X2RELEASE: ! if (mouse_row < W_WINROW(curwin) ! || mouse_row >= (W_WINROW(curwin) + curwin->w_height) ! || mouse_col < W_WINCOL(curwin) ! || mouse_col >= W_ENDCOL(curwin) ! || dragging_outside) ! { ! /* click outside the current window */ ! stuffcharReadbuff(c); ! mouse_was_outside = TRUE; ! return; ! } } + mouse_was_outside = FALSE; /* Convert the typed key to a sequence of bytes for the job. */ len = term_convert_key(c, buf); *************** *** 392,400 **** /* Required to initialize most things. */ vterm_screen_reset(screen, 1 /* hard */); - /* By default NL means CR-NL. */ - vterm_input_write(vterm, "\x1b[20h", 5); - return OK; } --- 431,436 ---- *************** *** 414,421 **** term_write_job_output(term_T *term, char_u *msg, size_t len) { VTerm *vterm = term->tl_vterm; ! vterm_input_write(vterm, (char *)msg, len); vterm_screen_flush_damage(vterm_obtain_screen(vterm)); } --- 450,476 ---- term_write_job_output(term_T *term, char_u *msg, size_t len) { VTerm *vterm = term->tl_vterm; + char_u *p; + size_t done; + size_t len_now; ! for (done = 0; done < len; done += len_now) ! { ! for (p = msg + done; p < msg + len; ) ! { ! if (*p == NL) ! break; ! p += mb_ptr2len_len(p, len - (p - msg)); ! } ! len_now = p - msg - done; ! vterm_input_write(vterm, (char *)msg + done, len_now); ! if (p < msg + len && *p == NL) ! { ! /* Convert NL to CR-NL, that appears to work best. */ ! vterm_input_write(vterm, "\r\n", 2); ! ++len_now; ! } ! } vterm_screen_flush_damage(vterm_obtain_screen(vterm)); } *************** *** 491,502 **** switch (c) { - /* TODO: which of these two should be used? */ - #if 0 case CAR: key = VTERM_KEY_ENTER; break; - #else - case CAR: c = NL; break; - #endif case ESC: key = VTERM_KEY_ESCAPE; break; case K_BS: key = VTERM_KEY_BACKSPACE; break; case K_DEL: key = VTERM_KEY_DEL; break; --- 546,552 ---- *************** *** 544,549 **** --- 594,625 ---- case K_RIGHT: key = VTERM_KEY_RIGHT; break; case K_UP: key = VTERM_KEY_UP; break; case TAB: key = VTERM_KEY_TAB; break; + + case K_MOUSEUP: /* TODO */ break; + case K_MOUSEDOWN: /* TODO */ break; + case K_MOUSELEFT: /* TODO */ break; + case K_MOUSERIGHT: /* TODO */ break; + + case K_LEFTMOUSE: /* TODO */ break; + case K_LEFTMOUSE_NM: /* TODO */ break; + case K_LEFTDRAG: /* TODO */ break; + case K_LEFTRELEASE: /* TODO */ break; + case K_LEFTRELEASE_NM: /* TODO */ break; + case K_MIDDLEMOUSE: /* TODO */ break; + case K_MIDDLEDRAG: /* TODO */ break; + case K_MIDDLERELEASE: /* TODO */ break; + case K_RIGHTMOUSE: /* TODO */ break; + case K_RIGHTDRAG: /* TODO */ break; + case K_RIGHTRELEASE: /* TODO */ break; + case K_X1MOUSE: /* TODO */ break; + case K_X1DRAG: /* TODO */ break; + case K_X1RELEASE: /* TODO */ break; + case K_X2MOUSE: /* TODO */ break; + case K_X2DRAG: /* TODO */ break; + case K_X2RELEASE: /* TODO */ break; + + /* TODO: handle all special keys and modifiers that terminal_loop() + * does not handle. */ } /* *************** *** 597,602 **** --- 673,680 ---- ScreenAttrs[off] = 0; ++off; } + else + pos.col = 0; screen_line(wp->w_winrow + pos.row, wp->w_wincol, pos.col, wp->w_width, FALSE); *** ../vim-8.0.0737/src/version.c 2017-07-19 19:55:54.494463778 +0200 --- src/version.c 2017-07-19 23:14:03.449704065 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 738, /**/ -- hundred-and-one symptoms of being an internet addict: 191. You rate eating establishments not by the quality of the food, but by the availability of electrical outlets for your PowerBook. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///