shithub: vdiff

Download patch

ref: 3637e076560fdb3cb06ccd88ab08c530f931c558
parent: 5463484216a9be9d57acdecf1e02d16843fc2f65
author: phil9 <telephil9@gmail.com>
date: Wed Oct 6 06:53:24 EDT 2021

fix utf8 not rendering properly (thanks igor)

	All characters were treated as ascii leading to wrong rendering when
	diff contained multi-byte characters.
	We now use Rune instead of chars which fixes all rendering.

--- a/vdiff.c
+++ b/vdiff.c
@@ -55,6 +55,7 @@
 {
 	Image *bg;
 	Point p;
+	Rune  rn;
 	char *s;
 
 	bg = cols[l->t];
@@ -66,8 +67,10 @@
 		else if((p.x+Hpadding+stringwidth(font, " ")+stringwidth(font, ellipsis)>=textr.max.x)){
 			string(screen, p, display->black, ZP, font, ellipsis);
 			break;
-		}else
-			p = stringn(screen, p, display->black, ZP, font, s, 1);
+		}else{
+			s += chartorune(&rn, s) - 1;
+			p = runestringn(screen, p, display->black, ZP, font, &rn, 1);
+		}
 	}
 }