Introduction
Introduction Statistics Contact Development Disclaimer Help
tRefactor selsnap SNAP_WORD. - st - [fork] customized build of st, the simple t…
git clone git://src.adamsgaard.dk/st
Log
Files
Refs
README
LICENSE
---
commit 5159d55c631cd1179bd2f872859d4540668745b9
parent 6fd887077e29efd789499e06193314d7abdcac38
Author: Colona <[email protected]>
Date: Thu, 5 Jun 2014 06:32:01 +0200
Refactor selsnap SNAP_WORD.
Refactor the SNAP_WORD part in selsnap, and fix a bug that caused the word
delimiters to be ignored if it was at the very beginning or end of a wrapped
line.
Signed-off-by: Roberto E. Vargas Caballero <[email protected]>
Diffstat:
M st.c | 44 +++++++++++++++--------------…
1 file changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/st.c b/st.c
t@@ -703,6 +703,9 @@ selected(int x, int y) {
void
selsnap(int mode, int *x, int *y, int direction) {
+ int newx, newy, xt, yt;
+ Glyph *gp;
+
switch(mode) {
case SNAP_WORD:
/*
t@@ -710,36 +713,31 @@ selsnap(int mode, int *x, int *y, int direction) {
* beginning of a line.
*/
for(;;) {
- if(direction < 0 && *x <= 0) {
- if(*y > 0 && term.line[*y - 1][term.col-1].mode
- & ATTR_WRAP) {
- *y -= 1;
- *x = term.col-1;
- } else {
+ newx = *x + direction;
+ newy = *y;
+ if(!BETWEEN(newx, 0, term.col - 1)) {
+ newy += direction;
+ newx = (newx + term.col) % term.col;
+ if (!BETWEEN(newy, 0, term.row - 1))
break;
- }
- }
- if(direction > 0 && *x >= term.col-1) {
- if(*y < term.row-1 && term.line[*y][*x].mode
- & ATTR_WRAP) {
- *y += 1;
- *x = 0;
- } else {
+
+ if(direction > 0)
+ yt = *y, xt = *x;
+ else
+ yt = newy, xt = newx;
+ if(!(term.line[yt][xt].mode & ATTR_WRAP))
break;
- }
}
- if(term.line[*y][*x+direction].mode & ATTR_WDUMMY) {
- *x += direction;
- continue;
- }
+ if (newx >= tlinelen(newy))
+ break;
- if(*x >= tlinelen(*y) || strchr(worddelimiters,
- term.line[*y][*x+direction].c[0])) {
+ gp = &term.line[newy][newx];
+ if (!(gp->mode & ATTR_WDUMMY) && strchr(worddelimiters…
break;
- }
- *x += direction;
+ *x = newx;
+ *y = newy;
}
break;
case SNAP_LINE:
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.