Bracket matching

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Bracket matching

Jim Byrnes-4
Currently jedit highlights a matching bracket by putting a red box
around it.  My eyes are getting old and sometimes I have trouble
spotting this indicator. Is it possible to set jedit to change the
background color between the pair of brackets?

Regards, Jim

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: Bracket matching

FORREST EVANS
Go to "Global Options->Text Area" and change the color in the box beside the "highlight matching elements" option.

Thanks,
Forrest

Sent from my Dell Optiplex 760 PC with Windows XP Professional SP3 and Microsoft Outlook 2007.


-----Original Message-----
From: Jim Byrnes [mailto:[hidden email]]
Sent: Monday, April 04, 2011 7:45 PM
To: [hidden email]
Subject: [ jEdit-users ] Bracket matching

Currently jedit highlights a matching bracket by putting a red box
around it.  My eyes are getting old and sometimes I have trouble
spotting this indicator. Is it possible to set jedit to change the
background color between the pair of brackets?

Regards, Jim

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: Bracket matching

Vampire-3
Administrator
In reply to this post by Jim Byrnes-4
Hi Jim,

the red box is a customization by you, isn't it?
For me it is a black box.
Nevertheless, you can only influence the color of that box around the
brackets.
If you want to have the whole block highlighted with a background color,
you need to provide a TextAreaExtension that does this painting. I don't
know whether there is a plugin around doing this in the way you want it.
Theoretically you could even do it with a BeanShell script like you can
do anything that you can do in a plugin also in a BeanShell script, but
a plugin would probably be more suitable here. The Highlighter plugin
could maybe serve as a starting point for developing such a plugin,
combined with org.gjt.sp.jedit.textarea.StructureMatcher.Highlight which
is the class doing the box-around highlighting for the matching brackets.

Regards
Vampire

Jim Byrnes schrieb:

> Currently jedit highlights a matching bracket by putting a red box
> around it.  My eyes are getting old and sometimes I have trouble
> spotting this indicator. Is it possible to set jedit to change the
> background color between the pair of brackets?
>
> Regards, Jim
>
> ------------------------------------------------------------------------------
> Xperia(TM) PLAY
> It's a major breakthrough. An authentic gaming
> smartphone on the nation's most reliable network.
> And it wants your games.
> http://p.sf.net/sfu/verizon-sfdev
>  

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: Bracket matching

Vampire-3
Administrator


2011/4/6 jim byrnes <[hidden email]>
Vampire wrote:
In case you don't find any plugin I've hacked a script together quickly that
should do what you want. But no guarantee that it really does what you think
it should do. :-D
Just put the attached file in your startup scripts folder and restart jEdit.

Regards
Vampire
 
Hey thanks for the script, I didn't expect anything like that.  I'm away from home right now so I put jEdit on my laptop to test it.  It works exactly like I wanted.

I noticed a couple of oddities when testing it. I mention them only because the script is really useful and you might want to make it available to other members of the jEdit community.

If you put the cursor to the right of the opening bracket, all the text between the brackets is highlighted and a box is drawn around the closing bracket.

The box is drawn because the script does not replace the matching bracket highlight but complements it, I changed this so that the standard matching bracket highlighter is removed if the script plugs in itself so the box around the closing bracket is not show anymore.
 
If you put the cursor to the right if the closing bracket, the text between the brackets and the brackets themselves are highlighted.

This is a little bit tricky as I use the built-in structure matcher mechanism which only specifies the opposite match. You have to consider that not only matching brackets are highlighted. Open an XML document with XML plugin installed and used for parsing. Then place the caret inside a tag and you see that there also the match is highlighted. I only get the start and end of the opposite matching item, but not the start and end of the item the caret is at. I changed it a little bit, so now the opposite matching item is always fully highlighted and the highlighting starts/ends at the caret. I don't think this is possible easily in another way. I hope it suits you better now.
 

If the brackets and the text between span more than one line there is a thin line where the background color is visible between the lines with the exception of the very first position of lines 1 and 2.

Also this is caused by the original matching bracket highlighter still being in place and thus around the opening bracket the box is still drawn. This box is one pixel higher than the background drawn by the script and thus has this effect you describe. This is also gone with disabling the standard bracket highlighter.
 

Like I said what I outlined above in no way takes away from the usefulness of your script to me.  In fact I only noticed it because I was using a bright red for my highlighting color.  Once I switched it to a soft yellow it was not noticeable.

I also tested with bright red, I just normally have my parens on the end of the line and not too long lines so I didn't notice this display glitch at first.
 
I've uploaded this script to the community page. You can either download it from there, or you can use the MacroManager plugin which will also list the macro now.

Regards
Vampire


Thanks again for your help.

Reards,  Jim

2011/4/5 Jim Byrnes<[hidden email]>

 
Vampire wrote:

   
Hi Jim,

the red box is a customization by you, isn't it?
For me it is a black box.

     
I don't remember doing it, but if yours is black I must have to tried to
make it more noticeable at some point in time.


 Nevertheless, you can only influence the color of that box around the
   
brackets.

     
OK, not what I wanted to hear, but thanks for the info, I'll stop looking
now.


 If you want to have the whole block highlighted with a background color,
   
you need to provide a TextAreaExtension that does this painting. I don't
know whether there is a plugin around doing this in the way you want it.

     
I'll look at the plugins.


 Theoretically you could even do it with a BeanShell script like you can
   
do anything that you can do in a plugin also in a BeanShell script, but
a plugin would probably be more suitable here. The Highlighter plugin
could maybe serve as a starting point for developing such a plugin,
combined with org.gjt.sp.jedit.textarea.StructureMatcher.Highlight which
is the class doing the box-around highlighting for the matching brackets.

     
I don't know java and not proficient with BeanShell so this is not doable
by me.

 Regards
   
Vampire

     
Regards,  Jim


 Jim Byrnes schrieb:
   
     
Currently jedit highlights a matching bracket by putting a red box
around it.  My eyes are getting old and sometimes I have trouble
spotting this indicator. Is it possible to set jedit to change the
background color between the pair of brackets?

Regards, Jim


       

 



------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: Bracket matching

Vampire-3
Administrator
You're welcome, but you should really start to use the "Reply All" button of your mailer, otherwise ppl on the list see your question but don't get the answers. ;-)

Cheers
Vampire

2011/4/7 Jim Byrnes <[hidden email]>
Vampire wrote:
2011/4/6 jim byrnes<[hidden email]>

Vampire wrote:

In case you don't find any plugin I've hacked a script together
quickly that should do what you want. But no guarantee that it
really does what you think it should do. :-D Just put the
attached file in your startup scripts folder and restart jEdit.

Regards Vampire


Hey thanks for the script, I didn't expect anything like that.  I'm
away from home right now so I put jEdit on my laptop to test it.
It works exactly like I wanted.

I noticed a couple of oddities when testing it. I mention them only
because the script is really useful and you might want to make it
available to other members of the jEdit community.

If you put the cursor to the right of the opening bracket, all the
text between the brackets is highlighted and a box is drawn around
the closing bracket.


The box is drawn because the script does not replace the matching
bracket highlight but complements it, I changed this so that the
standard matching bracket highlighter is removed if the script plugs
in itself so the box around the closing bracket is not show anymore.


If you put the cursor to the right if the closing bracket, the text
between the brackets and the brackets themselves are highlighted.


This is a little bit tricky as I use the built-in structure matcher
mechanism which only specifies the opposite match. You have to
consider that not only matching brackets are highlighted. Open an XML
document with XML plugin installed and used for parsing. Then place
the caret inside a tag and you see that there also the match is
highlighted. I only get the start and end of the opposite matching
item, but not the start and end of the item the caret is at. I
changed it a little bit, so now the opposite matching item is always
fully highlighted and the highlighting starts/ends at the caret. I
don't think this is possible easily in another way. I hope it suits
you better now.


Looks good.



If the brackets and the text between span more than one line there
is a thin line where the background color is visible between the
lines with the exception of the very first position of lines 1 and
2.


Also this is caused by the original matching bracket highlighter
still being in place and thus around the opening bracket the box is
still drawn. This box is one pixel higher than the background drawn
by the script and thus has this effect you describe. This is also
gone with disabling the standard bracket highlighter.



Like I said what I outlined above in no way takes away from the
usefulness of your script to me.  In fact I only noticed it because
I was using a bright red for my highlighting color.  Once I
switched it to a soft yellow it was not noticeable.


I also tested with bright red, I just normally have my parens on the
end of the line and not too long lines so I didn't notice this
display glitch at first.

I've uploaded this script to the community page. You can either
download it from there, or you can use the MacroManager plugin which
will also list the macro now.

Regards Vampire


I have it on my main machine now and it works great, just what I needed. Thanks again for your efforts.  Also thanks for the reference to the MacroManager.  Never really looked at it before.

Regards,  Jim

Thanks again for your help.

Reards,  Jim

2011/4/5 Jim Byrnes<[hidden email]>



Vampire wrote:



Hi Jim,

the red box is a customization by you, isn't it? For me it is
a black box.



I don't remember doing it, but if yours is black I must have to
tried to make it more noticeable at some point in time.


Nevertheless, you can only influence the color of that box
around the


brackets.



OK, not what I wanted to hear, but thanks for the info, I'll
stop looking now.


If you want to have the whole block highlighted with a
background color,


you need to provide a TextAreaExtension that does this
painting. I don't know whether there is a plugin around doing
this in the way you want it.



I'll look at the plugins.


Theoretically you could even do it with a BeanShell script like
you can


do anything that you can do in a plugin also in a BeanShell
script, but a plugin would probably be more suitable here.
The Highlighter plugin could maybe serve as a starting point
for developing such a plugin, combined with
org.gjt.sp.jedit.textarea.StructureMatcher.Highlight which is
the class doing the box-around highlighting for the matching
brackets.



I don't know java and not proficient with BeanShell so this is
not doable by me.

Regards


Vampire



Regards,  Jim


Jim Byrnes schrieb:




Currently jedit highlights a matching bracket by putting a
red box around it.  My eyes are getting old and sometimes I
have trouble spotting this indicator. Is it possible to set
jedit to change the background color between the pair of
brackets?

Regards, Jim












------------------------------------------------------------------------------


Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming smartphone on the
nation's most reliable network. And it wants your games.
http://p.sf.net/sfu/verizon-sfdev




------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: Bracket matching

Jim Byrnes-4
Vampire wrote:
> You're welcome, but you should really start to use the "Reply All" button of
> your mailer, otherwise ppl on the list see your question but don't get the
> answers. ;-)
>
> Cheers
> Vampire
>

<snip>

Your right, my bad.  I'm back on my desktop again, the last one from you
on my laptop was private with an attachment and I didn't look at the cc
this time.

Regards,  Jim

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users