testup-2
testup-2 copied to clipboard
TextWrangler as Editor on mac
To open the linked error file on a line number, requires the TW bin tool 'edit'. man edit in Terminal shows the options, I used '--separate-windows' as it seems to work best for me.
In conjunction with changing the default editor in testup 'Preferences' to '/Applications/TextWrangler.app'
I edited 'editor.rb' to use TW as shown...
def self.open_file(file, line = 0)
editor = self.application
if editor =~ /TextWrangler/
command = %[edit --separate-windows "#{file}:#{line}"]
else
arguments = self.arguments
arguments.gsub!('{FILE}', file)
arguments.gsub!('{LINE}', line)
command = %["#{editor}" #{arguments}]
end
system(command)
end
for some reason #{arguments} failed to expand so I used "#{file}:#{line}".
john
Do you have a reference to the docs for TextWrangler on how command line arguments are invoked for this application?
So specifying edit --separate-windows
as the editor in TestUp preferences doesn't work?
I don't see any reason for why #{arguments}
should fail - unless you didn't have the correct formatting in the TestUp preferences. Can we see a screenshot of what you entered into the Preferences dialog?
reference to the docs is man edit, or I can attach a PDF made using pman [a useful bin script]
specifying edit --separate-windows returns
"edit --separatewindows" "/Users/johns_iMac/Library/Application Support/SketchUp 2015/SketchUp/Plugins/testup/tests/TestUp/TC_TestErrors.rb:32"
which won't open because of the quotes, I used
this is expanding now... must have cocked it up last night
def self.open_file(file, line = 0)
editor = self.application
arguments = self.arguments
arguments.gsub!('{FILE}', file)
arguments.gsub!('{LINE}', line)
if editor =~ /TextWrangler/
command = %[edit --separate-windows #{arguments}]
else
command = %["#{editor}" #{arguments}]
end
puts command
system(command)
end
So if you hard coded edit --separate-windows
in the RB file, why not just type in edit --separate-windows
in the Application text box in Preferences?
(P.S. it's easier to read chunks of code if you mark them up as code blocks)
why not just type in edit --separate-windows
it returns
"edit --separate-windows"
which won't run due to the quotes...
Ah, so maybe the quotes needs to be specified in the Preference dialog so there is enough flexibility.
It less obscure to use the app name in Preferences and hardcode conditionals.
A lot of people use TextWrangler, but never unix tools like 'edit'
I have been thinking of a dropdown list of editor names where the command lines has been set up in advance.
the default on the mac is really
system(open "`#{file}")
that will open the file depending on it's extension, in whichever app the user normally uses, if you prepend that with -a, it opens in a chosen App, so
system(open -a "#{application}" "`#{file}")
if you want to open at the line number then you need the 'command-line' versions depending on your choice of editor, which not everyone will have...
what about an advanced tab, in preferences, that allows you to enter your own command?
Ruby files are often associated with the Ruby interpreter - we don't want to execute the RB script.
I was thinking of simply having a drop down list with per defined editors above the Editor and Arguments text fields. This is after all just a developer tool.
I like the idea of the drop-down, but there are a lot of editors out there... would the input app text field stay? and could it also have an editable text field for the command?
The existing text boxes would stay, we just add a drop down list of known configs. If people want their editor listed they just make a pull request with the patch to add it.
Here are the commands for the three common plain text editors on MacOS:
General: open "#{file}"
TextMate: mate -l #{line} "#{file}"
BBedit (successor to TextWrangler): bbedit "#{file}" +#{line}
Sublime: subl "#{file}:#{line}"
@macfreek awesome!