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
54 Numcolors,54 Numcolors,
55 55
56 /* this might become a bad idea in the future */56 /* this might become a bad idea in the future */
57 Mark_flag_group_highlight = 1<<6,
57 Mark_flag_selected = 1<<7,58 Mark_flag_selected = 1<<7,
58};59};
59 60
@@ -316,9 +317,9 @@ redraw(int complete) · 256 unmodified lines
316 Point p, top, bot;317 Point p, top, bot;
317 int x, y, rx, ry, i;318 int x, y, rx, ry, i;
318 int oldbg, oldfg, bg, fg, attr, off;319 int oldbg, oldfg, bg, fg, attr, off;
319 bool selected;320 bool selected, grouphl;
320 char s[32];321 char s[32];
321 Rune c;322 Rune c, csel;
322 323
323 p = addpt(screen->r.min, Pt(Txtoff, Txtoff));324 p = addpt(screen->r.min, Pt(Txtoff, Txtoff));
324 top = p;325 top = p;
@@ -337,6 +338,11 @@ redraw(int complete) · 12 unmodified lines
337 draw(screen, r, color[Dback], nil, ZP);338 draw(screen, r, color[Dback], nil, ZP);
338 }339 }
339 340
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
340 bg = -1;346 bg = -1;
341 fg = -1;347 fg = -1;
342 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {348 for (y = 0; y < field.height && p.y < bot.y-charh; y++) {
@@ -354,7 +360,14 @@ redraw(int complete) · 11 unmodified lines
354 else360 else
355 attr &= ~Mark_flag_selected;361 attr &= ~Mark_flag_selected;
356 362
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]) {
358 if (i > 0) {371 if (i > 0) {
359 p = runestringnbg(screen, p, color[oldfg], ZP, font, linebuf, i, color[oldbg], ZP);372 p = runestringnbg(screen, p, color[oldfg], ZP, font, linebuf, i, color[oldbg], ZP);
360 i = 0;373 i = 0;
@@ -367,7 +380,7 @@ redraw(int complete) · 6 unmodified lines
367 mscr.buffer[off] = attr;380 mscr.buffer[off] = attr;
368 381
369 bg = selected ? Dbinv : Dback;382 bg = selected ? Dbinv : Dback;
370 fg = selected ? Dfinv : Dfmed;383 fg = selected ? Dfinv : (grouphl ? Dbinv: Dfmed);
371 384
372 if (c == '.')385 if (c == '.')
373 c = dot[dotstyle];386 c = dot[dotstyle];
@@ -379,7 +392,7 @@ redraw(int complete) · 5 unmodified lines
379 c = rulerstyle == Snone ? dot[dotstyle] : ruler[rulerstyle][ry*3+rx];392 c = rulerstyle == Snone ? dot[dotstyle] : ruler[rulerstyle][ry*3+rx];
380 }393 }
381 fg = Dflow;394 fg = Dflow;
382 } else if (!selected) {395 } else if (!selected && !grouphl) {
383 if (c == '#') {396 if (c == '#') {
384 fg = Dfmed;397 fg = Dfmed;
385 } else {398 } 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