xref: /haiku/src/apps/terminal/Shell.h (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
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 TermParse;
20 class TermView;
21 class Shell {
22 public:
23 			Shell();
24 	virtual		~Shell();
25 
26 	status_t	Open(int row, int col, const char *encoding, int argc, const char **argv);
27 	void		Close();
28 
29 	const char *	TTYName() const;
30 
31 	ssize_t		Read(void *buffer, size_t numBytes);
32 	ssize_t		Write(const void *buffer, size_t numBytes);
33 
34 	status_t	UpdateWindowSize(int row, int columns);
35 	status_t	Signal(int signal);
36 
37 	status_t	GetAttr(struct termios &attr);
38 	status_t	SetAttr(struct termios &attr);
39 
40 	int			FD() const;
41 	pid_t		ProcessID() const	{ return fProcessID; }
42 
43 	virtual	void	ViewAttached(TermView *view);
44 	virtual void	ViewDetached();
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