davekeck / Xcode-4-Fixins

Plugins for fixing Xcode 4 bugs and shortcomings
362 stars 41 forks source link

Request: ctrl-p, ctrl-n as up/down in Symbol list (ctrl-6) #1

Closed brentd closed 12 years ago

brentd commented 12 years ago

Great ideas here. So happy to have animations disabled - most of them perform so badly that I can't understand why they're there.

Something I'd love to see is ctrl-p and ctrl-n act as up and down arrows when browsing & filtering the symbol list. This works as expected in every other list in OS X, and in most places in Xcode - I can't understand why it doesn't work there. Drives me nuts to have to reach for the up/down keys for that one thing.

Any ideas on how this could be hacked in?

davekeck commented 12 years ago

To clarify - do you mean the "Symbol Navigator" that's accessed through command-2?

If so, I'd imagine this would be implemented by swizzling -keyDown: for whatever NSOutlineView subclass that the Symbol Navigator is implemented as. If the key event doesn't match ctrl-p/-n, call the original implementation of -keyDown:. If it does match ctrl-p/-n, create a custom NSEvent that emulates up-arrow/down-arrow, and call the original implementation of -keyDown: with this custom event.

brentd commented 12 years ago

Nope, I don't use the Symbol list accessed via cmd-2... the one I mean you can pull up with ctrl-6.

http://cl.ly/1S3o1x0R063S0l0G1A1t

What's great about it is you can start typing and it filters the symbols of your current file for quick access. After filtering with a few keystrokes, you can choose the one you want with the up/down arrows. Just wish it worked with ctrl-p and ctrl-n :)

I understand method swizzling, but I'm new to the world of hacking existing apps. How does one go about finding out what class that list is being represented with?

davekeck commented 12 years ago

In that case, I'd imagine the process is nearly identical, except you'll have to identify the class of NSTableView (presuming that's what it is) displayed in that popup menu instead. Once you identify the subclass of NSTableView, you'd still override -keyDown:.

The most direct way of finding the NSTableView class that implements the symbol list would be searching through the various Xcode libraries in /Developer/Library/PrivateFrameworks/. I use 'class-dump' (http://www.codethecode.com/projects/class-dump/), 'nm', and 'otool'. Play around with those tools and see if you can find anything matching some terms you might expect in the class name.

The class could also be an NSMenu subclass. I kind of doubt it since it has a fancy text field to filter the results, but maybe NSMenus support that - I'm not sure.

Once you find the class name you should be golden though. Let me know if you run into any specific issues.