diff options
| author | Ivan Delalande <colona@ycc.fr> | 2014-08-20 21:20:44 +0200 | 
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-21 17:50:31 +0200 | 
| commit | 51466e019a67e9319e6c5a7fa4205842ca860b71 (patch) | |
| tree | 201223c8b9a5c0940b97d24da5595b3bbe1cacd4 | |
| parent | c490a60b804f467490cd4d8275a181dc37edef9f (diff) | |
| download | st-51466e019a67e9319e6c5a7fa4205842ca860b71.tar.xz st-51466e019a67e9319e6c5a7fa4205842ca860b71.zip  | |
Change the behavior of word snapping on delimiters
This makes any sequence of identical delimiters be considered a single
word in word-snapping mode. This seems more coherent for this mode and
is similar to what xterm does.
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
| -rw-r--r-- | st.c | 11 | 
1 files changed, 9 insertions, 2 deletions
@@ -709,7 +709,8 @@ selected(int x, int y) {  void  selsnap(int mode, int *x, int *y, int direction) {  	int newx, newy, xt, yt; -	Glyph *gp; +	bool delim, prevdelim; +	Glyph *gp, *prevgp;  	switch(mode) {  	case SNAP_WORD: @@ -717,6 +718,8 @@ selsnap(int mode, int *x, int *y, int direction) {  		 * Snap around if the word wraps around at the end or  		 * beginning of a line.  		 */ +		prevgp = &term.line[*y][*x]; +		prevdelim = strchr(worddelimiters, prevgp->c[0]) != NULL;  		for(;;) {  			newx = *x + direction;  			newy = *y; @@ -738,11 +741,15 @@ selsnap(int mode, int *x, int *y, int direction) {  				break;  			gp = &term.line[newy][newx]; -			if (!(gp->mode & ATTR_WDUMMY) && strchr(worddelimiters, gp->c[0])) +			delim = strchr(worddelimiters, gp->c[0]) != NULL; +			if(!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim +					|| (delim && gp->c[0] != prevgp->c[0])))  				break;  			*x = newx;  			*y = newy; +			prevgp = gp; +			prevdelim = delim;  		}  		break;  	case SNAP_LINE:  | 
