Skip to content

Commit c9456ce

Browse files
committed
patch 8.0.0823: cannot paste text into a terminal window
Problem: Cannot paste text into a terminal window. Solution: Make CTRL-W " work.
1 parent d09be32 commit c9456ce

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

src/terminal.c

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* that buffer, attributes come from the scrollback buffer tl_scrollback.
3737
*
3838
* TODO:
39-
* - Make CTRL-W "" paste register content to the job?
4039
* - in bash mouse clicks are inserting characters.
4140
* - mouse scroll: when over other window, scroll that window.
4241
* - For the scrollback buffer store lines in the buffer, only attributes in
@@ -67,6 +66,7 @@
6766
* mouse in the Terminal window for copy/paste.
6867
* - when 'encoding' is not utf-8, or the job is using another encoding, setup
6968
* conversions.
69+
* - update ":help function-list" for terminal functions.
7070
* - In the GUI use a terminal emulator for :!cmd.
7171
*/
7272

@@ -864,6 +864,50 @@ position_cursor(win_T *wp, VTermPos *pos)
864864
wp->w_valid |= (VALID_WCOL|VALID_WROW);
865865
}
866866

867+
/*
868+
* Handle CTRL-W "": send register contents to the job.
869+
*/
870+
static void
871+
term_paste_register(int prev_c UNUSED)
872+
{
873+
int c;
874+
list_T *l;
875+
listitem_T *item;
876+
long reglen = 0;
877+
int type;
878+
879+
#ifdef FEAT_CMDL_INFO
880+
if (add_to_showcmd(prev_c))
881+
if (add_to_showcmd('"'))
882+
out_flush();
883+
#endif
884+
c = term_vgetc();
885+
#ifdef FEAT_CMDL_INFO
886+
clear_showcmd();
887+
#endif
888+
889+
/* CTRL-W "= prompt for expression to evaluate. */
890+
if (c == '=' && get_expr_register() != '=')
891+
return;
892+
893+
l = (list_T *)get_reg_contents(c, GREG_LIST);
894+
if (l != NULL)
895+
{
896+
type = get_reg_type(c, &reglen);
897+
for (item = l->lv_first; item != NULL; item = item->li_next)
898+
{
899+
char_u *s = get_tv_string(&item->li_tv);
900+
901+
channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN,
902+
s, STRLEN(s), NULL);
903+
if (item->li_next != NULL || type == MLINE)
904+
channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN,
905+
(char_u *)"\r", 1, NULL);
906+
}
907+
list_free(l);
908+
}
909+
}
910+
867911
/*
868912
* Returns TRUE if the current window contains a terminal and we are sending
869913
* keys to the job.
@@ -912,6 +956,8 @@ terminal_loop(void)
912956

913957
if (c == (termkey == 0 ? Ctrl_W : termkey))
914958
{
959+
int prev_c = c;
960+
915961
#ifdef FEAT_CMDL_INFO
916962
if (add_to_showcmd(c))
917963
out_flush();
@@ -930,11 +976,16 @@ terminal_loop(void)
930976
/* "CTRL-W .": send CTRL-W to the job */
931977
c = Ctrl_W;
932978
}
933-
else if (termkey == 0 && c == 'N')
979+
else if (c == 'N')
934980
{
935981
term_enter_terminal_mode();
936982
return FAIL;
937983
}
984+
else if (c == '"')
985+
{
986+
term_paste_register(prev_c);
987+
continue;
988+
}
938989
else if (termkey == 0 || c != termkey)
939990
{
940991
stuffcharReadbuff(Ctrl_W);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
823,
772774
/**/
773775
822,
774776
/**/

0 commit comments

Comments
 (0)