Shell.h revision 17dfb8b1cb676292928973a7690c277a9875d5c9
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 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files or portions
9 * thereof (the "Software"), to deal in the Software without restriction,
10 * including without limitation the rights to use, copy, modify, merge,
11 * publish, distribute, sublicense, and/or sell copies of the Software,
12 * and to permit persons to whom the Software is furnished to do so, subject
13 * to the following conditions:
14 *
15 *  * Redistributions of source code must retain the above copyright notice,
16 *    this list of conditions and the following disclaimer.
17 *
18 *  * Redistributions in binary form must reproduce the above copyright notice
19 *    in the  binary, as well as this list of conditions and the following
20 *    disclaimer in the documentation and/or other materials provided with
21 *    the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * THE SOFTWARE.
30 *
31 */
32
33#ifndef _SHELL_H
34#define _SHELL_H
35
36#include <SupportDefs.h>
37
38// TODO: Maybe merge TermParse and Shell classes ?
39class TermParse;
40class TermView;
41class Shell {
42public:
43			Shell();
44	virtual		~Shell();
45
46	status_t	Open(int row, int col, const char *command, const char *coding);
47	void		Close();
48
49	const char *	TTYName() const;
50
51	ssize_t		Read(void *buffer, size_t numBytes);
52	ssize_t		Write(const void *buffer, size_t numBytes);
53
54	status_t	UpdateWindowSize(int row, int columns);
55	status_t	Signal(int signal);
56
57	status_t	GetAttr(struct termios &attr);
58	status_t	SetAttr(struct termios &attr);
59
60	int		FD() const;
61
62	virtual	void	ViewAttached(TermView *view);
63	virtual void	ViewDetached();
64
65private:
66	int		fFd;
67	pid_t		fProcessID;
68	TermParse	*fTermParse;
69	bool		fAttached;
70
71	status_t	_Spawn(int row, int col, const char *command, const char *coding);
72};
73
74#endif // _SHELL_H
75