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

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)
{ {

View File

@ -24,32 +24,36 @@ 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;
ssize_t Read(void *buffer, size_t numBytes) const; ssize_t Read(void* buffer, size_t numBytes) const;
ssize_t Write(const void *buffer, size_t numBytes); ssize_t Write(const void* buffer, size_t numBytes);
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; }
virtual status_t AttachBuffer(TerminalBuffer *buffer); bool HasActiveProcesses() const;
virtual status_t AttachBuffer(TerminalBuffer* buffer);
virtual void DetachBuffer(); virtual void DetachBuffer();
private: private:
int fFd; int fFd;
pid_t fProcessID; pid_t fProcessID;
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

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)

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; }

View File

@ -230,6 +230,13 @@ TermWindow::_InitWindow()
} }
bool
TermWindow::QuitRequested()
{
return BWindow::QuitRequested();
}
void void
TermWindow::MenusBeginning() TermWindow::MenusBeginning()
{ {

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();