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 int Encoding() const 53 { return fShellInfo.Encoding(); } 54 void SetEncoding(int encoding) 55 { fShellInfo.SetEncoding(encoding); } 56 57 bool HasActiveProcesses() const; 58 bool GetActiveProcessInfo( 59 ActiveProcessInfo& _info) const; 60 61 virtual status_t AttachBuffer(TerminalBuffer* buffer); 62 virtual void DetachBuffer(); 63 64 private: 65 status_t _Spawn(int row, int col, 66 const ShellParameters& parameters); 67 68 private: 69 ShellInfo fShellInfo; 70 int fFd; 71 pid_t fProcessID; 72 TermParse* fTermParse; 73 bool fAttached; 74 }; 75 76 77 #endif // _SHELL_H 78