xref: /haiku/src/apps/terminal/TerminalBuffer.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2013, Haiku, Inc. All rights reserved.
3  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
4  * Distributed under the terms of the MIT License.
5  *
6  * Authors:
7  *		Ingo Weinhold, ingo_weinhold@gmx.de
8  *		Simon South, simon@simonsouth.net
9  *		Siarzhuk Zharski, zharik@gmx.li
10  */
11 #ifndef TERMINAL_BUFFER_H
12 #define TERMINAL_BUFFER_H
13 
14 #include <GraphicsDefs.h>
15 #include <Locker.h>
16 #include <Messenger.h>
17 
18 #include "BasicTerminalBuffer.h"
19 
20 
21 class TerminalBuffer : public BasicTerminalBuffer, public BLocker {
22 public:
23 								TerminalBuffer();
24 	virtual						~TerminalBuffer();
25 
26 			status_t			Init(int32 width, int32 height,
27 									int32 historySize);
28 
29 			void				SetListener(BMessenger listener);
30 			void				UnsetListener();
31 
32 			int					Encoding() const;
33 			void				SetEncoding(int encoding);
34 
35 			void				SetTitle(const char* title);
36 			void				SetColors(uint8* indexes, rgb_color* colors,
37 									int32 count = 1, bool dynamic = false);
38 			void				ResetColors(uint8* indexes,
39 									int32 count = 1, bool dynamic = false);
40 			void				SetCursorStyle(int32 style, bool blinking);
41 			void				SetCursorBlinking(bool blinking);
42 			void				SetCursorHidden(bool hidden);
43 			void				SetPaletteColor(uint8 index, rgb_color color);
44 			rgb_color			PaletteColor(uint8 index);
45 			int					GuessPaletteColor(int red, int green, int blue);
46 
47 			void				NotifyQuit(int32 reason);
48 
49 	virtual	status_t			ResizeTo(int32 width, int32 height);
50 	virtual	status_t			ResizeTo(int32 width, int32 height,
51 									int32 historyCapacity);
52 
53 			void				UseAlternateScreenBuffer(bool clear);
54 			void				UseNormalScreenBuffer();
55 
56 			void				EnableInterpretMetaKey(bool enable);
57 			void				EnableMetaKeySendsEscape(bool enable);
58 
59 			void				ReportX10MouseEvent(bool report);
60 			void				ReportNormalMouseEvent(bool report);
61 			void				ReportButtonMouseEvent(bool report);
62 			void				ReportAnyMouseEvent(bool report);
63 			void				EnableExtendedMouseCoordinates(bool enable);
64 
65 protected:
66 	virtual	void				NotifyListener();
67 
68 private:
69 			void				_SwitchScreenBuffer();
70 
71 private:
72 			int					fEncoding;
73 
74 			TerminalLine**		fAlternateScreen;
75 			HistoryBuffer*		fAlternateHistory;
76 			int32				fAlternateScreenOffset;
77 			uint32				fAlternateAttributes;
78 			rgb_color*			fColorsPalette;
79 
80 			// listener/dirty region management
81 			BMessenger			fListener;
82 			bool				fListenerValid;
83 };
84 
85 
86 #endif	// TERMINAL_BUFFER_H
87