AW: Highlight current line
Ludger.Papenkort at dlr.de
Ludger.Papenkort at dlr.de
Wed Nov 29 14:06:06 CET 2006
Tony, You haven't misread my request, You are right with the triple click, but i want the cursor line to be highlighted, even the cursor moves to the next (down) or previous line (up), and the highlight should also move up and down to the next or previous line.
Example:
line1
[li|ne2] <--- line contains cursor and is highlighted
line3
line4
now cursor down
line1
line2
[li|ne3] <--- now this line contains the cursor and is highlighted (or backlighted)
line4
and so on.
Thank You,
Ludger
-----Ursprüngliche Nachricht-----
Von: discuss-bounces at nedit.org [mailto:discuss-bounces at nedit.org] Im Auftrag von Tony Balinski
Gesendet: Mittwoch, 29. November 2006 12:57
An: General NEdit discussion list
Betreff: RE: Highlight current line
Quoting Michael Smith <smithm at netapps.com.au>:
> On Wed, 29 Nov 2006 11:27:39 +0100
> <Ludger.Papenkort at dlr.de> wrote:
>
> > Hallo,
> >
> > how is it possible to highlight the current line ?
> >
> > Sometimes it is very usefull to highlight the line where the cursor is.
> > This feature would help to compare the text (numbers, tables or what
> > else) in the editor window with original text written on paper. You
> > could go through the text line by line with the cursor-down-key an
> > compare the highlighted line with the original.
> >
> > Is there a possibility to do that with a macro ?
>
> Yes
>
> define select_line
> {
> start = search("\n",$cursor,"backward")
> end = search("\n",$cursor,"forward")
> select(start + 1,end + 1)
> }
>
> It could do with some refinement though. I don't think it works well on the
> first or last line of a file.
>
> No doubt others will post improved versions from their own collections
> shortly :)
Ha! If that's enough, then triple-click the line! I must say, I misread the
OP, thinking that this was a request to keep the cursor's line highlighted at
all times (which could still be useful for Ludger). But if you just want to be
able to add/remove a highlight on a line that just happens to be current, I
think Joerg has macros do that. Alternatively, you can set up this macro,
which just uses a rangeset instead of a selection for the highlighting:
# toggle the rangeset "Highlighted Lines" for the current line or selection
if ($selection_start >= 0)
{
left = $selection_start
right = $selection_end - 1
}
else
{
left = $cursor
right = $cursor
}
# extend to full lines
left = search("\n", left - 1, "backward") + 1
right = search("\n", right, "forward")
if (right < 0)
right = $text_length
else
++right
# get our rangeset
rss = rangeset_get_by_name("Highlighted Lines")
if (rss[] == 0)
{
# no such rangeset: create it
rs = rangeset_create()
if (!rs)
return dialog("Failed: could not create rangeset 'Highlighted Lines'")
rangeset_set_color(rs, "lightgreen") # choose a color here
rangeset_set_name(rs, "Highlighted Lines")
}
else if (rss[] > 1)
{
# more than one rangeset with that name
return dialog("Failed: more than one rangeset called 'Highlighted Lines'")
}
else
{
# all OK
rs = rss[0]
}
# remove the area
if (rangeset_includes(rs, $cursor) != 0)
rangeset_subtract(rs, left, right)
else
rangeset_add(rs, left, right)
--
NEdit Discuss mailing list - Discuss at nedit.org
http://www.nedit.org/mailman/listinfo/discuss
More information about the Discuss
mailing list