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>
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
-- -- -- -- -- -- -- -- -- -- -- -- -- --
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>
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
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
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>
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