Home Download Buy Blog Forum Support

Add a warning when multi-selecting invisible text

Add a warning when multi-selecting invisible text

Postby edanm on Sun May 09, 2010 3:43 pm

This is a small feature request:

Once in a while, I'll multi-select a few fields, and accidently select some off-screen text (that appears later/earlier in the view). This usually happens because I didn't notice that some phrase appears more than twice in my document.
Whenever this happens, I make lots of changes, then realize that some other part of the file is ruined.

I'm thinking, just add a tiny "warning balloon" that appears at the top-right corner of the view, which lets you know that text was selected off-screen.

(In fact, if you could expose an API to set the text of the balloon, I could think of several other uses for it).
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: Add a warning when multi-selecting invisible text

Postby gpfsmurf on Tue May 11, 2010 12:19 am

You can see the number of selections in the statusbar, and the minimap is also of great help to see where the other selections are.

This being said, here's a plugin that will deselect anything that is not currently visible:
Code: Select all
import sublime, sublimeplugin

class CropVisibleSelectionCommand(sublimeplugin.TextCommand):
   def run(self, view, args):
      mask1 = sublime.Region(0, view.visibleRegion().begin())
      mask2 = sublime.Region(view.visibleRegion().end(), view.size())
      view.sel().subtract(mask1)
      view.sel().subtract(mask2)


Using view.visibleRegion(), you could create a plugin that warns you about how many selections are currently hidden, or something like that.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Add a warning when multi-selecting invisible text

Postby gpfsmurf on Tue May 11, 2010 12:34 am

... like this:
Code: Select all
import sublime, sublimeplugin

class HiddenSelectionInfo(sublimeplugin.Plugin):
   def onSelectionModified(self, view):
      hidden = 0
      visible = view.visibleRegion()
      for   region in view.sel():
         if not region.intersects(visible):
            hidden += 1

      if hidden >   0:
         view.setStatus('hiddenRegions', "%i hidden region%s" % (hidden, 's' if hidden > 1 else ''))
      else:
         view.eraseStatus('hiddenRegions')
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Add a warning when multi-selecting invisible text

Postby edanm on Tue May 11, 2010 7:34 am

Yeah, I know that you can use the status bar to display messages.

But, to me at least, that doesn't seem intrusive enough.
It's always there, and it doesn't grab your attention when it needs you to know something.

I have a vivid imagination of a "message box" that can be display in any view, which pops up for a few seconds and then closes, and which carries important information (something like the Gmail status messages you get when you delete mails, for example).

Then, the editor could help new users by popping up helpful messages whenever they do something that might warrant more explanation.
For example, the first time someone does a multi-selection (which is going to be new to most people), the message box can pop up and say "You made a multi-selection. For more info, click here" or something along those lines.

Anyway, that's just a dream of mine for an editor that actually helps the users learn all its awesome features.
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: Add a warning when multi-selecting invisible text

Postby gpfsmurf on Tue May 11, 2010 6:41 pm

I agree: modal alert boxes are too intrusive, so I tend to open/close the console pane all the time, bad habit.

+1 for modeless alerts!
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Add a warning when multi-selecting invisible text

Postby GreyWyvern on Tue May 11, 2010 9:25 pm

One way this could be solved without the need for alerts is to "throb" all selected regions in the minimap.

Right now, selected regions in the minimap are indicated by a static solid colour, which can be easily overlooked if your colour scheme contains lots of different colours itself. The eye is attracted first to movement, and second to changes in luminosity. So if the selected regions faded gently from (for example) white to grey to white again, seeing all the selections in the document would be very much easier.

Cool idea or no?
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Add a warning when multi-selecting invisible text

Postby edanm on Tue May 11, 2010 10:00 pm

Actually yeah, that's a great idea.
I'll just add that making the cursor itself (i.e. one selection) blink as well would also be very welcome, since I sometimes have a little trouble finding it on the minimap.

I still think a cool message api is good for really grabbing someone's attention in other cases, though.

Guess there's lots more to do for the next Sublime versions :)
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests