From b4aff3bc52e15be87304183b3ae959668192b48c Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 23 Jul 2015 05:30:36 +0200 Subject: 35824: allow highlighting of just pasted text and put text from bracketed paste in cut buffers --- ChangeLog | 6 +++++- Doc/Zsh/zle.yo | 3 +++ Src/Zle/iwidgets.list | 2 +- Src/Zle/zle.h | 3 ++- Src/Zle/zle_misc.c | 21 +++++++++++++++------ Src/Zle/zle_refresh.c | 15 ++++++++++++++- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2f704c67..ea9ebec5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,16 @@ 2015-07-23 Oliver Kiddle + * 35824: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list, Src/Zle/zle.h, + Src/Zle/zle_misc.c, Src/Zle/zle_refresh.c: allow highlighting of + just pasted text, put text from bracketed paste in cut buffers + * 35815: Functions/Misc/nslookup: fix for newer nslookup * 35814: Src/Zle/zle_main.c: POSTEDIT needs to be unmetafied 2015-07-22 Barton E. Schaefer - * 35939: Joshua Krusell : + * 35839: Joshua Krusell : Src/Modules/socket.c, Src/Modules/tcp.c: fix select polling in ztcp and zsocket diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index da8ee4721..ef73f4d55 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -2510,6 +2510,9 @@ a directory name. Note that suffix removal is configurable; the circumstances under which the suffix will be removed may differ for different completions. ) +item(tt(paste))( +Following a command to paste text, the characters that were inserted. +) enditem() tt(zle_highlight) may contain additional fields for controlling how diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list index 6a07212d0..ebcf31791 100644 --- a/Src/Zle/iwidgets.list +++ b/Src/Zle/iwidgets.list @@ -28,7 +28,7 @@ "beginning-of-history", beginningofhistory, 0 "beginning-of-line", beginningofline, 0 "beginning-of-line-hist", beginningoflinehist, 0 -"bracketed-paste", bracketedpaste, ZLE_MENUCMP | ZLE_KEEPSUFFIX +"bracketed-paste", bracketedpaste, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_YANKBEFORE "capitalize-word", capitalizeword, 0 "clear-screen", clearscreen, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND "complete-word", completeword, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index ab2428ea9..59f459185 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -429,8 +429,9 @@ struct region_highlight { * 0: region between point and mark * 1: isearch region * 2: suffix + * 3: pasted text */ -#define N_SPECIAL_HIGHLIGHTS (3) +#define N_SPECIAL_HIGHLIGHTS (4) #ifdef MULTIBYTE_SUPPORT diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c index 556ce5ba6..502e41e35 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -517,10 +517,12 @@ copyregionaskill(char **args) /* * kct: index into kill ring, or -1 for original cutbuffer of yank. - * yankb, yanke: mark the start and end of last yank in editing buffer. * yankcs marks the cursor position preceding the last yank */ -static int kct, yankb, yanke, yankcs; +static int kct, yankcs; + +/**/ +int yankb, yanke; /* mark the start and end of last yank in editing buffer. */ /* The original cutbuffer, either cutbuf or one of the vi buffers. */ static Cutbuffer kctbuf; @@ -778,10 +780,17 @@ bracketedpaste(char **args) ZLE_STRING_T wpaste; wpaste = stringaszleline((zmult == 1) ? pbuf : quotestring(pbuf, NULL, QT_BACKSLASH), 0, &n, NULL, NULL); - zmult = 1; - if (region_active) - killregion(zlenoargs); - doinsert(wpaste, n); + cuttext(wpaste, n, CUT_REPLACE); + if (!(zmod.flags & MOD_VIBUF)) { + kct = -1; + kctbuf = &cutbuf; + zmult = 1; + if (region_active) + killregion(zlenoargs); + yankcs = yankb = zlecs; + doinsert(wpaste, n); + yanke = zlecs; + } free(pbuf); free(wpaste); } return 0; diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index fe337993f..78046fb7b 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -318,6 +318,7 @@ zle_set_highlight(void) int region_atr_on_set = 0; int isearch_atr_on_set = 0; int suffix_atr_on_set = 0; + int paste_atr_on_set = 0; struct region_highlight *rhp; special_atr_on = default_atr_on = 0; @@ -337,7 +338,8 @@ zle_set_highlight(void) for (; *atrs; atrs++) { if (!strcmp(*atrs, "none")) { /* reset attributes for consistency... usually unnecessary */ - special_atr_on = default_atr_on = 0; + special_atr_on = default_atr_on = + paste_atr_on_set = 0; special_atr_on_set = region_atr_on_set = isearch_atr_on_set = suffix_atr_on_set = 1; } else if (strpfx("default:", *atrs)) { @@ -354,6 +356,9 @@ zle_set_highlight(void) } else if (strpfx("suffix:", *atrs)) { match_highlight(*atrs + 7, &(region_highlights[2].atr)); suffix_atr_on_set = 1; + } else if (strpfx("paste:", *atrs)) { + match_highlight(*atrs + 6, &(region_highlights[3].atr)); + paste_atr_on_set = 1; } } } @@ -367,6 +372,7 @@ zle_set_highlight(void) region_highlights[1].atr = TXTUNDERLINE; if (!suffix_atr_on_set) region_highlights[2].atr = TXTBOLDFACE; + /* paste defaults to 0 */ allocate_colour_buffer(); } @@ -1073,6 +1079,13 @@ zrefresh(void) region_highlights[2].start = region_highlights[2].end = -1; } + if (lastcmd & ZLE_YANK) { + region_highlights[3].start = yankb; + region_highlights[3].end = yanke; + } else { + region_highlights[3].start = region_highlights[3].end = -1; + } + if (clearlist && listshown > 0) { if (tccan(TCCLEAREOD)) { int ovln = vln, ovcs = vcs; -- cgit 1.4.1