xref: /haiku/src/apps/terminal/Shell.h (revision 0041b382147b19ee82ba05e36f007951892c2223)
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,
28 							int argc, const char** argv);
29 	void		Close();
30 
31 	const char*	TTYName() const;
32 
33 	ssize_t		Read(void* buffer, size_t numBytes) const;
34 	ssize_t		Write(const void* buffer, size_t numBytes);
35 
36 	status_t	UpdateWindowSize(int row, int columns);
37 
38 	status_t	GetAttr(struct termios& attr) const;
39 	status_t	SetAttr(const struct termios& attr);
40 
41 	int			FD() const;
42 	pid_t		ProcessID() const	{ return fProcessID; }
43 
44 	bool		HasActiveProcesses() const;
45 
46 	virtual	status_t	AttachBuffer(TerminalBuffer* buffer);
47 	virtual void	DetachBuffer();
48 
49 private:
50 	int		fFd;
51 	pid_t		fProcessID;
52 	TermParse*	fTermParse;
53 	bool		fAttached;
54 
55 	status_t	_Spawn(int row, int col, const char* encoding,
56 							int argc, const char** argv);
57 };
58 
59 #endif // _SHELL_H
60