aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/st.c b/st.c
index 8b65450..13226d8 100644
--- a/st.c
+++ b/st.c
@@ -703,6 +703,9 @@ selected(int x, int y) {
703 703
704void 704void
705selsnap(int mode, int *x, int *y, int direction) { 705selsnap(int mode, int *x, int *y, int direction) {
706 int newx, newy, xt, yt;
707 Glyph *gp;
708
706 switch(mode) { 709 switch(mode) {
707 case SNAP_WORD: 710 case SNAP_WORD:
708 /* 711 /*
@@ -710,36 +713,31 @@ selsnap(int mode, int *x, int *y, int direction) {
710 * beginning of a line. 713 * beginning of a line.
711 */ 714 */
712 for(;;) { 715 for(;;) {
713 if(direction < 0 && *x <= 0) { 716 newx = *x + direction;
714 if(*y > 0 && term.line[*y - 1][term.col-1].mode 717 newy = *y;
715 & ATTR_WRAP) { 718 if(!BETWEEN(newx, 0, term.col - 1)) {
716 *y -= 1; 719 newy += direction;
717 *x = term.col-1; 720 newx = (newx + term.col) % term.col;
718 } else { 721 if (!BETWEEN(newy, 0, term.row - 1))
719 break; 722 break;
720 } 723
721 } 724 if(direction > 0)
722 if(direction > 0 && *x >= term.col-1) { 725 yt = *y, xt = *x;
723 if(*y < term.row-1 && term.line[*y][*x].mode 726 else
724 & ATTR_WRAP) { 727 yt = newy, xt = newx;
725 *y += 1; 728 if(!(term.line[yt][xt].mode & ATTR_WRAP))
726 *x = 0;
727 } else {
728 break; 729 break;
729 }
730 } 730 }
731 731
732 if(term.line[*y][*x+direction].mode & ATTR_WDUMMY) { 732 if (newx >= tlinelen(newy))
733 *x += direction; 733 break;
734 continue;
735 }
736 734
737 if(*x >= tlinelen(*y) || strchr(worddelimiters, 735 gp = &term.line[newy][newx];
738 term.line[*y][*x+direction].c[0])) { 736 if (!(gp->mode & ATTR_WDUMMY) && strchr(worddelimiters, gp->c[0]))
739 break; 737 break;
740 }
741 738
742 *x += direction; 739 *x = newx;
740 *y = newy;
743 } 741 }
744 break; 742 break;
745 case SNAP_LINE: 743 case SNAP_LINE: