3333 * while, if the terminal window is visible, the screen contents is drawn.
3434 *
3535 * TODO:
36+ * - To set BS correctly, check get_stty(); Pass the fd of the pty.
3637 * - include functions from #1871
3738 * - do not store terminal buffer in viminfo. Or prefix term:// ?
38- * - Make CTRL-W . send CTRL-W to terminal?
3939 * - Add a scrollback buffer (contains lines to scroll off the top).
4040 * Can use the buf_T lines, store attributes somewhere else?
4141 * - When the job ends:
5050 * - when closing window and job has not ended, make terminal hidden?
5151 * - don't allow exiting Vim when a terminal is still running a job
5252 * - use win_del_lines() to make scroll-up efficient.
53- * - command line completion for :terminal
5453 * - add test for giving error for invalid 'termsize' value.
5554 * - support minimal size when 'termsize' is "rows*cols".
5655 * - support minimal size when 'termsize' is empty?
@@ -458,6 +457,24 @@ term_convert_key(int c, char *buf)
458457 return (int )vterm_output_read (vterm , buf , KEY_BUF_LEN );
459458}
460459
460+ /*
461+ * Get a key from the user without mapping.
462+ * TODO: use terminal mode mappings.
463+ */
464+ static int
465+ term_vgetc ()
466+ {
467+ int c ;
468+
469+ ++ no_mapping ;
470+ ++ allow_keys ;
471+ got_int = FALSE;
472+ c = vgetc ();
473+ -- no_mapping ;
474+ -- allow_keys ;
475+ return c ;
476+ }
477+
461478/*
462479 * Wait for input and send it to the job.
463480 * Return when the start of a CTRL-W command is typed or anything else that
@@ -481,17 +498,28 @@ terminal_loop(void)
481498 /* TODO: skip screen update when handling a sequence of keys. */
482499 update_screen (0 );
483500 update_cursor (curbuf -> b_term , FALSE);
484- ++ no_mapping ;
485- ++ allow_keys ;
486- got_int = FALSE;
487- c = vgetc ();
488- -- no_mapping ;
489- -- allow_keys ;
501+ c = term_vgetc ();
490502
491503 if (c == (termkey == 0 ? Ctrl_W : termkey ))
492504 {
493- stuffcharReadbuff (Ctrl_W );
494- return ;
505+ #ifdef FEAT_CMDL_INFO
506+ if (add_to_showcmd (c ))
507+ out_flush ();
508+ #endif
509+ c = term_vgetc ();
510+ #ifdef FEAT_CMDL_INFO
511+ clear_showcmd ();
512+ #endif
513+
514+ if (termkey == 0 && c == '.' )
515+ /* "CTRL-W .": send CTRL-W to the job */
516+ c = Ctrl_W ;
517+ else if (termkey == 0 || c != termkey )
518+ {
519+ stuffcharReadbuff (Ctrl_W );
520+ stuffcharReadbuff (c );
521+ return ;
522+ }
495523 }
496524
497525 /* Catch keys that need to be handled as in Normal mode. */
0 commit comments