Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextWrangler as Editor on mac #83

Open
driven opened this issue Oct 7, 2014 · 17 comments
Open

TextWrangler as Editor on mac #83

driven opened this issue Oct 7, 2014 · 17 comments

Comments

@driven
Copy link

driven commented Oct 7, 2014

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

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

Do you have a reference to the docs for TextWrangler on how command line arguments are invoked for this application?

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

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?

@driven
Copy link
Author

driven commented Oct 7, 2014

reference to the docs is man edit, or I can attach a PDF made using pman [a useful bin script]

@driven
Copy link
Author

driven commented Oct 7, 2014

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

2014-10-07 11 54 00 am

@driven
Copy link
Author

driven commented Oct 7, 2014

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

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

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?

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

(P.S. it's easier to read chunks of code if you mark them up as code blocks)

@driven
Copy link
Author

driven commented Oct 7, 2014

why not just type in edit --separate-windows

it returns

"edit --separate-windows"

which won't run due to the quotes...

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

Ah, so maybe the quotes needs to be specified in the Preference dialog so there is enough flexibility.

@thomthom thomthom added the bug label Oct 7, 2014
@driven
Copy link
Author

driven commented Oct 7, 2014

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'

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

I have been thinking of a dropdown list of editor names where the command lines has been set up in advance.

@driven
Copy link
Author

driven commented Oct 7, 2014

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?

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

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.

@driven
Copy link
Author

driven commented Oct 7, 2014

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?

@thomthom
Copy link
Member

thomthom commented Oct 7, 2014

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.

@macfreek
Copy link

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}"

@thomthom
Copy link
Member

@macfreek awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants