mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Bug 1635: Distinguish multiple sessions opened to the same site by current path
https://winscp.net/tracker/1635 Source commit: 2b4df8601f6d92b6ce37fd2f0c17bb4f2ad94a1e
This commit is contained in:
@@ -6165,6 +6165,7 @@ void __fastcall TCustomScpExplorerForm::UpdateSessionTab(TTabSheet * TabSheet)
|
||||
(ManagedTerminal == FTerminal) ? FSessionColor : ManagedTerminal->StateData->Color;
|
||||
|
||||
TabSheet->ImageIndex = AddSessionColor(Color);
|
||||
TabSheet->Caption = TTerminalManager::Instance()->GetTerminalTitle(ManagedTerminal, true);
|
||||
|
||||
TThemeTabSheet * ThemeTabSheet = dynamic_cast<TThemeTabSheet *>(TabSheet);
|
||||
if (DebugAlwaysTrue(ThemeTabSheet != NULL))
|
||||
@@ -6470,7 +6471,7 @@ void __fastcall TCustomScpExplorerForm::PopupTrayBalloon(TTerminal * Terminal,
|
||||
if (Terminal != NULL)
|
||||
{
|
||||
Title = FORMAT(L"%s - %s",
|
||||
(TTerminalManager::Instance()->TerminalTitle(Terminal), Title));
|
||||
(TTerminalManager::Instance()->GetTerminalTitle(Terminal, true), Title));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6601,7 +6602,7 @@ void __fastcall TCustomScpExplorerForm::Notify(TTerminal * Terminal,
|
||||
if (Terminal != NULL)
|
||||
{
|
||||
NoteMessage = FORMAT(L"%s: %s",
|
||||
(TTerminalManager::Instance()->TerminalTitle(Terminal), NoteMessage));
|
||||
(TTerminalManager::Instance()->GetTerminalTitle(Terminal, true), NoteMessage));
|
||||
}
|
||||
|
||||
if (WinConfiguration->BalloonNotifications)
|
||||
@@ -7922,13 +7923,7 @@ UnicodeString __fastcall TCustomScpExplorerForm::PathForCaption()
|
||||
switch (WinConfiguration->PathInCaption)
|
||||
{
|
||||
case picShort:
|
||||
{
|
||||
Result = UnixExtractFileName(FTerminal->CurrentDirectory);
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
Result = FTerminal->CurrentDirectory;
|
||||
}
|
||||
}
|
||||
Result = TTerminalManager::Instance()->GetTerminalShortPath(FTerminal);
|
||||
break;
|
||||
|
||||
case picFull:
|
||||
@@ -7951,6 +7946,12 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
|
||||
bool HasTerminal = (Terminal != NULL);
|
||||
if (HasTerminal)
|
||||
{
|
||||
// Update path when it changes
|
||||
if ((SessionsPageControl->ActivePage != NULL) && (GetSessionTabTerminal(SessionsPageControl->ActivePage) == Terminal))
|
||||
{
|
||||
UpdateSessionTab(SessionsPageControl->ActivePage);
|
||||
}
|
||||
|
||||
if (!RemoteDirView->Enabled)
|
||||
{
|
||||
RemoteDirView->Enabled = true;
|
||||
|
||||
@@ -161,7 +161,6 @@ void __fastcall TTerminalManager::SetupTerminal(TTerminal * Terminal)
|
||||
//---------------------------------------------------------------------------
|
||||
TTerminal * __fastcall TTerminalManager::DoNewTerminal(TSessionData * Data)
|
||||
{
|
||||
FTerminalList->Clear();
|
||||
TTerminal * Terminal = TTerminalList::NewTerminal(Data);
|
||||
try
|
||||
{
|
||||
@@ -507,7 +506,6 @@ void __fastcall TTerminalManager::FreeTerminal(TTerminal * Terminal)
|
||||
__finally
|
||||
{
|
||||
int Index = IndexOf(Terminal);
|
||||
FTerminalList->Clear();
|
||||
Extract(Terminal);
|
||||
|
||||
TTerminalQueue * Queue;
|
||||
@@ -666,15 +664,7 @@ void __fastcall TTerminalManager::UpdateAppTitle()
|
||||
{
|
||||
if (ScpExplorer)
|
||||
{
|
||||
UnicodeString NewTitle;
|
||||
if (ActiveTerminal)
|
||||
{
|
||||
NewTitle = FormatMainFormCaption(ActiveTerminalTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTitle = FormatMainFormCaption(L"");
|
||||
}
|
||||
UnicodeString NewTitle = FormatMainFormCaption(GetActiveTerminalTitle(false));
|
||||
|
||||
UnicodeString QueueProgressTitle;
|
||||
if (!FForegroundProgressTitle.IsEmpty())
|
||||
@@ -692,11 +682,7 @@ void __fastcall TTerminalManager::UpdateAppTitle()
|
||||
}
|
||||
else if (ActiveTerminal && (ScpExplorer != NULL))
|
||||
{
|
||||
UnicodeString Path = ScpExplorer->PathForCaption();
|
||||
if (!Path.IsEmpty())
|
||||
{
|
||||
NewTitle = Path + L" - " + NewTitle;
|
||||
}
|
||||
AddToList(NewTitle, ScpExplorer->PathForCaption(), L" - ");
|
||||
}
|
||||
|
||||
ScpExplorer->Caption = NewTitle;
|
||||
@@ -1234,25 +1220,12 @@ void __fastcall TTerminalManager::TerminalReady()
|
||||
//---------------------------------------------------------------------------
|
||||
TStrings * __fastcall TTerminalManager::GetTerminalList()
|
||||
{
|
||||
if (FTerminalList->Count != Count)
|
||||
FTerminalList->Clear();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
UnicodeString NameN;
|
||||
UnicodeString Name = Terminals[i]->SessionData->SessionName;
|
||||
int Number = 1;
|
||||
NameN = Name;
|
||||
while (FTerminalList->IndexOf(NameN) >= 0)
|
||||
{
|
||||
Number++;
|
||||
NameN = FORMAT(L"%s (%d)", (Name, Number));
|
||||
}
|
||||
if (Number > 1)
|
||||
{
|
||||
Name = FORMAT(L"%s (%d)", (Name, Number));
|
||||
}
|
||||
FTerminalList->AddObject(Name, Terminals[i]);
|
||||
}
|
||||
TTerminal * Terminal = Terminals[i];
|
||||
UnicodeString Name = GetTerminalTitle(Terminal, true);
|
||||
FTerminalList->AddObject(Name, Terminal);
|
||||
}
|
||||
return FTerminalList;
|
||||
}
|
||||
@@ -1267,26 +1240,51 @@ void __fastcall TTerminalManager::SetActiveTerminalIndex(int value)
|
||||
ActiveTerminal = Terminals[value];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TTerminalManager::TerminalTitle(TTerminal * Terminal)
|
||||
UnicodeString __fastcall TTerminalManager::GetTerminalShortPath(TTerminal * Terminal)
|
||||
{
|
||||
int Index = IndexOf(Terminal);
|
||||
UnicodeString Result;
|
||||
if (Index >= 0)
|
||||
UnicodeString Result = UnixExtractFileName(Terminal->CurrentDirectory);
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
Result = TerminalList->Strings[Index];
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is the case of background transfer sessions
|
||||
Result = Terminal->SessionData->SessionName;
|
||||
Result = Terminal->CurrentDirectory;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TTerminalManager::GetActiveTerminalTitle()
|
||||
UnicodeString __fastcall TTerminalManager::GetTerminalTitle(TTerminal * Terminal, bool Unique)
|
||||
{
|
||||
UnicodeString Result = ActiveTerminal ?
|
||||
TerminalTitle(ActiveTerminal) : UnicodeString(L"");
|
||||
UnicodeString Result = Terminal->SessionData->SessionName;
|
||||
if (Unique)
|
||||
{
|
||||
int Index = IndexOf(Terminal);
|
||||
// not for background transfer sessions
|
||||
if (Index >= 0)
|
||||
{
|
||||
for (int Index2 = 0; Index2 < Count; Index2++)
|
||||
{
|
||||
UnicodeString Name = Terminals[Index2]->SessionData->SessionName;
|
||||
if ((Terminals[Index2] != Terminal) &&
|
||||
SameText(Name, Result))
|
||||
{
|
||||
UnicodeString Path = GetTerminalShortPath(Terminal);
|
||||
if (!Path.IsEmpty())
|
||||
{
|
||||
Result = FORMAT(L"%s (%s)", (Result, Path));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TTerminalManager::GetActiveTerminalTitle(bool Unique)
|
||||
{
|
||||
UnicodeString Result;
|
||||
if (ActiveTerminal != NULL)
|
||||
{
|
||||
Result = GetTerminalTitle(ActiveTerminal, Unique);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -1523,7 +1521,6 @@ void __fastcall TTerminalManager::MasterPasswordPrompt()
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTerminalManager::Move(TTerminal * Source, TTerminal * Target)
|
||||
{
|
||||
FTerminalList->Clear();
|
||||
int SourceIndex = IndexOf(Source);
|
||||
int TargetIndex = IndexOf(Target);
|
||||
TTerminalList::Move(SourceIndex, TargetIndex);
|
||||
|
||||
@@ -54,7 +54,9 @@ public:
|
||||
void __fastcall OpenInPutty();
|
||||
void __fastcall NewSession(bool FromSite, const UnicodeString & SessionUrl, bool ReloadSessions = true, TForm * LinkedForm = NULL);
|
||||
void __fastcall Idle(bool SkipCurrentTerminal);
|
||||
UnicodeString __fastcall TerminalTitle(TTerminal * Terminal);
|
||||
UnicodeString __fastcall GetTerminalShortPath(TTerminal * Terminal);
|
||||
UnicodeString __fastcall GetTerminalTitle(TTerminal * Terminal, bool Unique);
|
||||
UnicodeString __fastcall GetActiveTerminalTitle(bool Unique);
|
||||
void __fastcall HandleException(Exception * E);
|
||||
void __fastcall SaveWorkspace(TList * DataList);
|
||||
void __fastcall QueueStatusUpdated();
|
||||
@@ -67,7 +69,6 @@ public:
|
||||
__property TTerminal * ActiveTerminal = { read = FActiveTerminal, write = SetActiveTerminal };
|
||||
__property TTerminalQueue * ActiveQueue = { read = GetActiveQueue };
|
||||
__property int ActiveTerminalIndex = { read = GetActiveTerminalIndex, write = SetActiveTerminalIndex };
|
||||
__property UnicodeString ActiveTerminalTitle = { read = GetActiveTerminalTitle };
|
||||
__property TStrings * TerminalList = { read = GetTerminalList };
|
||||
__property TNotifyEvent OnLastTerminalClosed = { read = FOnLastTerminalClosed, write = FOnLastTerminalClosed };
|
||||
__property TNotifyEvent OnTerminalListChanged = { read = FOnTerminalListChanged, write = FOnTerminalListChanged };
|
||||
@@ -137,7 +138,6 @@ private:
|
||||
void __fastcall TerminalReady();
|
||||
TStrings * __fastcall GetTerminalList();
|
||||
int __fastcall GetActiveTerminalIndex();
|
||||
UnicodeString __fastcall GetActiveTerminalTitle();
|
||||
TTerminalQueue * __fastcall GetActiveQueue();
|
||||
void __fastcall SaveTerminal(TTerminal * Terminal);
|
||||
void __fastcall SetActiveTerminalIndex(int value);
|
||||
|
||||
Reference in New Issue
Block a user