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 | Move calls to selsnap into selnormalize (diff) | |
| download | st-51466e019a67e9319e6c5a7fa4205842ca860b71.tar.gz 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>
Diffstat (limited to '')
| -rw-r--r-- | st.c | 11 |
1 files changed, 9 insertions, 2 deletions
| @@ -709,7 +709,8 @@ selected(int x, int y) { | |||
| 709 | void | 709 | void |
| 710 | selsnap(int mode, int *x, int *y, int direction) { | 710 | selsnap(int mode, int *x, int *y, int direction) { |
| 711 | int newx, newy, xt, yt; | 711 | int newx, newy, xt, yt; |
| 712 | Glyph *gp; | 712 | bool delim, prevdelim; |
| 713 | Glyph *gp, *prevgp; | ||
| 713 | 714 | ||
| 714 | switch(mode) { | 715 | switch(mode) { |
| 715 | case SNAP_WORD: | 716 | case SNAP_WORD: |
| @@ -717,6 +718,8 @@ selsnap(int mode, int *x, int *y, int direction) { | |||
| 717 | * Snap around if the word wraps around at the end or | 718 | * Snap around if the word wraps around at the end or |
| 718 | * beginning of a line. | 719 | * beginning of a line. |
| 719 | */ | 720 | */ |
| 721 | prevgp = &term.line[*y][*x]; | ||
| 722 | prevdelim = strchr(worddelimiters, prevgp->c[0]) != NULL; | ||
| 720 | for(;;) { | 723 | for(;;) { |
| 721 | newx = *x + direction; | 724 | newx = *x + direction; |
| 722 | newy = *y; | 725 | newy = *y; |
| @@ -738,11 +741,15 @@ selsnap(int mode, int *x, int *y, int direction) { | |||
| 738 | break; | 741 | break; |
| 739 | 742 | ||
| 740 | gp = &term.line[newy][newx]; | 743 | gp = &term.line[newy][newx]; |
| 741 | if (!(gp->mode & ATTR_WDUMMY) && strchr(worddelimiters, gp->c[0])) | 744 | delim = strchr(worddelimiters, gp->c[0]) != NULL; |
| 745 | if(!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim | ||
| 746 | || (delim && gp->c[0] != prevgp->c[0]))) | ||
| 742 | break; | 747 | break; |
| 743 | 748 | ||
| 744 | *x = newx; | 749 | *x = newx; |
| 745 | *y = newy; | 750 | *y = newy; |
| 751 | prevgp = gp; | ||
| 752 | prevdelim = delim; | ||
| 746 | } | 753 | } |
| 747 | break; | 754 | break; |
| 748 | case SNAP_LINE: | 755 | case SNAP_LINE: |
