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