commit e30efa5b51e928bd4c4e841942bd1292c04fb758
parent 9f866a0318605e4a46efbec767ba77436058461b
Author: Rafael Garcia <rafael.garcia.gallego@gmail.com>
Date:   Sun,  5 Jun 2011 20:18:24 +0200
Fix m_(next|prev)line issue reported by cls, it now determines position in the next/previous line with scren size rather than bit size. Vline still pending.
Diffstat:
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/config.mk b/config.mk
@@ -13,10 +13,10 @@ LIBS = -L/usr/lib -lc -lncurses
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE
-CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
-LDFLAGS = -s ${LIBS}
-#CFLAGS = -ggdb -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
-#LDFLAGS = ${LIBS}
+#CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
+#LDFLAGS = -s ${LIBS}
+CFLAGS = -ggdb -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
+LDFLAGS = ${LIBS}
 
 # Solaris
 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/sandy.c b/sandy.c
@@ -1565,9 +1565,14 @@ m_prevword(Filepos pos) {
 
 Filepos /* Advance one line, or to eol if at last line */
 m_nextline(Filepos pos) {
+	int ivchar, ichar;
+
+	for(ivchar=ichar=0; ichar < pos.o;ichar++)
+		ivchar+=VLEN(pos.l->c[ichar], (ivchar%(cols-1)));
+
 	if(pos.l->next){
-		pos.l=pos.l->next;
-		if(pos.o>pos.l->len) pos.o=pos.l->len;
+		for(pos.l=pos.l->next, pos.o=ichar=0; ichar<ivchar && pos.o < pos.l->len; pos.o++)
+			ichar+=VLEN(pos.l->c[pos.o], ichar);
 		FIXNEXT(pos);
 	} else pos.o=pos.l->len;
 	return pos;
@@ -1575,9 +1580,14 @@ m_nextline(Filepos pos) {
 
 Filepos /* Backup one line, or to bol if at first line */
 m_prevline(Filepos pos) {
+	int ivchar, ichar;
+
+	for(ivchar=ichar=0; ichar < pos.o;ichar++)
+		ivchar+=VLEN(pos.l->c[ichar], (ivchar%(cols-1)));
+
 	if(pos.l->prev){
-		pos.l=pos.l->prev;
-		if(pos.o>pos.l->len) pos.o=pos.l->len;
+		for(pos.l=pos.l->prev, pos.o=ichar=0; ichar<ivchar && pos.o < pos.l->len; pos.o++)
+			ichar+=VLEN(pos.l->c[pos.o], ichar);
 		FIXNEXT(pos);
 	} else pos.o=0;
 	return pos;