xref: /haiku/src/apps/terminal/TermApp.h (revision 490f785868ff92a8195d84e9017dd1a6827854a3)
1d3dc729fSAxel Dörfler /*
291eec68cSIngo Weinhold  * Copyright 2001-2010, Haiku.
3d3dc729fSAxel Dörfler  * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
4d3dc729fSAxel Dörfler  * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
5d3dc729fSAxel Dörfler  *
6d3dc729fSAxel Dörfler  * Permission is hereby granted, free of charge, to any person obtaining
7d3dc729fSAxel Dörfler  * a copy of this software and associated documentation files or portions
8d3dc729fSAxel Dörfler  * thereof (the "Software"), to deal in the Software without restriction,
9d3dc729fSAxel Dörfler  * including without limitation the rights to use, copy, modify, merge,
10d3dc729fSAxel Dörfler  * publish, distribute, sublicense, and/or sell copies of the Software,
11d3dc729fSAxel Dörfler  * and to permit persons to whom the Software is furnished to do so, subject
12d3dc729fSAxel Dörfler  * to the following conditions:
13d3dc729fSAxel Dörfler  *
14d3dc729fSAxel Dörfler  *  * Redistributions of source code must retain the above copyright notice,
15d3dc729fSAxel Dörfler  *    this list of conditions and the following disclaimer.
16d3dc729fSAxel Dörfler  *
17d3dc729fSAxel Dörfler  *  * Redistributions in binary form must reproduce the above copyright notice
18d3dc729fSAxel Dörfler  *    in the  binary, as well as this list of conditions and the following
19d3dc729fSAxel Dörfler  *    disclaimer in the documentation and/or other materials provided with
20d3dc729fSAxel Dörfler  *    the distribution.
21d3dc729fSAxel Dörfler  *
22d3dc729fSAxel Dörfler  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23d3dc729fSAxel Dörfler  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24d3dc729fSAxel Dörfler  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25d3dc729fSAxel Dörfler  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26d3dc729fSAxel Dörfler  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27d3dc729fSAxel Dörfler  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28d3dc729fSAxel Dörfler  * THE SOFTWARE.
29d3dc729fSAxel Dörfler  *
30d3dc729fSAxel Dörfler  */
317f108511SAxel Dörfler #ifndef TERM_APP_H
327f108511SAxel Dörfler #define TERM_APP_H
33d3dc729fSAxel Dörfler 
34d3dc729fSAxel Dörfler 
357f108511SAxel Dörfler #include <Application.h>
368989d8a5SStephan Aßmus #include <Catalog.h>
37d18fc399SAdrien Destugues #include <File.h>
38d3dc729fSAxel Dörfler #include <String.h>
39d3dc729fSAxel Dörfler 
4091eec68cSIngo Weinhold 
41bb4632f1SStefano Ceccherini class Arguments;
42d3dc729fSAxel Dörfler class BRect;
43702e4be8SStefano Ceccherini class BWindow;
4491eec68cSIngo Weinhold 
4591eec68cSIngo Weinhold 
467f108511SAxel Dörfler class TermApp : public BApplication {
47d3dc729fSAxel Dörfler public:
4876649c03SAxel Dörfler 								TermApp();
497f108511SAxel Dörfler 	virtual						~TermApp();
50d3dc729fSAxel Dörfler 
517f108511SAxel Dörfler protected:
52*490f7858SIngo Weinhold 	virtual	void				ReadyToRun();
53*490f7858SIngo Weinhold 	virtual bool				QuitRequested();
54*490f7858SIngo Weinhold 	virtual	void				Quit();
55*490f7858SIngo Weinhold 	virtual	void				AboutRequested();
56*490f7858SIngo Weinhold 	virtual	void				MessageReceived(BMessage* message);
57*490f7858SIngo Weinhold 	virtual	void				RefsReceived(BMessage* message);
58*490f7858SIngo Weinhold 	virtual	void				ArgvReceived(int32 argc, char** argv);
59d3dc729fSAxel Dörfler 
60d3dc729fSAxel Dörfler private:
6191eec68cSIngo Weinhold 			status_t			_MakeTermWindow(BRect& frame,
6291eec68cSIngo Weinhold 									uint32 workspaces);
6391eec68cSIngo Weinhold 			status_t			_GetWindowPositionFile(BFile* file,
6491eec68cSIngo Weinhold 									uint32 openMode);
6591eec68cSIngo Weinhold 			status_t			_LoadWindowPosition(BRect* frame,
6691eec68cSIngo Weinhold 									uint32* workspaces);
67d18fc399SAdrien Destugues 			status_t			_SaveWindowPosition(BMessage* message);
687f108511SAxel Dörfler 			void				_SwitchTerm();
697f108511SAxel Dörfler 			void				_ActivateTermWindow(team_id id);
706a63492fSAxel Dörfler 			bool				_IsSwitchTarget(team_id id);
7191eec68cSIngo Weinhold 			void				_SanitizeIDs(BMessage* data, uint8* windows,
7291eec68cSIngo Weinhold 									ssize_t length);
7391eec68cSIngo Weinhold 			bool				_UpdateIDs(bool set, uint8* windows,
7491eec68cSIngo Weinhold 									ssize_t maxLength, ssize_t* _length);
757f108511SAxel Dörfler 			void				_UpdateRegistration(bool set);
767f108511SAxel Dörfler 			void				_UnregisterTerminal();
777f108511SAxel Dörfler 			void				_RegisterTerminal();
78d3dc729fSAxel Dörfler 
79dbc03773SIngo Weinhold 			void				_HandleChildCleanup();
80dbc03773SIngo Weinhold 	static	void				_SigChildHandler(int signal, void* data);
81dbc03773SIngo Weinhold 	static	status_t			_ChildCleanupThread(void* data);
82dbc03773SIngo Weinhold 
837f108511SAxel Dörfler 			void				_Usage(char *name);
847f108511SAxel Dörfler 
8591eec68cSIngo Weinhold private:
86265fea4aSFrançois Revol 			bool				fStartFullscreen;
870d5dea62SAxel Dörfler 			BString				fWindowTitle;
887f108511SAxel Dörfler 			int32				fWindowNumber;
8985f69514SStefano Ceccherini 
90702e4be8SStefano Ceccherini 			BWindow*			fTermWindow;
91d3dc729fSAxel Dörfler 			BRect				fTermFrame;
92d18fc399SAdrien Destugues 			uint32				fTermWorkspaces;
93bb4632f1SStefano Ceccherini 			Arguments*			fArgs;
94d3dc729fSAxel Dörfler };
95d3dc729fSAxel Dörfler 
9691eec68cSIngo Weinhold 
977f108511SAxel Dörfler #endif	// TERM_APP_H
98