Home Download Buy Blog Forum Support

2 new plugins: Bound Keys and Find Selected

2 new plugins: Bound Keys and Find Selected

Postby CodeEffect on Mon May 06, 2013 6:56 am

Only discovered ST a couple of weeks ago and I'm already in love. Previously I used ultraedit which is a great editor but ST has all that it does, is just as fast and is so much more extensible and pretty.

The thing I missed the most was being able to press F3 to search for whatever text was selected. If nothing is selected it searches for whatever you last searched for in the find panel. I've put together a really simple plugin to match this functionality and it's up here: https://github.com/CodeEffect/FindSelected My python is a little rusty as it's been a while so your comments /feature requests / bugs / suggestions would be very much appreciated. Here's the bumf:

Two additional search methods are available:

find_selected_next - If some text is selected then it is searched for and the cursor highlights the next occurrence of the text. If no text is selected then depending on the passed argument we either search for the last Find search term ("last_search") or the clipboard ("clipboard").

find_selected_previous - As above but we search backwards

This package doesn't really add much in the way of new functionality, it just makes available existing functionality under one method or keypress. Previously to search for the last search term you would call the "find_next" method or to search for selected text you would call the "find_under" method. Now you can just call the "find_selected" method and depending on whether text is selected or not the appropriate built-in method is called for you. It's a somewhat trivial change in behaviour but one I found that I missed greatly when migrating from UltraEdit. There is also the added ability to search for whatever is on the clipboard in one keypress.



I can't believe that the second plugin doesn't exist in one form or another as it seemed like such an obvious requirement but I was unable to find anything after a quick google search (cue links to 10 other similar plugins :)). Bound Keys https://github.com/CodeEffect/BoundKeys lists all key combinations from installed plugins (that aren't ignored) from your platform. It presents the data in a sort of table and lists key combination, command, arguments and clashes with other key combinations including whether or not it's been overridden and if so by which file. Again, any feedback / comments etc is very much appreciated. My next task will be to give it a bit of colour so if anyone has suggestions on the best route to accomplish that I'd be grateful for any advice.

The bumf again:
A plugin to list the contents of keymap files and indicate any clashes / overrides. Sublime Text 2 (http://www.sublimetext.com/2).

The plugin lists the contents of all installed sublime-keymap files from active plugins along with the user and default files. The last column of the table lists clashes of key combinations whilst he prescence of asterisks indicate that the combination is overridden by the other file.

The presented columns of data are: Key combination, command called, arguments to command and clashes.


Both only tested on ST2 in windows but when I get round to sorting my broken RAID I'll be able to test on nix too.

I really enjoyed putting those two together so if anyone has any ideas on a plugin they'd like built either post here or bung me a PM. If I've got the time and it's not too much of a beast I'll (probably!) have a go at putting it together.

Thanks for such a great app, will be buying a license shortly :)
CodeEffect
 
Posts: 20
Joined: Mon May 06, 2013 6:18 am

Re: 2 new plugins: Bound Keys and Find Selected

Postby skuroda on Mon May 06, 2013 7:36 am

As for BoundKeys, I wrote FindKeyConflicts to do something similar. :) I think many users just do "sublime.log_commands(True)" when something isn't behaving properly, then track it down that way. To color it, you would need to define your own color scheme, then apply it to the generated output file. I'll take a closer look at yours when I have some extra time. Welcome to the ST community.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: 2 new plugins: Bound Keys and Find Selected

Postby CodeEffect on Mon May 13, 2013 2:14 am

Another one added: https://github.com/CodeEffect/AlarmClock

Pretty much does what it says on the tin:

Need to be able to get your head down and bury yourself in your code without missing that important meeting? This really simple plugin allows you to quickly set alarms either a number of hours / minutes into the future or at a particular time. Includes that all important snooze functionality in case you're not quite done yet.

At present the audible beep only works on windows. Beeping for linux / mac will be added shortly.


Not quite working fully in ST2 at the moment (I think it's only the beep but I've not yet had the time to look into it).

Also, as noted the beep doesn't work in anything other than windows on ST3. I'll get Linux up and running shortly but if anyone has suggestions on how best to beep on a mac I'd love to hear. I suspect I may have to call an external program but that's a bit shitty so I'd really rather not.
CodeEffect
 
Posts: 20
Joined: Mon May 06, 2013 6:18 am

Re: 2 new plugins: Bound Keys and Find Selected

Postby adzenith on Mon May 13, 2013 1:44 pm

What about just print('\a')? Works over here.
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: 2 new plugins: Bound Keys and Find Selected

Postby CodeEffect on Mon May 13, 2013 4:18 pm

Was the first thing I tried but it didn't work from inside ST (or the console), it just printed a bell character.

Could I ask what platform you're using please - and whether you've tried it in the console / as a plugin please? If it works on mac / *nix then jobs a good 'un :D
CodeEffect
 
Posts: 20
Joined: Mon May 06, 2013 6:18 am

Re: 2 new plugins: Bound Keys and Find Selected

Postby adzenith on Mon May 13, 2013 4:49 pm

Hah! no, it doesn't work... I only checked in the terminal, not in Sublime Text's console.
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: 2 new plugins: Bound Keys and Find Selected

Postby adzenith on Mon May 13, 2013 4:51 pm

On OS X you can do this:
from os import system
system('say time up!')
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: 2 new plugins: Bound Keys and Find Selected

Postby facelessuser on Mon May 13, 2013 5:08 pm

What about instead of getting the beep out of python directly, you just call the system?

For OSX (not a hardware beep, but still sufficient)
Code: Select all
from subprocess import call


call(["osascript",  "-e",  "beep 1"])


Also, just for kicks and giggles on mac, you could make it talk:
Code: Select all
from subprocess import call


call(["say", "i'm afraid i can't do that dave"])


Both work from within sublime on ST3 at least, but I imagine they would work on ST2 as well.

I imagine you could take a similar approach on linux. Call the command line from python to perform an operation to create your alarm instead of relying on python to do it for you.

Anyways, just some ideas.

EDIT: Looks like adzenith had the same idea.
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: 2 new plugins: Bound Keys and Find Selected

Postby CodeEffect on Mon May 13, 2013 6:07 pm

I smell some config settings :D Cheers guys, I'll get what I can test working then post for mac beta testers :)
CodeEffect
 
Posts: 20
Joined: Mon May 06, 2013 6:18 am

Re: 2 new plugins: Bound Keys and Find Selected

Postby CodeEffect on Mon May 13, 2013 10:11 pm

Having a weird issue on ST2 with threads. I've got a solution to make beeps on windows on ST2 using a batch file and a vbscript which all works kind of nicely. The issue is that I launch a thread to beep away in the background then fire up an ok_cancel_dialog to allow the user to snooze or turn off the alarm. This worked fine on ST3 but on ST2 the ok_cancel_dialog seems to halt execution of *all* code including the thread that I've just fired off.

So this:
Code: Select all
# Code to beep fired off in its own thread
def beep(arg, stop_event):
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    while(not stop_event.is_set()):
        subprocess.call("wscript ./hidebat.vbs")
        stop_event.wait(0.9)

# Code to fire off the thread
    self.t_stop = threading.Event()
    t = threading.Thread(target=beep, args=(1, self.t_stop))
    t.start()
    if sublime.ok_cancel_dialog("Alarm time up", "Snooze"):


Just beeps once and stops. When I click OK or cancel it sometimes beeps again then stops (as it should do). If I remove the ok_cancel_dialog() it beeps continually as you might expect it would always do. I've tried a sleep before I open my ok_cancel_dialog in case it needed a bit of a run up before the thread would start working but that just means it beeps a bit more to start but as soon as the dialog opens it stops as before. I've stuck in some basic debugging with print statements and they support the above: opening the dialog halts execution of all code.

I'm scratching my head on this one now, am I doing something stupid? What am I missing?
CodeEffect
 
Posts: 20
Joined: Mon May 06, 2013 6:18 am

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 5 guests