Discussion:
Highlighting arbitrary bits of text
Greg Edwards
2011-02-15 02:13:20 UTC
Permalink
Folks,

I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)

I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further notice

Example:

if (whatever) {
$var[1] = 123;
$var[3] = "abc"; # need to change this in many similar blocks further
down
$var[5] = 456;
$var[7] = "xyz"; # need to change this in many similar blocks further
down
$var[9] = "789;
}

.... (most likely split nedit screen here) ...

if(whatever2) {
$var[1] = etc etc


The red text above is an example of highlighting required. This would be
temporary, and disappear on command or when saving file.

Any suggestions appreciated.

Rgds,
--
Greg Edwards
gedwards2-***@public.gmane.org
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Tony Balinski
2011-02-15 07:01:59 UTC
Permalink
Post by Greg Edwards
Folks,
I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)
I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further
The red text above is an example of highlighting required. This would be
temporary, and disappear on command or when saving file.
Any suggestions appreciated.
Rgds,
--
Greg Edwards
--
http://www.nedit.org/mailman/listinfo/discuss
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Tony Balinski
2011-02-15 07:17:48 UTC
Permalink
Post by Greg Edwards
Folks,
I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)
I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further notice
(Sorry for the empty reply earlier: finger slipped over the iphone.)
This is what rangesets are for. You need to provide a macro that will
create a rangeset and provide ranges (start and end positions) for it.
You can also give it a color and a name. You can also write macros to
jump to a range in the set, add a searched string's occurrences to a
set etc. Look in nedit's help windows for more info; various people
have macro collections for this sort of thing too.
Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
e***@public.gmane.org
2011-02-15 11:48:44 UTC
Permalink
As an alternative to Tony's perfectly sensible response, you might like to look at the stuff about Calltips in the documentation.
(http://www.nedit.org/ftp/contrib/misc/nedit.pdf)
They would seem to allow you to achieve the effect you wish, albeit in a different way.
Which is better will depend on a number of factors, like how much effort you wish to put in, how dynamic the information is, personal preference, etc.

Have fun,
Evan




Communications with Accenture or any of its group companies ("Accenture Group") including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with company policy. Accenture Group does not accept service by e-mail of court proceedings, other processes or formal notices of any kind.

Accenture means Accenture (UK) Limited (registered number 4757301), Accenture Technology Solutions Limited (registered number 4442596), or Accenture HR Services Limited (registered number 3957974), all registered in England and Wales with registered addresses at 30 Fenchurch Street, London EC3M 3BD, as the case may be.



-----Original Message-----
From: discuss-bounces-***@public.gmane.org [mailto:discuss-bounces-***@public.gmane.org] On Behalf Of Tony Balinski
Sent: 2011-02-15 07:18
To: General NEdit discussion list
Subject: Re: Highlighting arbitrary bits of text
Post by Greg Edwards
Folks,
I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)
I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further notice
(Sorry for the empty reply earlier: finger slipped over the iphone.)
This is what rangesets are for. You need to provide a macro that will
create a rangeset and provide ranges (start and end positions) for it.
You can also give it a color and a name. You can also write macros to
jump to a range in the set, add a searched string's occurrences to a
set etc. Look in nedit's help windows for more info; various people
have macro collections for this sort of thing too.
Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Greg Edwards
2011-02-15 21:49:14 UTC
Permalink
Thanks all. I'm checking all that out.
Greg E
Post by e***@public.gmane.org
As an alternative to Tony's perfectly sensible response, you might like to
look at the stuff about Calltips in the documentation.
(http://www.nedit.org/ftp/contrib/misc/nedit.pdf)
They would seem to allow you to achieve the effect you wish, albeit in a different way.
Which is better will depend on a number of factors, like how much effort
you wish to put in, how dynamic the information is, personal preference,
etc.
Have fun,
Evan
Communications with Accenture or any of its group companies ("Accenture
Group") including telephone calls and emails (including content), may be
monitored by our systems for the purposes of security and the assessment of
internal compliance with company policy. Accenture Group does not accept
service by e-mail of court proceedings, other processes or formal notices of
any kind.
Accenture means Accenture (UK) Limited (registered number 4757301),
Accenture Technology Solutions Limited (registered number 4442596), or
Accenture HR Services Limited (registered number 3957974), all registered in
England and Wales with registered addresses at 30 Fenchurch Street, London
EC3M 3BD, as the case may be.
-----Original Message-----
Behalf Of Tony Balinski
Sent: 2011-02-15 07:18
To: General NEdit discussion list
Subject: Re: Highlighting arbitrary bits of text
Post by Greg Edwards
Folks,
I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)
I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further notice
(Sorry for the empty reply earlier: finger slipped over the iphone.)
This is what rangesets are for. You need to provide a macro that will
create a rangeset and provide ranges (start and end positions) for it.
You can also give it a color and a name. You can also write macros to
jump to a range in the set, add a searched string's occurrences to a
set etc. Look in nedit's help windows for more info; various people
have macro collections for this sort of thing too.
Tony
--
http://www.nedit.org/mailman/listinfo/discuss
This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete the
original. Any other use of the email by you is prohibited.
--
http://www.nedit.org/mailman/listinfo/discuss
--
Greg Edwards
gedwards2-***@public.gmane.org
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Greg Edwards
2011-03-02 23:11:44 UTC
Permalink
Nedit team,

Thanks to Tony Balinkski for pointing me at rangesets below. Nice to
discover your requirement is already implemented.

I had trouble finding anything on rangesets on nedit.org, and the email
archives don;t seem searchable, but plain Google for "nedit rangeset
examples" brought up quite a bit.

To help anyone else, below is my implementation of what I wanted, hacked
from old code of Tony's. A simple ability to mark up some lines and pieces
of code, to keep them easily visible in one paned window while I edit
similar code in another pane. This is only a fraction of what rangesets can
do.

This is on Mac OS X 10.6.6, nedit 5.5.

Cheers,
Greg


----- from ~/.nedit/autoload.nm ------


$line_marking = $empty_array
$line_marking["\n"] = $empty_array

define mark_area {

# Create range if we don't already have one
file = $file_path $file_name
if(!(file in $line_marking)) {
$line_marking[file] = rangeset_create()
$line_marking["\n"][file] = "orange"
rangeset_set_color($line_marking[file], $line_marking["\n"][file])
}

# Mark selection if we have one
if($selection_start >= 0 && $selection_left < 0) {
rangeset_add($line_marking[file])
return
}

# Mark current line.
rangeset_add($line_marking[file],\
search("^", $cursor, "regex", "backward"),\
search("$", $cursor, "regex"))
}

define unmark_area {

file = $file_path $file_name
if(file in $line_marking) {
i = rangeset_includes($line_marking[file], $cursor)
if(i) {
range = rangeset_range($line_marking[file], i)
rangeset_subtract($line_marking[file], range["start"],
range["end"])
}
}
}

define undefine_range {
file = $file_path $file_name
if((file in $line_marking)) {
rangeset_destroy($line_marking[file])
}
$line_marking = $empty_array
$line_marking["\n"] = $empty_array
}

---- from ~/.nedit/nedit.rc ------


Rangesets>Mark line/area:Shift+F1::: {\n\
mark_area()\n\
}\n\
Rangesets>Unmark line/area:Shift+F2::: {\n\
unmark_area()\n\
}\n\
Rangesets>Cancel rangeset:Shift+F3::: {\n\
undefine_range()\n\
}\n\




---------- Forwarded message ----------
From: Tony Balinski <ajbj-***@public.gmane.org>
Date: Tue, Feb 15, 2011 at 6:17 PM
Subject: Re: Highlighting arbitrary bits of text
Post by Greg Edwards
Folks,
I haven't researched this properly, apologies if it's obvious, or obviously
impossible :=)
I'd like to be able to highlight, in some colour or some background, some
small pieces of code in a program being edited with Nedit, to server as
reference and reminder for editing/checking/changing some other similar code
further down in a file. This seems to be in the domain of highlighting
syntax, but it's not constant highlighting of a set syntax style. I just
want to sweep over some bits of code and highlight them somehow, and have
them stay highlighted until further notice
(Sorry for the empty reply earlier: finger slipped over the iphone.)
This is what rangesets are for. You need to provide a macro that will
create a rangeset and provide ranges (start and end positions) for it.
You can also give it a color and a name. You can also write macros to
jump to a range in the set, add a searched string's occurrences to a
set etc. Look in nedit's help windows for more info; various people
have macro collections for this sort of thing too.
Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
--
Greg Edwards
gedwards2-***@public.gmane.org
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Continue reading on narkive:
Loading...