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 * Siarzhuk Zharski, zharik@gmx.li 9 */ 10 #ifndef TERMINAL_BUFFER_H 11 #define TERMINAL_BUFFER_H 12 13 #include <GraphicsDefs.h> 14 #include <Locker.h> 15 #include <Messenger.h> 16 17 #include "BasicTerminalBuffer.h" 18 19 20 class TerminalBuffer : public BasicTerminalBuffer, public BLocker { 21 public: 22 TerminalBuffer(); 23 virtual ~TerminalBuffer(); 24 25 status_t Init(int32 width, int32 height, 26 int32 historySize); 27 28 void SetListener(BMessenger listener); 29 void UnsetListener(); 30 31 int Encoding() const; 32 void SetEncoding(int encoding); 33 34 void SetTitle(const char* title); 35 void SetColors(uint8* indexes, rgb_color* colors, 36 int32 count = 1, bool dynamic = false); 37 void ResetColors(uint8* indexes, 38 int32 count = 1, bool dynamic = false); 39 void SetCursorStyle(int32 style, bool blinking); 40 void SetCursorBlinking(bool blinking); 41 void SetCursorHidden(bool hidden); 42 void SetPaletteColor(uint8 index, rgb_color color); 43 rgb_color PaletteColor(uint8 index); 44 int GuessPaletteColor(int red, int green, int blue); 45 46 void NotifyQuit(int32 reason); 47 48 virtual status_t ResizeTo(int32 width, int32 height); 49 virtual status_t ResizeTo(int32 width, int32 height, 50 int32 historyCapacity); 51 52 void UseAlternateScreenBuffer(bool clear); 53 void UseNormalScreenBuffer(); 54 55 void ReportX10MouseEvent(bool report); 56 void ReportNormalMouseEvent(bool report); 57 void ReportButtonMouseEvent(bool report); 58 void ReportAnyMouseEvent(bool report); 59 60 protected: 61 virtual void NotifyListener(); 62 63 private: 64 void _SwitchScreenBuffer(); 65 66 private: 67 int fEncoding; 68 69 TerminalLine** fAlternateScreen; 70 HistoryBuffer* fAlternateHistory; 71 int32 fAlternateScreenOffset; 72 uint32 fAlternateAttributes; 73 rgb_color* fColorsPalette; 74 75 // listener/dirty region management 76 BMessenger fListener; 77 bool fListenerValid; 78 }; 79 80 81 #endif // TERMINAL_BUFFER_H 82