Implement support for getting the current URL from OSC 7

Implements support for the OSC 7 "standard" for tracking open
directories in the terminal (e. g. for bookmarks).

From the bug report, this is apparently what the osx terminal, iterm and
gnome terminal uses to keep track of stuff. I kept the existing tracking
as a fallback.

REVIEW: 128351
BUG: 336618
parent 9d2fd9a3
......@@ -269,6 +269,10 @@ void Session::setInitialWorkingDirectory(const QString& dir)
QString Session::currentWorkingDirectory()
{
if (_reportedWorkingUrl.isValid() && _reportedWorkingUrl.isLocalFile()) {
return _reportedWorkingUrl.path();
}
// only returned cached value
if (_currentWorkingDir.isEmpty())
updateWorkingDirectory();
......@@ -549,6 +553,12 @@ void Session::setUserTitle(int what, const QString& caption)
}
}
if (what == CurrentDirectory) {
_reportedWorkingUrl = QUrl::fromUserInput(caption);
emit currentDirectoryChanged(currentWorkingDirectory());
modified = true;
}
if (what == ProfileChange) {
emit profileChangeCommandReceived(caption);
return;
......@@ -1007,6 +1017,7 @@ QString Session::getDynamicTitle()
{
// update current directory from process
updateWorkingDirectory();
ProcessInfo* process = getProcessInfo();
// format tab titles using process info
......@@ -1024,6 +1035,10 @@ QString Session::getDynamicTitle()
QUrl Session::getUrl()
{
if (_reportedWorkingUrl.isValid()) {
return _reportedWorkingUrl;
}
QString path;
updateSessionProcessInfo();
......
......@@ -352,6 +352,7 @@ public:
IconNameAndWindowTitle = 0,
IconName = 1,
WindowTitle = 2,
CurrentDirectory = 7, // From VTE (supposedly 6 was for dir, 7 for file, but whatever)
TextColor = 10,
BackgroundColor = 11,
SessionName = 30, // Non-standard
......@@ -767,6 +768,7 @@ private:
QString _initialWorkingDir;
QString _currentWorkingDir;
QUrl _reportedWorkingUrl;
ProcessInfo* _sessionProcessInfo;
ProcessInfo* _foregroundProcessInfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment