History

plan9: highlight same characters on the field

Sigrid Haflínudóttir committed 6 years ago

Commit ba578071 parent 92967a21 file · +18 −5Browse files

Unified · Split

plan9.c+18−5
@@ -54,6 +54,7 @@ enum { · 53 unmodified lines
5454 Numcolors,
5555
5656 /* this might become a bad idea in the future */
57+ Mark_flag_group_highlight = 1<<6,
5758 Mark_flag_selected = 1<<7,
5859 };
5960
@@ -316,9 +317,9 @@ redraw(int complete) · 256 unmodified lines
316317 Point p, top, bot;
317318 int x, y, rx, ry, i;
318319 int oldbg, oldfg, bg, fg, attr, off;
319− bool selected;
320+ bool selected, grouphl;
320321 char s[32];
321− Rune c;
322+ Rune c, csel;
322323
323324 p = addpt(screen->r.min, Pt(Txtoff, Txtoff));
324325 top = p;
@@ -337,6 +338,11 @@ redraw(int complete) · 12 unmodified lines
337338 draw(screen, r, color[Dback], nil, ZP);
338339 }
339340
341+ off = field.width*cury + curx;
342+ csel = field.buffer[off];
343+ if (csel == '.' || (mbuf.buffer[off] & (Mark_flag_input|Mark_flag_output)) != 0)
344+ csel = 0;
345+
340346 bg = -1;
341347 fg = -1;
342348 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {
@@ -354,7 +360,14 @@ redraw(int complete) · 11 unmodified lines
354360 else
355361 attr &= ~Mark_flag_selected;
356362
357− if (!complete && c == copyfield.buffer[off] && attr == mscr.buffer[off]) {
363+ /* highlight the same char */
364+ grouphl = c != '.' && csel == c && (x != curx || y != cury);
365+ if (grouphl)
366+ attr |= Mark_flag_group_highlight;
367+ else
368+ attr &= ~Mark_flag_group_highlight;
369+
370+ if (!grouphl && !complete && c == copyfield.buffer[off] && attr == mscr.buffer[off]) {
358371 if (i > 0) {
359372 p = runestringnbg(screen, p, color[oldfg], ZP, font, linebuf, i, color[oldbg], ZP);
360373 i = 0;
@@ -367,7 +380,7 @@ redraw(int complete) · 6 unmodified lines
367380 mscr.buffer[off] = attr;
368381
369382 bg = selected ? Dbinv : Dback;
370− fg = selected ? Dfinv : Dfmed;
383+ fg = selected ? Dfinv : (grouphl ? Dbinv: Dfmed);
371384
372385 if (c == '.')
373386 c = dot[dotstyle];
@@ -379,7 +392,7 @@ redraw(int complete) · 5 unmodified lines
379392 c = rulerstyle == Snone ? dot[dotstyle] : ruler[rulerstyle][ry*3+rx];
380393 }
381394 fg = Dflow;
382− } else if (!selected) {
395+ } else if (!selected && !grouphl) {
383396 if (c == '#') {
384397 fg = Dfmed;
385398 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t