Add Cocoa 'Edit > Transformation' Menu Commands

Most Cocoa applications have a Transformations sub-menu in the Edit Menu, which has the following commands for transforming selected text:

  • Make Upper Case
  • Make Lower Case
  • Capitalize

It’s also available in the Context Menu.

Obviously, there are workarounds, but I use these fairly frequently in other applications, and they would be useful to have in Script Debugger.

There are a couple of reasons why they’re not there. One is that in code the compiler often over-rules casing anyway, and the other is that the menus are pretty packed anyway – the context menu loses usability as it grows.

But they’re pretty easy to implement as scripts in Script Debugger’s Scripts menu. For example:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

tell application id "com.latenightsw.ScriptDebugger8" -- Script Debugger
	set theText to selection of document 1 as text
	set theText to current application's NSString's stringWithString:theText
	set theText to theText's lowercaseString() as text -- or uppercaseString() or capitalizedString()
	set selection of document 1 to theText
end tell

Thanks Shane! Think I may migrate to using that instead of my current workarounds (I mostly use it for strings; as you say, it’s not very useful for code because of compilation).

I have these transformation functions mapped to global keyboard shortcuts for use with other applications, which is part of the reason for the request. The native global keyboard shortcuts would function with the commands added to the Edit menu, without needing to disturb the context menu (which I agree is quite full already), should you decide to add them in at some point.