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 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 rgb_color PaletteColor(uint8 index); 46 int GuessPaletteColor(int red, int green, int blue); 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 60 void ReportX10MouseEvent(bool report); 61 void ReportNormalMouseEvent(bool report); 62 void ReportButtonMouseEvent(bool report); 63 void ReportAnyMouseEvent(bool report); 64 void EnableExtendedMouseCoordinates(bool enable); 65 66 protected: 67 virtual void NotifyListener(); 68 69 private: 70 void _SwitchScreenBuffer(); 71 72 private: 73 int fEncoding; 74 75 TerminalLine** fAlternateScreen; 76 HistoryBuffer* fAlternateHistory; 77 int32 fAlternateScreenOffset; 78 uint32 fAlternateAttributes; 79 rgb_color* fColorsPalette; 80 81 // listener/dirty region management 82 BMessenger fListener; 83 bool fListenerValid; 84 }; 85 86 87 #endif // TERMINAL_BUFFER_H 88