shithub: riscv

Download patch

ref: 217e8a06198cf6681fb0c38c26f34d96ae4302f6
parent: 676298b16ba58991d1a859e0f519a967d619ccef
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Sep 3 18:37:45 EDT 2018

vt: fix selrange() to recover whitespace indention

--- a/sys/src/cmd/vt/main.c
+++ b/sys/src/cmd/vt/main.c
@@ -915,16 +915,25 @@
 Rune *
 selrange(Rune *r, int x0, int y0, int x1, int y1)
 {
-	Rune *p, *sr, *er;
+	Rune *s, *e;
+	int z, p;
 
-	p = r;
-	sr = onscreenr(x0, y0);
-	er = onscreenr(x1, y1);
-	for(; sr != er; sr++)
-		if(*sr)
-			*p++ = *sr;
-	*p = 0;
-	return p;
+	s = onscreenr(x0, y0);
+	e = onscreenr(x1, y1);
+	for(z = p = 0; s < e; s++){
+		if(*s){
+			if(*s == '\n')
+				z = p = 0;
+			else if(p++ == 0){
+				while(z-- > 0) *r++ = ' ';
+			}
+			*r++ = *s;
+		} else {
+			z++;
+		}
+	}
+	*r = 0;
+	return r;
 }
 
 Rune*