1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

35824: allow highlighting of just pasted text and put text from bracketed paste in cut buffers

This commit is contained in:
Oliver Kiddle 2015-07-23 05:30:36 +02:00
parent a925d036fc
commit b4aff3bc52
6 changed files with 40 additions and 10 deletions

View file

@ -1,12 +1,16 @@
2015-07-23 Oliver Kiddle <opk@zsh.org>
* 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 <schaefer@zsh.org>
* 35939: Joshua Krusell <js.shirin@gmail.com>:
* 35839: Joshua Krusell <js.shirin@gmail.com>:
Src/Modules/socket.c, Src/Modules/tcp.c: fix select polling in
ztcp and zsocket

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;