Commit bb6abc0b authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

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) ...@@ -269,6 +269,10 @@ void Session::setInitialWorkingDirectory(const QString& dir)
QString Session::currentWorkingDirectory() QString Session::currentWorkingDirectory()
{ {
if (_reportedWorkingUrl.isValid() && _reportedWorkingUrl.isLocalFile()) {
return _reportedWorkingUrl.path();
}
// only returned cached value // only returned cached value
if (_currentWorkingDir.isEmpty()) if (_currentWorkingDir.isEmpty())
updateWorkingDirectory(); updateWorkingDirectory();
...@@ -549,6 +553,12 @@ void Session::setUserTitle(int what, const QString& caption) ...@@ -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) { if (what == ProfileChange) {
emit profileChangeCommandReceived(caption); emit profileChangeCommandReceived(caption);
return; return;
...@@ -1007,6 +1017,7 @@ QString Session::getDynamicTitle() ...@@ -1007,6 +1017,7 @@ QString Session::getDynamicTitle()
{ {
// update current directory from process // update current directory from process
updateWorkingDirectory(); updateWorkingDirectory();
ProcessInfo* process = getProcessInfo(); ProcessInfo* process = getProcessInfo();
// format tab titles using process info // format tab titles using process info
...@@ -1024,6 +1035,10 @@ QString Session::getDynamicTitle() ...@@ -1024,6 +1035,10 @@ QString Session::getDynamicTitle()
QUrl Session::getUrl() QUrl Session::getUrl()
{ {
if (_reportedWorkingUrl.isValid()) {
return _reportedWorkingUrl;
}
QString path; QString path;
updateSessionProcessInfo(); updateSessionProcessInfo();
......
...@@ -352,6 +352,7 @@ public: ...@@ -352,6 +352,7 @@ public:
IconNameAndWindowTitle = 0, IconNameAndWindowTitle = 0,
IconName = 1, IconName = 1,
WindowTitle = 2, WindowTitle = 2,
CurrentDirectory = 7, // From VTE (supposedly 6 was for dir, 7 for file, but whatever)
TextColor = 10, TextColor = 10,
BackgroundColor = 11, BackgroundColor = 11,
SessionName = 30, // Non-standard SessionName = 30, // Non-standard
...@@ -767,6 +768,7 @@ private: ...@@ -767,6 +768,7 @@ private:
QString _initialWorkingDir; QString _initialWorkingDir;
QString _currentWorkingDir; QString _currentWorkingDir;
QUrl _reportedWorkingUrl;
ProcessInfo* _sessionProcessInfo; ProcessInfo* _sessionProcessInfo;
ProcessInfo* _foregroundProcessInfo; 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