Find indicator for OS X

71 views
Skip to first unread message

Neil Hodgson

unread,
Apr 12, 2012, 10:35:45 AM4/12/12
to scintilla-interest
OS X applications often display animated indicators for find
matches. I have some working but unfinished code for this in SciTE for
OS X and it could go into Scintilla as a feature that is only
implemented on OS X initially. The static effect can be seen at
http://scintilla.org/FindIndicator.png compared with TextEdit and
Safari. When the indicator first appears it animates to draw the
user's attention: starting at normal size then swelling about 25% and
returning to normal size.

For normal text, the match is commonly a word so the padding on the
indicator doesn't overlap characters of interest. For source code,
however, you are often interested in the operator characters right
next to the match. The indicator can be made translucent but then
there are conflicting demands for either the match or the background
to be visible. Xcode solves this by fading the indicator away after it
has performed the initial animation. The implementation could provide
both to allow for the two cases.

On OS X windows can have animation layers that are mostly
independent of other drawing and that animate using the GPU on
separate threads. I haven't looked at the equivalent Windows APIs but
expect a similar effect could be achieved. For GTK+, I don't know of
any animation APIs that work with the widget system. While the same
effects could be achieved with normal drawing, it would be much more
work and may not be as smooth.

Animation adds new dimensions of choice over static drawing as
different movement, effects and timing can be chosen but I'd prefer to
avoid adding many settings for this.

The API could be something like
SCI_SHOWFINDINDICATOR(position start, position end)
with a SCI_FLASHFINDINDICATOR to fade as well. Setting an empty
range would hide the indicator.

Neil

Matthew Brush

unread,
Apr 12, 2012, 10:51:56 AM4/12/12
to scintilla...@googlegroups.com
On 12-04-12 07:35 AM, Neil Hodgson wrote:
> OS X applications often display animated indicators for find
> matches. [...]
>
Hi Neil,

I think in 10.7 this can be taken care of for you by making the
ScintillaView implementing an NSTextFinder[1] (NSTextFindClient,
NSTextFinderBarContainer protocols). I started to try this with
ScintillaView, but never finished. Just throwing it out there in case
you hadn't seen it yet, since it overlaps a bit with what you're talking
about here.

Cheers,
Matthew Brush

[1]
http://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSTextFinder_Class/Reference/Reference.html

Neil Hodgson

unread,
Apr 12, 2012, 6:23:04 PM4/12/12
to scintilla...@googlegroups.com
Some applications would be able to use NSTextFinder but I don't
think it has enough functionality for all applications. For example,
it does not appear to support regular expression search.

Supporting NSTextFinder would be worthwhile though.

Neil

Neil Hodgson

unread,
Apr 16, 2012, 3:24:10 AM4/16/12
to scintilla...@googlegroups.com
The OS X find indicator implementation has been committed. The API
is slightly different from the initial message

SCI_FINDINDICATORSHOW(position start, position end)
SCI_FINDINDICATORFLASH(position start, position end)
SCI_FINDINDICATORHIDE

Neil

Neil Hodgson

unread,
Apr 16, 2012, 5:41:44 AM4/16/12
to scintilla...@googlegroups.com
   Forgot to mention that the ScintillaTest demonstration app now uses SCI_FINDINDICATORFLASH when typing in the search box.

   Neil
Reply all
Reply to author
Forward
0 new messages