diff options
| author | Jim Ingham <jingham@apple.com> | 2010-08-30 23:48:25 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2010-08-30 23:48:25 +0000 |
| commit | 5024baba16ab4eaf5c810bffda91b844ebcd2791 (patch) | |
| tree | a4d15a0f84e4f171c1baf15458d9aab0d59305db | |
| parent | f2d817192bb694590f737f2c4585a0088399898d (diff) | |
| download | bcm5719-llvm-5024baba16ab4eaf5c810bffda91b844ebcd2791.tar.gz bcm5719-llvm-5024baba16ab4eaf5c810bffda91b844ebcd2791.zip | |
Add LLDB_EXTERNAL_EDITOR
llvm-svn: 112558
| -rw-r--r-- | lldb/source/Host/macosx/Host.mm | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 2bbee036f7d..f32f92992e9 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -829,15 +829,47 @@ Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) file_and_line_desc.descKey = keyAEPosition; LSApplicationParameters app_params; + static FSRef app_to_use; + static std::string app_name; bzero (&app_params, sizeof (app_params)); app_params.flags = kLSLaunchDefaults | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch; + + char *external_editor = ::getenv ("LLDB_EXTERNAL_EDITOR"); + + if (external_editor != NULL) + { + bool calculate_fsref = true; + if (app_name.empty() || strcmp (app_name.c_str(), external_editor) != 0) + { + calculate_fsref = true; + } + else + calculate_fsref = false; + + if (calculate_fsref) + { + CFCString editor_name (external_editor, kCFStringEncodingUTF8); + error = ::LSFindApplicationForInfo(kLSUnknownCreator, NULL, editor_name.get(), &app_to_use, NULL); + + // If we found the app, then store away the name so we don't have to re-look it up. + if (error == noErr) + app_name.assign (external_editor); + else + return false; + + } + + app_params.application = &app_to_use; + } + + ProcessSerialNumber psn; CFCReleaser<CFArrayRef> file_array(CFArrayCreate (NULL, (const void **) file_URL.ptr_address(false), 1, NULL)); error = ::LSOpenURLsWithRole (file_array.get(), - kLSRolesViewer, + kLSRolesAll, &file_and_line_desc, &app_params, &psn, |

