Highlight all occurrences of selected text

1,319 views
Skip to first unread message

Jérôme LAFORGE

unread,
Apr 19, 2011, 3:29:16 PM4/19/11
to scite-i...@googlegroups.com
Hello guys,
I found this workaround (http://lua-users.org/wiki/SciteMarkWord) but I think that can be improved.
I want to know whether this feature has been developed and included into SciTE.
If Neil and users of SciTE are interessted, then I can begin to work on this feature.
Best regard
Jérôme

--
"The box said 'Requires Windows 95, NT, or better,' so I installed Linux."

mozers

unread,
Apr 20, 2011, 1:23:24 AM4/20/11
to J�r�me LAFORGE
Tuesday, April 19, 2011, 11:29:16 PM, J�r�me wrote:
> I read this thread :
> http://groups.google.com/group/scite-interest/browse_thread/thread/d5324e9feb04eaf

Similar thread with ready-made solution - "Highlight selected word in text"
http://groups.google.com/group/scite-interest/browse_thread/thread/bfe5d83fc0adb048

--
mozers
<http://scite-ru.org>

Philippe Lhoste

unread,
Apr 20, 2011, 12:41:56 PM4/20/11
to scite-i...@googlegroups.com
On 20/04/2011 18:35, J�r�me LAFORGE wrote:
> How the users of scite see the lua scripts,usually?
> For me, I see the lua scripts like a way to quick implement some
> feature, test it and share it.
> If this feature is usefull for a part of users then it can be directly
> integrated into scite.
> Thus, the user can use it with scite out of the box more easily.
> Am I wrong?
> What do you think about that?
> In this case, can we imagine that this feature could be integrate into
> scite?

Most of my Lua script just scratch a small itch I have. In general, their features are
language-specific (eg. compute the min and max of SVG coordinates in a selected path ->
bounding box; apply some reformatting rules; list functions in the buffer...) so I don't
expect them to go into SciTE.
It is just a powerful tool in my toolbox...

Now, it can also be used the way you describe, of course. It is also a very good
prototyping tool... :-)
Just check with Neil if he will accept the feature and what he thinks about a possible
implementation: he is very good at seeing issues like cross-platform issues,
compatibility, if we need to enable/disable the feature with settings, etc.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Jérôme LAFORGE

unread,
Apr 20, 2011, 12:35:15 PM4/20/11
to scite-interest
Many thanks for the script. It works fine with little hack on
eventmanager.lua and common.lua script.

I have some questions :
How the users of scite see the lua scripts,usually?
For me, I see the lua scripts like a way to quick implement some
feature, test it and share it.
If this feature is usefull for a part of users then it can be directly
integrated into scite.
Thus, the user can use it with scite out of the box more easily.
Am I wrong?
What do you think about that?
In this case, can we imagine that this feature could be integrate into
scite?

Jérôme


On Apr 20, 7:23 am, mozers <moz...@gmail.com> wrote:
> Tuesday, April 19, 2011, 11:29:16 PM, J r me wrote:
>
> > I read this thread :
> >http://groups.google.com/group/scite-interest/browse_thread/thread/d5...
>
> Similar thread with ready-made solution - "Highlight selected word in text"http://groups.google.com/group/scite-interest/browse_thread/thread/bf...
>
> --
> mozers
> <http://scite-ru.org>

mozers

unread,
Apr 20, 2011, 1:58:44 PM4/20/11
to J�r�me LAFORGE
Wednesday, April 20, 2011, 8:35:15 PM, J�r�me wrote:
> What do you think about that?
> In this case, can we imagine that this feature could be integrate into scite?

SciTE-Ru contains many improvements to the code.
Alas, a lot works only for Windows.
Part is done by not the best algorithm.
Many useful opportunities not included in the official SciTE, only because of their authors do not speak English.
But in SciTE-Ru is no code that can be easy implement with script.

In any case, solve with Neil.
More often he does not allow to edit the code if it can be done with script.
I completely agree with him.
But sometimes he agree in SciTE add such nonsense as "Copy Path".

--
mozers
<http://scite-ru.org>

Jérôme LAFORGE

unread,
Apr 20, 2011, 3:07:00 PM4/20/11
to scite-interest
>More often he does not allow to edit the code if it can be done with script.
I understand this point of view, but many users consider this feature
like very important one. Maybe, it would be better to integrate
directly into SciTE.

Neil Hodgson

