Add ‘uuid’ to txmt URL scheme

This can be used to link to the “current document” even if that document has no path. Previously this was done by leaving out the ‘url’ parameter, which made it target the frontmost document — using ‘uuid’ is a more robust way to achieve the same.

A command can read the TM_DOCUMENT_UUID environment variable for the current document’s identifier.
This commit is contained in:
Allan Odgaard
2013-01-08 19:42:18 +01:00
parent 821be6acad
commit 2f2cce3f3e

View File

@@ -94,6 +94,7 @@ static NSString* const OakGlobalSessionInfo = @"OakGlobalSessionInfo";
}
std::map<std::string, std::string>::const_iterator const& url = parameters.find("url");
std::map<std::string, std::string>::const_iterator const& uuid = parameters.find("uuid");
std::map<std::string, std::string>::const_iterator const& line = parameters.find("line");
std::map<std::string, std::string>::const_iterator const& column = parameters.find("column");
std::map<std::string, std::string>::const_iterator const& project = parameters.find("project");
@@ -121,6 +122,18 @@ static NSString* const OakGlobalSessionInfo = @"OakGlobalSessionInfo";
NSRunAlertPanel(@"File Does not Exist", @"The item “%@” does not exist.", @"Continue", nil, nil, [NSString stringWithCxxString:path]);
}
}
else if(uuid != parameters.end())
{
if(document::document_ptr doc = document::find(uuid->second))
{
doc->set_recent_tracking(false);
document::show(doc, project != parameters.end() ? oak::uuid_t(project->second) : document::kCollectionCurrent, range);
}
else
{
NSRunAlertPanel(@"File Does not Exist", @"No document found for UUID %@.", @"Continue", nil, nil, [NSString stringWithCxxString:uuid->second]);
}
}
else if(range != text::range_t::undefined)
{
for(NSWindow* win in [NSApp orderedWindows])