[Bob Rossi]
>> As for my enhancement, I was wondering if you'd consider making
>> it an option to highlight the entire current line when scrolling
>> around in the source window. The current behavior is to make
>> the current line number bold, but I find it much easier to
>> identify the current line when the highlighting extends all
>> the way across the screen.
> This seems like a reasonable idea. I'm wondering how this is best
> implemented though. Currently, CGDB only highlights the line number.
> This patch would have it highlight the entire line. How would the user
> switch back and forth between this functionality?
I was thinking a new option. More on this below.
> I applied your patch, and noticed that when breakpoints are set, and you
> go over them, the current line is no longer highlighted.
Yes, don't you agree that's a feature? :-)
When I first decided to change the behavior of the current line
highlighting, it was because I was scrolling the source to set
breakpoints, and found that with heavily indented code, the
boldfaced line number all the way on the left didn't help much.
When I enable a breakpoint, I appreciate immediate visual feedback,
so just allowing the normal breakpoint highlighting to work
normally seemed like a good solution to me. The minute you're
moving away from the breakpoint, the current line is highlighted
again, so I don't see what the problem is.
> I also noticed that if I do a search, cgdb segfaults.
That was because I had carelessly changed
if ( sources_syntax_on ) {
to
if (!(focus && sview->cur->sel_line == line) && sources_syntax_on) {
without considering the effects of branching into the "else"
block.
Anyway, the reason for the above change was that I wanted to
disable regular syntax highlighting for the current line. Now,
after trying it with the regular syntax highlighting enabled,
I'm not so sure that I even /want/ to disable regular syntax
highlighting. When using the reverse bit for highlighting the
current line, the syntax highlighting overlays quite nicely.
> I don't have time to look into these but if you want to think
> about how this option could nicely fit into CGDB from a users
> perspective, that would be useful.
I'm not sure what you mean. As I said above, I thought about adding
a new highlighting group for the current line (the on that is now
hardcoded to boldfaced text), and an option to let it extend across
the entire line.
By the way, here's my latest version of the patch. The only change
is the one I described above (fixing the segfault by letting the
normal highlighting overlay the current line highlighting).
--- cgdb-0.6.3/cgdb/src/sources.c.orig 2006-06-03 20:09:06.000000000 +0200
+++ cgdb-0.6.3/cgdb/src/sources.c 2006-10-05 18:04:40.829514437 +0200
@@ -675,17 +675,17 @@
/* Ordinary lines */
else{
if ( focus && sview->cur->sel_line == line )
- wattron(sview->win, A_BOLD);
-
+ {
+ if (hl_groups_get_attr (hl_groups_instance, HLG_CURRENT_LINE, &attr) == -1)
+ return -1;
+ wattron(sview->win, attr);
+ }
wprintw(sview->win, fmt, line+1);
-
- if ( focus && sview->cur->sel_line == line )
- wattroff(sview->win, A_BOLD);
- if (focus)
+ if (focus && sview->cur->sel_line != line)
wattron(sview->win, A_BOLD);
waddch(sview->win, VERT_LINE);
- if (focus)
+ if (focus && sview->cur->sel_line != line)
wattroff(sview->win, A_BOLD);
waddch(sview->win, ' ');
@@ -714,6 +714,9 @@
width-lwidth-2, sview->cur->sel_col);
}
}
+
+ if (focus && sview->cur->sel_line == line)
+ wattroff(sview->win, attr);
}
} else {
wprintw(sview->win, "%s\n", sview->cur->buf.tlines[line]);
--- cgdb-0.6.3/cgdb/src/highlight_groups.c.orig 2006-06-03 20:09:06.000000000 +0200
+++ cgdb-0.6.3/cgdb/src/highlight_groups.c 2006-10-05 17:57:10.172971689 +0200
@@ -93,6 +93,7 @@
{HLG_ENABLED_BREAKPOINT, A_BOLD, A_BOLD, COLOR_RED, COLOR_BLACK},
{HLG_DISABLED_BREAKPOINT, A_BOLD, A_BOLD, COLOR_YELLOW, COLOR_BLACK},
{HLG_LOGO, A_BOLD, A_BOLD, COLOR_BLUE, COLOR_BLACK},
+ {HLG_CURRENT_LINE, A_NORMAL, A_NORMAL, COLOR_BLACK, COLOR_WHITE},
{HLG_LAST, A_NORMAL, A_NORMAL, -1, -1}
};
@@ -115,6 +116,7 @@
{HLG_ENABLED_BREAKPOINT, A_BOLD, A_BOLD, COLOR_RED, -1},
{HLG_DISABLED_BREAKPOINT, A_BOLD, A_BOLD, COLOR_YELLOW, -1},
{HLG_LOGO, A_BOLD, A_BOLD, COLOR_BLUE, -1},
+ {HLG_CURRENT_LINE, A_REVERSE, A_REVERSE, -1, -1},
{HLG_LAST, A_NORMAL, A_NORMAL, -1, -1}
};
@@ -140,6 +142,7 @@
{HLG_ENABLED_BREAKPOINT, "Breakpoint"},
{HLG_DISABLED_BREAKPOINT, "DisabledBreakpoint"},
{HLG_LOGO, "Logo"},
+ {HLG_CURRENT_LINE, "CurrentLine"},
{HLG_LAST, "NULL"}
};
--- cgdb-0.6.3/cgdb/include/highlight_groups.h.orig 2006-06-03 20:09:05.000000000 +0200
+++ cgdb-0.6.3/cgdb/include/highlight_groups.h 2006-10-05 17:57:10.173971501 +0200
@@ -41,6 +41,7 @@
HLG_ENABLED_BREAKPOINT,
HLG_DISABLED_BREAKPOINT,
HLG_LOGO,
+ HLG_CURRENT_LINE,
HLG_LAST
};
--
Haakon
|