Developing guides

1 view
Skip to first unread message

Alex

unread,
Jul 16, 2010, 7:37:05 PM7/16/10
to peppy-dev
Hi all,

I would like to add word highlight to peppy. There should be several
colors defined and using keyboard shortcut all matching words in
document will gain chosen background color.

So I am seeking advice about implementing this feature the proper way.

Where can I add new shortcut handler ?
How to get cursor position and current buffer contents ?
How to change character background color in buffer ?

Thanks

Rob McMullen

unread,
Jul 18, 2010, 12:17:06 AM7/18/10
to pepp...@googlegroups.com
Hey, that's great if you'd want to work on something like that. I've
done a bit of thinking and I believe the only way to change the
background color for particular bits of text in the wx.StyledTextCtrl
is to use the styling bits:

http://www.yellowbrain.com/stc/textio.html
http://www.yellowbrain.com/stc/styling.html

There are usually 32 styling definitions available for most modes, but
some of the styles are reserved for the font coloring for each major
mode.

So, assuming that is only way to set the background (and I'm not sure
that it is), I see several issues:

1) I use the Editra styling system because that allows consistent
styling across major modes (i.e. comments appear in the same
color/font regardless if you're editing Python or C++ or Perl). The
problem is that Scintilla (the underlying editing component) isn't
consistent, so there is a bunch of index remapping to make sure
peppy's display is consistent. You'd have to chose index numbers so
that they wouldn't conflict.

2) The automatic styling that happens due to the call to SetLexer will
overwrite the custom styles whenever it thinks lines have changed, so
somehow we'd need to short-circuit that process or at least know when
it happens.

3) It seems like a good place to add this would be within the
incremental find action (i.e. the Edit -> Find menu option). Is that
something like what you were thinking?

Have you done much work with the wx.StyledTextCtrl? I think it might
be worth experimenting with some proof-of-concept things before trying
to integrate into peppy.

If you check out the latest svn, you can use the
peppy/find_replace/actions.py as a testbed. If you call that
directly, i.e.:

python peppy/find_replace/actions.py

it will pop up a window that has some sample text and the find bar.
Should be a good place to start.

Rob

> --
> You received this message because you are subscribed to the Google Groups "peppy-dev" group.
> To post to this group, send email to pepp...@googlegroups.com.
> To unsubscribe from this group, send email to peppy-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/peppy-dev?hl=en.
>
>

Alex

unread,
Jul 23, 2010, 8:55:47 AM7/23/10
to peppy-dev
Hi Rob,

Thanks for the tips. I was thinking to bind shortcut to this new
feature. It should identify word under cursor (or selection) and
highlight it in entire document. Useful when analyzing code or log
files. Best implemented in notepad++ .. invoked from context menu ...

Also when there is word selected that word is also highlighted, so
searching for word also makes it highlighted.

Now I will experiment with StyledTextCtrl and actions.py, and report
of every progress.

On Jul 18, 7:17 am, Rob McMullen <rob.mcmul...@gmail.com> wrote:
> Hey, that's great if you'd want to work on something like that.  I've
> done a bit of thinking and I believe the only way to change the
> background color for particular bits of text in the wx.StyledTextCtrl
> is to use the styling bits:
>
> http://www.yellowbrain.com/stc/textio.htmlhttp://www.yellowbrain.com/stc/styling.html
Reply all
Reply to author
Forward
0 new messages