1/*
2 * Copyright 2013-2023, 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
21class TerminalBuffer : public BasicTerminalBuffer, public BLocker {
22public:
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				GetColor(uint8 index);
41			void				SetCursorStyle(int32 style, bool blinking);
42			void				SetCursorBlinking(bool blinking);
43			void				SetCursorHidden(bool hidden);
44			void				SetPaletteColor(uint8 index, rgb_color color);
45			inline const rgb_color*
46								Palette() const { return fColorsPalette; }
47
48			void				NotifyQuit(int32 reason);
49
50	virtual	status_t			ResizeTo(int32 width, int32 height);
51	virtual	status_t			ResizeTo(int32 width, int32 height,
52									int32 historyCapacity);
53
54			void				UseAlternateScreenBuffer(bool clear);
55			void				UseNormalScreenBuffer();
56
57			void				EnableInterpretMetaKey(bool enable);
58			void				EnableMetaKeySendsEscape(bool enable);
59			void				EnableBracketedPasteMode(bool enable);
60
61			void				ReportX10MouseEvent(bool report);
62			void				ReportNormalMouseEvent(bool report);
63			void				ReportButtonMouseEvent(bool report);
64			void				ReportAnyMouseEvent(bool report);
65			void				EnableExtendedMouseCoordinates(bool enable);
66
67protected:
68	virtual	void				NotifyListener();
69
70private:
71			void				_SwitchScreenBuffer();
72
73private:
74			int					fEncoding;
75
76			TerminalLine**		fAlternateScreen;
77			HistoryBuffer*		fAlternateHistory;
78			int32				fAlternateScreenOffset;
79			Attributes			fAlternateAttributes;
80			rgb_color*			fColorsPalette;
81
82			// listener/dirty region management
83			BMessenger			fListener;
84			bool				fListenerValid;
85};
86
87
88#endif	// TERMINAL_BUFFER_H
89