ui: clickable file scope

* When content that is shown in a snippet is located in the file scope, the snippet's title bar displays the file's name. Clicking this name has the same effect as maximizing the file (the file's entire content is shown but the file symbol is not activated).
This commit is contained in:
malte_langkabel
2015-10-15 12:24:24 +02:00
parent 0664f9a81b
commit e1683d047a
3 changed files with 19 additions and 6 deletions
@@ -260,7 +260,6 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(std:
params.startLineNumber = std::max<int>(1, range.start.row - (range.start.strong ? 0 : snippetExpandRange));
params.endLineNumber = std::min<int>(textAccess->getLineCount(), range.end.row + (range.end.strong ? 0 : snippetExpandRange));
std::shared_ptr<TokenLocationFile> tempFile =
m_storageAccess->getTokenLocationsForLinesInFile(file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
TokenLocationLine* firstUsedLine = nullptr;
@@ -269,9 +268,12 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(std:
firstUsedLine = tempFile->findTokenLocationLineByNumber(i);
}
params.titleId = 0;
if (firstUsedLine && firstUsedLine->getTokenLocations().size())
{
m_storageAccess->getTokenLocationOfParentScope(firstUsedLine->getTokenLocations().begin()->second.get())->forEachStartTokenLocation(
m_storageAccess->getTokenLocationOfParentScope(
firstUsedLine->getTokenLocations().begin()->second.get()
)->forEachStartTokenLocation( // this TokenLocationFile only contains a single StartTokenLocation.
[&](TokenLocation* location)
{
params.title = m_storageAccess->getNameHierarchyForNodeWithId(location->getTokenId()).getFullName();
@@ -279,6 +281,10 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(std:
}
);
}
if (!file->isWholeCopy && params.titleId == 0)
{
params.title = file->getFilePath().str();
}
for (const std::string& line: textAccess->getLines(params.startLineNumber, params.endLineNumber))
{