shithub: orca

Download patch

ref: ba578071fa5b685ecb4fe6a4f7befcbd0858d491
parent: 92967a2616a0326e21698685a7295c931cf18eb8
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Feb 16 11:15:35 EST 2020

plan9: highlight same characters on the field

--- a/plan9.c
+++ b/plan9.c
@@ -54,6 +54,7 @@
 	Numcolors,
 
 	/* this might become a bad idea in the future */
+	Mark_flag_group_highlight = 1<<6,
 	Mark_flag_selected = 1<<7,
 };
 
@@ -316,9 +317,9 @@
 	Point p, top, bot;
 	int x, y, rx, ry, i;
 	int oldbg, oldfg, bg, fg, attr, off;
-	bool selected;
+	bool selected, grouphl;
 	char s[32];
-	Rune c;
+	Rune c, csel;
 
 	p = addpt(screen->r.min, Pt(Txtoff, Txtoff));
 	top = p;
@@ -337,6 +338,11 @@
 		draw(screen, r, color[Dback], nil, ZP);
 	}
 
+	off = field.width*cury + curx;
+	csel = field.buffer[off];
+	if (csel == '.' || (mbuf.buffer[off] & (Mark_flag_input|Mark_flag_output)) != 0)
+		csel = 0;
+
 	bg = -1;
 	fg = -1;
 	for (y = 0; y < field.height && p.y < bot.y-charh; y++) {
@@ -354,7 +360,14 @@
 			else
 				attr &= ~Mark_flag_selected;
 
-			if (!complete && c == copyfield.buffer[off] && attr == mscr.buffer[off]) {
+			/* highlight the same char */
+			grouphl = c != '.' && csel == c && (x != curx || y != cury);
+			if (grouphl)
+				attr |= Mark_flag_group_highlight;
+			else
+				attr &= ~Mark_flag_group_highlight;
+
+			if (!grouphl && !complete && c == copyfield.buffer[off] && attr == mscr.buffer[off]) {
 				if (i > 0) {
 					p = runestringnbg(screen, p, color[oldfg], ZP, font, linebuf, i, color[oldbg], ZP);
 					i = 0;
@@ -367,7 +380,7 @@
 			mscr.buffer[off] = attr;
 
 			bg = selected ? Dbinv : Dback;
-			fg = selected ? Dfinv : Dfmed;
+			fg = selected ? Dfinv : (grouphl ? Dbinv: Dfmed);
 
 			if (c == '.')
 				c = dot[dotstyle];
@@ -379,7 +392,7 @@
 					c = rulerstyle == Snone ? dot[dotstyle] : ruler[rulerstyle][ry*3+rx];
 				}
 				fg = Dflow;
-			} else if (!selected) {
+			} else if (!selected && !grouphl) {
 				if (c == '#') {
 					fg = Dfmed;
 				} else {