unread,
Apr 21, 2011, 2:58:27 AM4/21/11
to scite-i...@googlegroups.com
This has some feature requests:
https://sourceforge.net/tracker/index.php?func=detail&aid=2912710&group_id=2439&atid=352439
https://sourceforge.net/tracker/index.php?func=detail&aid=2837932&group_id=2439&atid=352439

Its popular enough that I'll accept a well written option for
SciTE. Whether it highlights matches in any style or only one
identifier style should be defined. There is also the question of
whether to do this immediately or after a delay like some
applications.

While it would be better if it only highlighted occurrences of the
same identifier rather than all identifiers with the same name in all
scopes, it would be difficult to write this.

mozers:

> But sometimes he agree in SciTE add such nonsense as "Copy Path".

The issue with Copy Path as a script is that Lua doesn't have
direct clipboard access and SCI_COPYTEXT assumes the encoding in the
editor. I was sure that there'd be people confused by trying to
SCI_COPYTEXT($(FilePath)) when using a non-Unicode encoding which
would lead to support requests. Avoiding support requests is a good
thing.

Neil

Philippe Lhoste

unread,
Apr 21, 2011, 4:11:47 AM4/21/11
to scite-i...@googlegroups.com
On 21/04/2011 08:58, Neil Hodgson wrote:
> Its popular enough that I'll accept a well written option for
> SciTE. Whether it highlights matches in any style or only one
> identifier style should be defined. There is also the question of
> whether to do this immediately or after a delay like some
> applications.

Good ideas.
I think most of the time, we want to highlight only occurrences in same style: we don't
want to have highlights in comments, for example, except perhaps doc comments.
In Eclipse, I see an approximative delay of two seconds, which makes sense as it avoids
highlights to change quickly while navigating the code with arrows, for example.

> While it would be better if it only highlighted occurrences of the
> same identifier rather than all identifiers with the same name in all
> scopes, it would be difficult to write this.

Indeed, even if done at lexer level. I guess that most of them have no concept of scope,
it can be quite hard to implement for some languages.
Beside, scope isn't enough: when you click on .equals(), you don't want (in theory) to
highlight all implementations of equals, only those on the current object. Which cannot be
done without a compiler-backed lexer which knowledge of the AST of the whole project.
So it is better to stick to simple things... :-)

>> But sometimes he agree in SciTE add such nonsense as "Copy Path".

I disagree, I find this feature useful, I use it often.
Different users, different needs. And beside, it was probably easy to add, unlike some
other wanted features.

Note: I look again at ScTE Mark Word code in the wiki, and I think it should select words
based on the lexer's definition of words.
Or maybe select contiguous

mozers

unread,
Apr 21, 2011, 9:29:16 AM4/21/11
to Philippe Lhoste
Thursday, April 21, 2011, 12:11:47 PM, Philippe wrote:
> I disagree, I find this feature useful, I use it often.

I also think that this feature is useful.
I said that it is easily implemented using lua:
command.21.*=dostring editor:CopyText(props['FilePath'])

But as rightly said Neil, lua version does not work with paths unicode.
Built-in command "Copy Path" works well.
Once again you're right, Neil :)

About the "Highlight all occurrences of selected text":
I think that if include of the code all the wishes, it is - a very large works and amount.
At several times more than the script.

--
mozers
<http://scite-ru.org>

Jérôme LAFORGE

unread,
Apr 22, 2011, 4:56:49 PM4/22/11
to scite-interest
For your information, I've just create feature request onto
Sourceforge (https://sourceforge.net/tracker/?
func=detail&aid=3291636&group_id=2439&atid=352439)
For now, this is just mockup.
Still work in progress :)

Neil Hodgson

unread,
May 15, 2011, 9:06:28 PM5/15/11
to scite-i...@googlegroups.com
Jérôme's implementation of current word highlighting is now
working. It is controlled by these properties:

highlight.current.word
When set to 1, all occurrences of the selected word are highlighted
with the colour defined by highlight.current.word.colour. By default,
this option is disabled.

highlight.current.word.colour
highlight.current.word.by.style
The option highlight.current.word.colour defines the colour of
highlight. The default value is yellow (#FFFF00).
If the option highlight.current.word.by.style is set, then only words
with the same style are highlighted (e.g. if you select this word in a
comment, then only occurrences of words in comments are selected).

Available from the Mercurial repository
(https://sourceforge.net/scm/?type=hg&group_id=2439) and from
http://www.scintilla.org/scite.zip Source
http://www.scintilla.org/wscite.zip Windows executable

Neil

Reply all
Reply to author
Forward
0 new messages