Moved spawning the shell from TermApp to TermWindow
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,7 +37,6 @@ PrefHandler *gTermPref;
|
||||
|
||||
static bool sUsageRequested = false;
|
||||
static bool sGeometryRequested = false;
|
||||
static bool sColorRequested = false;
|
||||
|
||||
struct standard_args {
|
||||
char *name;
|
||||
@@ -102,6 +101,7 @@ TermApp::ReadyToRun()
|
||||
status_t status = _MakeTermWindow(fTermFrame);
|
||||
|
||||
// failed spawn, print stdout and open alert panel
|
||||
// TODO: This alert does never show up.
|
||||
if (status < B_OK) {
|
||||
(new BAlert("alert", "Terminal couldn't start the shell. Sorry.",
|
||||
"ok", NULL, NULL, B_WIDTH_FROM_LABEL,
|
||||
@@ -298,22 +298,15 @@ TermApp::_MakeTermWindow(BRect &frame)
|
||||
command = fCommandLine.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);
|
||||
try {
|
||||
fTermWindow = new TermWindow(frame, fWindowTitle.String(), command);
|
||||
} catch (int error) {
|
||||
return (status_t)error;
|
||||
} catch (...) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
||||
const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING));
|
||||
int pfd = spawn_shell(rows, cols, command, encoding);
|
||||
if (pfd < 0)
|
||||
return pfd;
|
||||
|
||||
fTermWindow = new TermWindow(frame, fWindowTitle.String(), pfd);
|
||||
fTermWindow->Show();
|
||||
|
||||
return B_OK;
|
||||
|
||||
@@ -54,15 +54,53 @@ extern PrefHandler *gTermPref;
|
||||
//#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html"
|
||||
|
||||
|
||||
TermWindow::TermWindow(BRect frame, const char* title, int fd)
|
||||
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||
: BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE),
|
||||
fPfd(fd)
|
||||
fPfd(-1),
|
||||
fTermParse(NULL),
|
||||
fMenubar(NULL),
|
||||
fFilemenu(NULL),
|
||||
fEditmenu(NULL),
|
||||
fEncodingmenu(NULL),
|
||||
fHelpmenu(NULL),
|
||||
fFontMenu(NULL),
|
||||
fWindowSizeMenu(NULL),
|
||||
fNewFontMenu(NULL),
|
||||
fTermView(NULL),
|
||||
fBaseView(NULL),
|
||||
fCodeConv(NULL),
|
||||
fPrintSettings(NULL),
|
||||
fPrefWindow(NULL),
|
||||
fFindPanel(NULL),
|
||||
fWindowUpdate(NULL),
|
||||
fSavedFrame(0, 0, 0, 0),
|
||||
fFindString(""),
|
||||
fFindForwardMenuItem(NULL),
|
||||
fFindBackwardMenuItem(NULL),
|
||||
fFindSelection(false),
|
||||
fForwardSearch(false),
|
||||
fMatchCase(false),
|
||||
fMatchWord(false)
|
||||
{
|
||||
InitWindow();
|
||||
int rows = gTermPref->getInt32(PREF_ROWS);
|
||||
if (rows < 1) {
|
||||
rows = 1;
|
||||
gTermPref->setInt32(PREF_ROWS, rows);
|
||||
}
|
||||
|
||||
fPrintSettings = NULL;
|
||||
fPrefWindow = NULL;
|
||||
fFindPanel = NULL;
|
||||
int cols = gTermPref->getInt32(PREF_COLS);
|
||||
if (cols < MIN_COLS) {
|
||||
cols = MIN_COLS;
|
||||
gTermPref->setInt32(PREF_COLS, cols);
|
||||
}
|
||||
|
||||
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
||||
const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING));
|
||||
fPfd = spawn_shell(rows, cols, command, encoding);
|
||||
if (fPfd < 0)
|
||||
throw fPfd;
|
||||
|
||||
InitWindow();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,9 +125,8 @@ TermWindow::~TermWindow()
|
||||
|
||||
|
||||
/** Initialize Window object. */
|
||||
|
||||
void
|
||||
TermWindow::InitWindow(void)
|
||||
TermWindow::InitWindow()
|
||||
{
|
||||
// make menu bar
|
||||
SetupMenu();
|
||||
@@ -584,7 +621,7 @@ TermWindow::MessageReceived(BMessage *message)
|
||||
// Dispatch Mesasge.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::WindowActivated (bool )
|
||||
TermWindow::WindowActivated(bool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class FindWindow;
|
||||
|
||||
class TermWindow : public BWindow {
|
||||
public:
|
||||
TermWindow(BRect frame, const char* title, int fd);
|
||||
TermWindow(BRect frame, const char* title, const char *command);
|
||||
virtual ~TermWindow();
|
||||
|
||||
void TermWinActivate();
|
||||
|
||||
Reference in New Issue
Block a user