got rid of the tty_name global
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4d5d5756b4
commit
b19041249d
@ -107,46 +107,18 @@ TermApp::ReadyToRun()
|
|||||||
if (usage_requested)
|
if (usage_requested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char *command = NULL;
|
status_t status = MakeTermWindow(fTermFrame);
|
||||||
const char *encoding;
|
|
||||||
int rows, cols;
|
|
||||||
|
|
||||||
encoding = gTermPref->getString(PREF_TEXT_ENCODING);
|
|
||||||
|
|
||||||
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
|
||||||
const etable *p = encoding_table;
|
|
||||||
while (p->name) {
|
|
||||||
if (!strcmp(p->name, encoding)) {
|
|
||||||
encoding = p->shortname;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandLine.Length() > 0)
|
|
||||||
command = CommandLine.String();
|
|
||||||
else
|
|
||||||
command = gTermPref->getString(PREF_SHELL);
|
|
||||||
|
|
||||||
rows = gTermPref->getInt32(PREF_ROWS);
|
|
||||||
if (rows < 1)
|
|
||||||
gTermPref->setInt32(PREF_ROWS, rows = 1);
|
|
||||||
|
|
||||||
cols = gTermPref->getInt32(PREF_COLS);
|
|
||||||
if (cols < MIN_COLS)
|
|
||||||
gTermPref->setInt32(PREF_COLS, cols = MIN_COLS);
|
|
||||||
|
|
||||||
pfd = spawn_shell(rows, cols, command, encoding);
|
|
||||||
|
|
||||||
// failed spawn, print stdout and open alert panel
|
// failed spawn, print stdout and open alert panel
|
||||||
if (pfd == -1 ) {
|
if (status < B_OK) {
|
||||||
(new BAlert("alert", "Terminal couldn't start the shell. Sorry.",
|
(new BAlert("alert", "Terminal couldn't start the shell. Sorry.",
|
||||||
"ok", NULL, NULL, B_WIDTH_FROM_LABEL,
|
"ok", NULL, NULL, B_WIDTH_FROM_LABEL,
|
||||||
B_INFO_ALERT))->Go(NULL);
|
B_INFO_ALERT))->Go(NULL);
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeTermWindow(fTermFrame);
|
|
||||||
// using BScreen::Frame isn't enough
|
// using BScreen::Frame isn't enough
|
||||||
if (fStartFullscreen)
|
if (fStartFullscreen)
|
||||||
BMessenger(fTermWindow).SendMessage(FULLSCREEN);
|
BMessenger(fTermWindow).SendMessage(FULLSCREEN);
|
||||||
@ -372,11 +344,43 @@ TermApp::RefsReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
TermApp::MakeTermWindow(BRect &frame)
|
TermApp::MakeTermWindow(BRect &frame)
|
||||||
{
|
{
|
||||||
fTermWindow = new TermWindow(frame, fWindowTitle.String());
|
const char *encoding = gTermPref->getString(PREF_TEXT_ENCODING);
|
||||||
|
|
||||||
|
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
||||||
|
const etable *p = encoding_table;
|
||||||
|
while (p->name) {
|
||||||
|
if (!strcmp(p->name, encoding)) {
|
||||||
|
encoding = p->shortname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *command = NULL;
|
||||||
|
if (CommandLine.Length() > 0)
|
||||||
|
command = CommandLine.String();
|
||||||
|
else
|
||||||
|
command = gTermPref->getString(PREF_SHELL);
|
||||||
|
|
||||||
|
int rows = gTermPref->getInt32(PREF_ROWS);
|
||||||
|
if (rows < 1)
|
||||||
|
gTermPref->setInt32(PREF_ROWS, rows = 1);
|
||||||
|
|
||||||
|
int cols = gTermPref->getInt32(PREF_COLS);
|
||||||
|
if (cols < MIN_COLS)
|
||||||
|
gTermPref->setInt32(PREF_COLS, cols = MIN_COLS);
|
||||||
|
|
||||||
|
int pfd = spawn_shell(rows, cols, command, encoding);
|
||||||
|
if (pfd < 0)
|
||||||
|
return pfd;
|
||||||
|
|
||||||
|
fTermWindow = new TermWindow(frame, fWindowTitle.String(), pfd);
|
||||||
fTermWindow->Show();
|
fTermWindow->Show();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
/*
|
/*
|
||||||
* Public Member functions.
|
* Public Member functions.
|
||||||
*/
|
*/
|
||||||
void MakeTermWindow (BRect &frame);
|
status_t MakeTermWindow (BRect &frame);
|
||||||
void SwitchTerm(void);
|
void SwitchTerm(void);
|
||||||
void ActivateTermWindow(team_id id);
|
void ActivateTermWindow(team_id id);
|
||||||
|
|
||||||
|
@ -2342,6 +2342,7 @@ TermView::GetSelection(BString &str)
|
|||||||
fTextBuffer->GetStringFromRegion(str);
|
fTextBuffer->GetStringFromRegion(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send DrawRect data to Draw Engine thread.
|
// Send DrawRect data to Draw Engine thread.
|
||||||
inline void
|
inline void
|
||||||
TermView::SendDataToDrawEngine(int x1, int y1, int x2, int y2)
|
TermView::SendDataToDrawEngine(int x1, int y1, int x2, int y2)
|
||||||
|
@ -186,7 +186,6 @@ public:
|
|||||||
void GetFontInfo (int *, int*);
|
void GetFontInfo (int *, int*);
|
||||||
bool Find (const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
bool Find (const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
||||||
void GetSelection (BString &str);
|
void GetSelection (BString &str);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PRIVATE MEMBER.
|
* PRIVATE MEMBER.
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <WindowScreen.h>
|
#include <WindowScreen.h>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -56,8 +58,9 @@ extern int gNowCoding; /* defined TermParce.cpp */
|
|||||||
void SetCoding(int);
|
void SetCoding(int);
|
||||||
|
|
||||||
|
|
||||||
TermWindow::TermWindow(BRect frame, const char* title)
|
TermWindow::TermWindow(BRect frame, const char* title, int pfd)
|
||||||
: BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE)
|
: BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE),
|
||||||
|
fPfd(pfd)
|
||||||
{
|
{
|
||||||
InitWindow();
|
InitWindow();
|
||||||
|
|
||||||
@ -425,7 +428,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
else if (!strcmp("tty", spe.FindString("property", i))) {
|
else if (!strcmp("tty", spe.FindString("property", i))) {
|
||||||
BMessage reply(B_REPLY);
|
BMessage reply(B_REPLY);
|
||||||
reply.AddString("result", &tty_name[8]);
|
reply.AddString("result", ttyname(fPfd));
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
} else {
|
} else {
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
|
@ -47,7 +47,7 @@ class FindDlg;
|
|||||||
|
|
||||||
class TermWindow : public BWindow {
|
class TermWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
TermWindow(BRect frame, const char* title);
|
TermWindow(BRect frame, const char* title, int pfd);
|
||||||
~TermWindow();
|
~TermWindow();
|
||||||
|
|
||||||
void Quit (void);
|
void Quit (void);
|
||||||
@ -74,6 +74,7 @@ private:
|
|||||||
/*
|
/*
|
||||||
* data member
|
* data member
|
||||||
*/
|
*/
|
||||||
|
int fPfd;
|
||||||
TermParse *fTermParse;
|
TermParse *fTermParse;
|
||||||
BMenuBar *fMenubar;
|
BMenuBar *fMenubar;
|
||||||
BMenu *fFilemenu, *fEditmenu, *fEncodingmenu, *fHelpmenu, *fFontMenu, *fWindowSizeMenu, *fNewFontMenu;
|
BMenu *fFilemenu, *fEditmenu, *fEncodingmenu, *fHelpmenu, *fFontMenu, *fWindowSizeMenu, *fNewFontMenu;
|
||||||
|
@ -122,8 +122,6 @@ typedef struct
|
|||||||
/* global varriables */
|
/* global varriables */
|
||||||
|
|
||||||
pid_t sh_pid;
|
pid_t sh_pid;
|
||||||
char tty_name[B_PATH_NAME_LENGTH];
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
spawn_shell(int row, int col, const char *command, const char *coding)
|
spawn_shell(int row, int col, const char *command, const char *coding)
|
||||||
@ -157,6 +155,7 @@ spawn_shell(int row, int col, const char *command, const char *coding)
|
|||||||
* which is already in use, so we simply go until the open succeeds.
|
* which is already in use, so we simply go until the open succeeds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
char tty_name[B_PATH_NAME_LENGTH];
|
||||||
DIR *dir = opendir("/dev/pt/");
|
DIR *dir = opendir("/dev/pt/");
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
struct dirent *dirEntry;
|
struct dirent *dirEntry;
|
||||||
|
@ -88,7 +88,6 @@ int spawn_shell (int, int, const char *, const char *);
|
|||||||
void Setenv (const char *, const char *);
|
void Setenv (const char *, const char *);
|
||||||
|
|
||||||
extern pid_t sh_pid; /* shell process ID */
|
extern pid_t sh_pid; /* shell process ID */
|
||||||
extern char tty_name[]; /* tty device file name */
|
|
||||||
extern int pfd_num; /* number of pfd */
|
extern int pfd_num; /* number of pfd */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user