* Renamed the session ID to index.
* Introduced class SessionID to uniquely identify a session. Unlike the indexes the IDs aren't reused. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39484 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3c90554279
commit
b1b6854036
@ -63,6 +63,9 @@ const static uint32 kUpdateTitles = 'UPti';
|
|||||||
#define B_TRANSLATE_CONTEXT "Terminal TermWindow"
|
#define B_TRANSLATE_CONTEXT "Terminal TermWindow"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - CustomTermView
|
||||||
|
|
||||||
|
|
||||||
class CustomTermView : public TermView {
|
class CustomTermView : public TermView {
|
||||||
public:
|
public:
|
||||||
CustomTermView(int32 rows, int32 columns,
|
CustomTermView(int32 rows, int32 columns,
|
||||||
@ -72,6 +75,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - TermViewContainerView
|
||||||
|
|
||||||
|
|
||||||
class TermViewContainerView : public BView {
|
class TermViewContainerView : public BView {
|
||||||
public:
|
public:
|
||||||
TermViewContainerView(TermView* termView)
|
TermViewContainerView(TermView* termView)
|
||||||
@ -100,23 +106,56 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - SessionID
|
||||||
|
|
||||||
|
|
||||||
|
TermWindow::SessionID::SessionID(int32 id)
|
||||||
|
:
|
||||||
|
fID(id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TermWindow::SessionID::SessionID(const BMessage& message, const char* field)
|
||||||
|
:
|
||||||
|
fID(-1)
|
||||||
|
{
|
||||||
|
message.FindInt32(field, &fID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TermWindow::SessionID::AddToMessage(BMessage& message, const char* field) const
|
||||||
|
{
|
||||||
|
return message.AddInt32(field, fID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Session
|
||||||
|
|
||||||
|
|
||||||
struct TermWindow::Session {
|
struct TermWindow::Session {
|
||||||
int32 id;
|
SessionID id;
|
||||||
|
int32 index;
|
||||||
Title title;
|
Title title;
|
||||||
TermViewContainerView* containerView;
|
TermViewContainerView* containerView;
|
||||||
|
|
||||||
Session(int32 id, TermViewContainerView* containerView)
|
Session(SessionID id, int32 index, TermViewContainerView* containerView)
|
||||||
:
|
:
|
||||||
id(id),
|
id(id),
|
||||||
|
index(index),
|
||||||
containerView(containerView)
|
containerView(containerView)
|
||||||
{
|
{
|
||||||
title.title = B_TRANSLATE("Shell ");
|
title.title = B_TRANSLATE("Shell ");
|
||||||
title.title << id;
|
title.title << index;
|
||||||
title.patternUserDefined = false;
|
title.patternUserDefined = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - TermWindow
|
||||||
|
|
||||||
|
|
||||||
TermWindow::TermWindow(BRect frame, const BString& title,
|
TermWindow::TermWindow(BRect frame, const BString& title,
|
||||||
bool isUserDefinedTitle, int32 windowIndex, uint32 workspaces,
|
bool isUserDefinedTitle, int32 windowIndex, uint32 workspaces,
|
||||||
Arguments* args)
|
Arguments* args)
|
||||||
@ -125,6 +164,7 @@ TermWindow::TermWindow(BRect frame, const BString& title,
|
|||||||
B_CURRENT_WORKSPACE | B_QUIT_ON_WINDOW_CLOSE, workspaces),
|
B_CURRENT_WORKSPACE | B_QUIT_ON_WINDOW_CLOSE, workspaces),
|
||||||
fWindowIndex(windowIndex),
|
fWindowIndex(windowIndex),
|
||||||
fTitleUpdateRunner(this, BMessage(kUpdateTitles), 1000000),
|
fTitleUpdateRunner(this, BMessage(kUpdateTitles), 1000000),
|
||||||
|
fNextSessionID(0),
|
||||||
fTabView(NULL),
|
fTabView(NULL),
|
||||||
fMenubar(NULL),
|
fMenubar(NULL),
|
||||||
fFilemenu(NULL),
|
fFilemenu(NULL),
|
||||||
@ -867,7 +907,8 @@ TermWindow::_AddTab(Arguments* args, const BString& currentDirectory)
|
|||||||
if (fSessions.IsEmpty())
|
if (fSessions.IsEmpty())
|
||||||
fTabView->SetScrollView(scrollView);
|
fTabView->SetScrollView(scrollView);
|
||||||
|
|
||||||
Session* session = new Session(_NewSessionID(), containerView);
|
Session* session = new Session(_NewSessionID(), _NewSessionIndex(),
|
||||||
|
containerView);
|
||||||
fSessions.AddItem(session);
|
fSessions.AddItem(session);
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
@ -1179,7 +1220,7 @@ TermWindow::_UpdateSessionTitle(int32 index)
|
|||||||
// evaluate the session title pattern
|
// evaluate the session title pattern
|
||||||
BString sessionTitlePattern = session->title.patternUserDefined
|
BString sessionTitlePattern = session->title.patternUserDefined
|
||||||
? session->title.pattern : fSessionTitlePattern;
|
? session->title.pattern : fSessionTitlePattern;
|
||||||
TabTitlePlaceholderMapper tabMapper(activeProcessInfo, session->id);
|
TabTitlePlaceholderMapper tabMapper(activeProcessInfo, session->index);
|
||||||
const BString& sessionTitle = PatternEvaluator::Evaluate(
|
const BString& sessionTitle = PatternEvaluator::Evaluate(
|
||||||
sessionTitlePattern, tabMapper);
|
sessionTitlePattern, tabMapper);
|
||||||
|
|
||||||
@ -1210,15 +1251,22 @@ TermWindow::_UpdateSessionTitle(int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
TermWindow::SessionID
|
||||||
TermWindow::_NewSessionID()
|
TermWindow::_NewSessionID()
|
||||||
|
{
|
||||||
|
return fNextSessionID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
TermWindow::_NewSessionIndex()
|
||||||
{
|
{
|
||||||
for (int32 id = 1; ; id++) {
|
for (int32 id = 1; ; id++) {
|
||||||
bool used = false;
|
bool used = false;
|
||||||
|
|
||||||
for (int32 i = 0;
|
for (int32 i = 0;
|
||||||
Session* session = (Session*)fSessions.ItemAt(i); i++) {
|
Session* session = (Session*)fSessions.ItemAt(i); i++) {
|
||||||
if (id == session->id) {
|
if (id == session->index) {
|
||||||
used = true;
|
used = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,18 @@ private:
|
|||||||
bool patternUserDefined;
|
bool patternUserDefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SessionID {
|
||||||
|
SessionID(int32 id);
|
||||||
|
SessionID(const BMessage& message,
|
||||||
|
const char* field);
|
||||||
|
|
||||||
|
status_t AddToMessage(BMessage& message,
|
||||||
|
const char* field) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fID;
|
||||||
|
};
|
||||||
|
|
||||||
struct Session;
|
struct Session;
|
||||||
|
|
||||||
void _SetTermColors(TermViewContainerView* termView);
|
void _SetTermColors(TermViewContainerView* termView);
|
||||||
@ -114,7 +126,8 @@ private:
|
|||||||
void _UpdateTitles();
|
void _UpdateTitles();
|
||||||
void _UpdateSessionTitle(int32 index);
|
void _UpdateSessionTitle(int32 index);
|
||||||
|
|
||||||
int32 _NewSessionID();
|
SessionID _NewSessionID();
|
||||||
|
int32 _NewSessionIndex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Title fTitle;
|
Title fTitle;
|
||||||
@ -123,6 +136,7 @@ private:
|
|||||||
BMessageRunner fTitleUpdateRunner;
|
BMessageRunner fTitleUpdateRunner;
|
||||||
|
|
||||||
BList fSessions;
|
BList fSessions;
|
||||||
|
int32 fNextSessionID;
|
||||||
|
|
||||||
SmartTabView* fTabView;
|
SmartTabView* fTabView;
|
||||||
TermView* fTermView;
|
TermView* fTermView;
|
||||||
|
Loading…
Reference in New Issue
Block a user