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