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 #include <SupportDefs.h> 17 18 // TODO: Maybe merge TermParse and Shell classes ? 19 class TerminalBuffer; 20 class TermParse; 21 22 class Shell { 23 public: 24 Shell(); 25 virtual ~Shell(); 26 27 status_t Open(int row, int col, const char *encoding, int argc, const char **argv); 28 void Close(); 29 30 const char * TTYName() const; 31 32 ssize_t Read(void *buffer, size_t numBytes) const; 33 ssize_t Write(const void *buffer, size_t numBytes); 34 35 status_t UpdateWindowSize(int row, int columns); 36 37 status_t GetAttr(struct termios &attr) const; 38 status_t SetAttr(struct termios &attr); 39 40 int FD() const; 41 pid_t ProcessID() const { return fProcessID; } 42 43 virtual status_t AttachBuffer(TerminalBuffer *buffer); 44 virtual void DetachBuffer(); 45 46 private: 47 int fFd; 48 pid_t fProcessID; 49 TermParse *fTermParse; 50 bool fAttached; 51 52 status_t _Spawn(int row, int col, const char *encoding, int argc, const char **argv); 53 }; 54 55 #endif // _SHELL_H 56