Added Shell::HasActiveProcesses() and TermView::IsShellBusy() (which calls

the former) to tell if some process launched from the terminal is still
running. Some style fix in Shell.h, made a parameter const.
Added basic TermWindow::QuitRequested()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37631 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2010-07-20 20:38:53 +00:00
parent 50f1e6269d
commit d9fdb4f6cd
6 changed files with 42 additions and 10 deletions
+12 -1
View File
@@ -214,7 +214,7 @@ Shell::GetAttr(struct termios &attr) const
status_t status_t
Shell::SetAttr(struct termios &attr) Shell::SetAttr(const struct termios &attr)
{ {
if (tcsetattr(fFd, TCSANOW, &attr) < 0) if (tcsetattr(fFd, TCSANOW, &attr) < 0)
return errno; return errno;
@@ -229,6 +229,17 @@ Shell::FD() const
} }
bool
Shell::HasActiveProcesses() const
{
pid_t running = tcgetpgrp(fFd);
if (running == fProcessID || running == -1)
return false;
return true;
}
status_t status_t
Shell::AttachBuffer(TerminalBuffer *buffer) Shell::AttachBuffer(TerminalBuffer *buffer)
{ {
+7 -3
View File
@@ -24,7 +24,8 @@ public:
Shell(); Shell();
virtual ~Shell(); virtual ~Shell();
status_t Open(int row, int col, const char *encoding, int argc, const char **argv); status_t Open(int row, int col, const char* encoding,
int argc, const char** argv);
void Close(); void Close();
const char* TTYName() const; const char* TTYName() const;
@@ -35,11 +36,13 @@ public:
status_t UpdateWindowSize(int row, int columns); status_t UpdateWindowSize(int row, int columns);
status_t GetAttr(struct termios& attr) const; status_t GetAttr(struct termios& attr) const;
status_t SetAttr(struct termios &attr); status_t SetAttr(const struct termios& attr);
int FD() const; int FD() const;
pid_t ProcessID() const { return fProcessID; } pid_t ProcessID() const { return fProcessID; }
bool HasActiveProcesses() const;
virtual status_t AttachBuffer(TerminalBuffer* buffer); virtual status_t AttachBuffer(TerminalBuffer* buffer);
virtual void DetachBuffer(); virtual void DetachBuffer();
@@ -49,7 +52,8 @@ private:
TermParse* fTermParse; TermParse* fTermParse;
bool fAttached; bool fAttached;
status_t _Spawn(int row, int col, const char *encoding, int argc, const char **argv); status_t _Spawn(int row, int col, const char* encoding,
int argc, const char** argv);
}; };
#endif // _SHELL_H #endif // _SHELL_H
+7
View File
@@ -381,6 +381,13 @@ TermView::~TermView()
} }
bool
TermView::IsShellBusy() const
{
return fShell != NULL && fShell->HasActiveProcesses();
}
/* static */ /* static */
BArchivable * BArchivable *
TermView::Instantiate(BMessage* data) TermView::Instantiate(BMessage* data)
+2
View File
@@ -46,6 +46,8 @@ public:
virtual void GetPreferredSize(float* _width, float* _height); virtual void GetPreferredSize(float* _width, float* _height);
bool IsShellBusy() const;
const char* TerminalName() const; const char* TerminalName() const;
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; } inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
+7
View File
@@ -230,6 +230,13 @@ TermWindow::_InitWindow()
} }
bool
TermWindow::QuitRequested()
{
return BWindow::QuitRequested();
}
void void
TermWindow::MenusBeginning() TermWindow::MenusBeginning()
{ {
+1
View File
@@ -56,6 +56,7 @@ public:
void SessionChanged(); void SessionChanged();
protected: protected:
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void WindowActivated(bool); virtual void WindowActivated(bool);
virtual void MenusBeginning(); virtual void MenusBeginning();