a new terminal is now launched in TermWindow
we now search for a Terminal index : we use scripting to ask every Terminal its window title, and from this computes a free index this fixes bug #699 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17975 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -73,14 +73,7 @@ const ulong MSG_TERM_IS_MINIMIZE = 'mtim';
|
|||||||
TermApp::TermApp()
|
TermApp::TermApp()
|
||||||
: BApplication(TERM_SIGNATURE)
|
: BApplication(TERM_SIGNATURE)
|
||||||
{
|
{
|
||||||
BList teams;
|
fWindowNumber = FindTerminalId();
|
||||||
be_roster->GetAppList(TERM_SIGNATURE, &teams);
|
|
||||||
fWindowNumber = teams.CountItems();
|
|
||||||
|
|
||||||
if (fWindowNumber == 0) {
|
|
||||||
be_roster->GetAppList(R5_TERM_SIGNATURE, &teams);
|
|
||||||
fWindowNumber = teams.CountItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
char title[256];
|
char title[256];
|
||||||
snprintf(title, sizeof(title), "Terminal %d", fWindowNumber);
|
snprintf(title, sizeof(title), "Terminal %d", fWindowNumber);
|
||||||
@@ -200,10 +193,6 @@ void
|
|||||||
TermApp::MessageReceived(BMessage* msg)
|
TermApp::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MENU_NEW_TREM:
|
|
||||||
RunNewTerm();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MENU_SWITCH_TERM:
|
case MENU_SWITCH_TERM:
|
||||||
SwitchTerm();
|
SwitchTerm();
|
||||||
break;
|
break;
|
||||||
@@ -391,18 +380,6 @@ TermApp::MakeTermWindow(BRect &frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TermApp::RunNewTerm()
|
|
||||||
{
|
|
||||||
app_info info;
|
|
||||||
be_app->GetAppInfo(&info);
|
|
||||||
|
|
||||||
// try launching two different ways to work around possible problems
|
|
||||||
if (be_roster->Launch(&info.ref)!=B_OK)
|
|
||||||
be_roster->Launch(TERM_SIGNATURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermApp::ActivateTermWindow(team_id id)
|
TermApp::ActivateTermWindow(team_id id)
|
||||||
{
|
{
|
||||||
@@ -462,6 +439,51 @@ TermApp::IsMinimize(team_id id)
|
|||||||
return hidden;
|
return hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
TermApp::FindTerminalId()
|
||||||
|
{
|
||||||
|
BList teams;
|
||||||
|
be_roster->GetAppList(TERM_SIGNATURE, &teams);
|
||||||
|
int32 count = teams.CountItems();
|
||||||
|
int32 numbers[count];
|
||||||
|
thread_info info;
|
||||||
|
get_thread_info(find_thread(NULL), &info);
|
||||||
|
|
||||||
|
for (int32 i=0; i<count; i++) {
|
||||||
|
team_id id = (team_id)teams.ItemAt(i);
|
||||||
|
if (id == info.team)
|
||||||
|
continue;
|
||||||
|
numbers[i] = 0;
|
||||||
|
|
||||||
|
BMessage msg(B_GET_PROPERTY);
|
||||||
|
BMessage reply;
|
||||||
|
msg.AddSpecifier("Title");
|
||||||
|
msg.AddSpecifier("Window", (int32)0);
|
||||||
|
if (BMessenger(TERM_SIGNATURE, id).SendMessage(&msg, &reply) != B_OK)
|
||||||
|
continue;
|
||||||
|
BString title;
|
||||||
|
if (reply.FindString("result", &title)!=B_OK)
|
||||||
|
continue;
|
||||||
|
sscanf(title.String(), "Terminal %ld", &numbers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32 i=1; i<count; i++) {
|
||||||
|
bool found = false;
|
||||||
|
for (int32 j=0; j<count; j++) {
|
||||||
|
if (i == numbers[j]) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//#ifndef B_NETPOSITIVE_APP_SIGNATURE
|
//#ifndef B_NETPOSITIVE_APP_SIGNATURE
|
||||||
//#define B_NETPOSITIVE_APP_SIGNATURE "application/x-vnd.Be-NPOS"
|
//#define B_NETPOSITIVE_APP_SIGNATURE "application/x-vnd.Be-NPOS"
|
||||||
//#endif
|
//#endif
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ private:
|
|||||||
* Public Member functions.
|
* Public Member functions.
|
||||||
*/
|
*/
|
||||||
void MakeTermWindow (BRect &frame);
|
void MakeTermWindow (BRect &frame);
|
||||||
void RunNewTerm (void);
|
|
||||||
void SwitchTerm(void);
|
void SwitchTerm(void);
|
||||||
void ActivateTermWindow(team_id id);
|
void ActivateTermWindow(team_id id);
|
||||||
|
|
||||||
@@ -71,6 +70,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsMinimize (team_id);
|
bool IsMinimize (team_id);
|
||||||
|
int32 FindTerminalId();
|
||||||
|
|
||||||
int fRows, fCols, fXpos, fYpos;
|
int fRows, fCols, fXpos, fYpos;
|
||||||
bool fStartFullscreen;
|
bool fStartFullscreen;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
// Menu Message.
|
// Menu Message.
|
||||||
//
|
//
|
||||||
const uint32 MENU_SWITCH_TERM = 'MSWT';
|
const uint32 MENU_SWITCH_TERM = 'MSWT';
|
||||||
const uint32 MENU_NEW_TREM = 'MNTE';
|
const uint32 MENU_NEW_TERM = 'MNTE';
|
||||||
const uint32 MENU_PREF_OPEN = 'MPre';
|
const uint32 MENU_PREF_OPEN = 'MPre';
|
||||||
const uint32 MENU_FILE_QUIT = 'MFqu';
|
const uint32 MENU_FILE_QUIT = 'MFqu';
|
||||||
const uint32 MENU_CLEAR_ALL = 'MCAl';
|
const uint32 MENU_CLEAR_ALL = 'MCAl';
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#include <PropertyInfo.h>
|
#include <PropertyInfo.h>
|
||||||
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
@@ -202,7 +203,7 @@ TermWindow::SetupMenu(void)
|
|||||||
*/
|
*/
|
||||||
fFilemenu = new BMenu("Terminal");
|
fFilemenu = new BMenu("Terminal");
|
||||||
fFilemenu->AddItem(new BMenuItem("Switch Terminals", new BMessage(MENU_SWITCH_TERM),'G'));
|
fFilemenu->AddItem(new BMenuItem("Switch Terminals", new BMessage(MENU_SWITCH_TERM),'G'));
|
||||||
fFilemenu->AddItem(new BMenuItem("Start New Terminal", new BMessage(MENU_NEW_TREM), 'N'));
|
fFilemenu->AddItem(new BMenuItem("Start New Terminal", new BMessage(MENU_NEW_TERM), 'N'));
|
||||||
fFilemenu->AddSeparatorItem();
|
fFilemenu->AddSeparatorItem();
|
||||||
fFilemenu->AddItem(new BMenuItem("Page Setup...", new BMessage(MENU_PAGE_SETUP)));
|
fFilemenu->AddItem(new BMenuItem("Page Setup...", new BMessage(MENU_PAGE_SETUP)));
|
||||||
fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P'));
|
fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P'));
|
||||||
@@ -289,8 +290,14 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
be_app->PostMessage(MENU_SWITCH_TERM);
|
be_app->PostMessage(MENU_SWITCH_TERM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_NEW_TREM:
|
case MENU_NEW_TERM: {
|
||||||
be_app->PostMessage(MENU_NEW_TREM);
|
app_info info;
|
||||||
|
be_app->GetAppInfo(&info);
|
||||||
|
|
||||||
|
// try launching two different ways to work around possible problems
|
||||||
|
if (be_roster->Launch(&info.ref)!=B_OK)
|
||||||
|
be_roster->Launch(TERM_SIGNATURE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_PREF_OPEN:
|
case MENU_PREF_OPEN:
|
||||||
@@ -703,3 +710,6 @@ TermWindow::DoPrint()
|
|||||||
job.CommitJob();
|
job.CommitJob();
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user