Home Download Buy Blog Forum Support

Highlight Current Word

Re: Highlight Current Word

Postby senzo on Wed Jun 15, 2011 8:38 pm

This is really nice. Thanks.

Just a small issue: The highlighted words start flickering while scrolling and sometimes turn gray while they are still in the viewport.
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: Highlight Current Word

Postby ajpalkovic on Wed Jun 15, 2011 10:39 pm

Hmm, I haven't seen any flickering or color changing going on. I just pushed a couple of changes to the gist that might help.

The problem is there is no on_scroll event, so I just had a small timer that periodically checked if the viewport had changes dimensions. That works, but that would be my guess why the flickering is there. If you still have it, maybe try setting the interval to 10, instead of 50, restart sublime and see if that fixes it.
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Highlight Current Word

Postby senzo on Thu Jun 16, 2011 7:47 am

The flickering itself is not so much a problem. But after scrolling, the highlighted words look sometimes different, depending on which flickering state i stop scrolling. As if their selector changes. Here are screenshots with the Monokai Theme and "searchHighlight" as the selector:

themeSelector = view.settings().get('highlight_word_theme_selector', 'searchHighlight')

Before scrolling:
before.png
before.png (31.48 KiB) Viewed 2407 times


After scrolling:
after.png
after.png (31.2 KiB) Viewed 2402 times
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: Highlight Current Word

Postby senzo on Thu Jun 16, 2011 7:51 am

Ok, "searchHighlight" doesn't exist... The example works anyway :)
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: Highlight Current Word

Postby ajpalkovic on Thu Jun 16, 2011 8:39 am

Heh, it actually might be because you have two versions of the plugin running :)
I haven't figured out a good solution for this yet, it appears that sometimes when I make changes to a plugin the old events / timers aren't always killed properly. In this case, you actually might have two versions of the plugins that are firing the same events but with a different default, so it's a race condition to see which one gets displayed. I might have messed up in coding it, but for now, I'd say just restart sublime once you have finished your changes to the plugin. You can add highlight_word_theme_selector to your settings file, that way you do not need to modify the plugin to change the color. (This is also why I never saw the flickering because I set this, which overrode the default). Then you can drop something like this into your theme file:
Code: Select all
            <dict>
                <key>name</key>
                <string>Current Word</string>
                <key>scope</key>
                <string>currentword</string>
                <key>settings</key>
                <dict>
                    <key>foreground</key>
                    <string>#F8F8F8</string>
                    <key>background</key>
                    <string>#117004</string>
                </dict>
            </dict>
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Highlight Current Word

Postby senzo on Thu Jun 16, 2011 9:02 am

Ah, ok. Adding highlight_word_theme_selector to the settings did the trick. I already defined a key in my theme – and did some testing with various other keys. That has to be the reason for the issue. Thanks a lot!
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: Highlight Current Word

Postby charlesroper on Thu Jun 16, 2011 12:43 pm

If it were any other editor it might be silly, but the minimap means that you can see selections beyond your current frame. You have to have a really bright selection colour to pick them out in the minimap, though (which I do).
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am

Re: Highlight Current Word

Postby ajpalkovic on Thu Jun 16, 2011 5:54 pm

Yea, I thought about that too. I could hardly see the highlights though so I didn't really find it that useful. You can always do a find all if you truly want to see all of them. Also, since it's in a gist right now, you can grab an old version too if you need to.
ajpalkovic
 
Posts: 142
Joined: Fri Jun 10, 2011 10:21 pm

Re: Highlight Current Word

Postby singw on Sun Aug 07, 2011 1:59 pm

Can the highlighted words keep on highlighting until I make another selection on other words?
just like the search function, it will highlight the searched term persistently.
singw
 
Posts: 59
Joined: Fri Aug 05, 2011 2:16 pm

Re: Highlight Current Word

Postby optilude on Sat Aug 13, 2011 12:13 am

Hi,

Just a question on this: In the current file, it says:

Code: Select all
# The search is performed half a second after the most recent event in order to prevent the search hapenning on every keypress.
# Each of the event handlers simply marks the time of the most recent event and a timer periodically executes doSearch


However, if I'm reading the code right, this isn't the case: it's doing the search every half second and every time the selection is changed, since:

Code: Select all
def on_selection_modified(self, view):
    self.doSearch(view)


Isn't that a bit resource intensive?

Martin
optilude
 
Posts: 30
Joined: Sun Jan 30, 2011 2:36 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests