xref: /haiku/src/apps/terminal/TerminalBuffer.h (revision 1b80286772b529a3d6de3bbeb0720c62e6a32fed)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TERMINAL_BUFFER_H
6 #define TERMINAL_BUFFER_H
7 
8 #include <Locker.h>
9 #include <Messenger.h>
10 
11 #include "BasicTerminalBuffer.h"
12 
13 
14 class TerminalBuffer : public BasicTerminalBuffer, public BLocker {
15 public:
16 								TerminalBuffer();
17 	virtual						~TerminalBuffer();
18 
19 			status_t			Init(int32 width, int32 height,
20 									int32 historySize);
21 
22 			void				SetListener(BMessenger listener);
23 			void				UnsetListener();
24 
25 			int					Encoding() const;
26 			void				SetEncoding(int encoding);
27 
28 			void				SetTitle(const char* title);
29 			void				NotifyQuit(int32 reason);
30 
31 	virtual	status_t			ResizeTo(int32 width, int32 height);
32 	virtual	status_t			ResizeTo(int32 width, int32 height,
33 									int32 historyCapacity);
34 
35 			void				UseAlternateScreenBuffer(bool clear);
36 			void				UseNormalScreenBuffer();
37 
38 			void				ReportAnyMouseEvent(bool reportAnyMouseEvent);
39 
40 protected:
41 	virtual	void				NotifyListener();
42 
43 private:
44 			void				_SwitchScreenBuffer();
45 
46 private:
47 			int					fEncoding;
48 
49 			TerminalLine**		fAlternateScreen;
50 			HistoryBuffer*		fAlternateHistory;
51 			int32				fAlternateScreenOffset;
52 
53 			// listener/dirty region management
54 			BMessenger			fListener;
55 			bool				fListenerValid;
56 };
57 
58 
59 #endif	// TERMINAL_BUFFER_H
60