1 /* 2 * Copyright 2007 Haiku, Inc. 3 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net> 4 * Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net> 5 * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. 6 * Distributed under the terms of the MIT License. 7 * Authors: 8 * Stefano Ceccherini <stefano.ceccherini@gmail.com> 9 * Kian Duffy <myob@users.sourceforge.net> 10 * Kazuho Okui 11 * Takashi Murai 12 */ 13 #ifndef _SHELL_H 14 #define _SHELL_H 15 16 17 #include "ShellInfo.h" 18 19 20 class ActiveProcessInfo; 21 class ShellParameters; 22 // TODO: Maybe merge TermParse and Shell classes ? 23 class TerminalBuffer; 24 class TermParse; 25 26 27 class Shell { 28 public: 29 Shell(); 30 virtual ~Shell(); 31 32 status_t Open(int row, int col, 33 const ShellParameters& parameters); 34 void Close(); 35 36 const char* TTYName() const; 37 38 ssize_t Read(void* buffer, size_t numBytes) const; 39 ssize_t Write(const void* buffer, size_t numBytes); 40 41 status_t UpdateWindowSize(int row, int columns); 42 43 status_t GetAttr(struct termios& attr) const; 44 status_t SetAttr(const struct termios& attr); 45 46 int FD() const; 47 pid_t ProcessID() const 48 { return fShellInfo.ProcessID(); } 49 const ShellInfo& Info() const 50 { return fShellInfo; } 51 52 bool HasActiveProcesses() const; 53 bool GetActiveProcessInfo( 54 ActiveProcessInfo& _info) const; 55 56 virtual status_t AttachBuffer(TerminalBuffer* buffer); 57 virtual void DetachBuffer(); 58 59 private: 60 status_t _Spawn(int row, int col, 61 const ShellParameters& parameters); 62 63 private: 64 ShellInfo fShellInfo; 65 int fFd; 66 pid_t fProcessID; 67 TermParse* fTermParse; 68 bool fAttached; 69 }; 70 71 72 #endif // _SHELL_H 73