1 /* 2 * Copyright 2003-2004, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini (burton666@libero.it) 7 */ 8 9 #ifndef __UNDOBUFFER_H 10 #define __UNDOBUFFER_H 11 12 #include <TextView.h> 13 14 15 class BClipboard; 16 17 class _BUndoBuffer_ { 18 public: 19 _BUndoBuffer_(BTextView *, undo_state); 20 virtual ~_BUndoBuffer_(); 21 22 void Undo(BClipboard *); 23 undo_state State(bool *); 24 25 protected: 26 virtual void UndoSelf(BClipboard *); 27 virtual void RedoSelf(BClipboard *); 28 29 BTextView *fTextView; 30 int32 fStart; 31 int32 fEnd; 32 33 char *fTextData; 34 int32 fTextLength; 35 text_run_array *fRunArray; 36 int32 fRunArrayLength; 37 38 bool fRedo; 39 40 private: 41 undo_state fState; 42 }; 43 44 45 // ******** _BCutUndoBuffer_ ******* 46 class _BCutUndoBuffer_ : public _BUndoBuffer_ { 47 public: 48 _BCutUndoBuffer_(BTextView *textView); 49 ~_BCutUndoBuffer_(); 50 51 protected: 52 virtual void RedoSelf(BClipboard *); 53 }; 54 55 56 // ******** _BPasteUndoBuffer_ ******* 57 class _BPasteUndoBuffer_ : public _BUndoBuffer_ { 58 public: 59 _BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32); 60 ~_BPasteUndoBuffer_(); 61 62 protected: 63 virtual void UndoSelf(BClipboard *); 64 virtual void RedoSelf(BClipboard *); 65 66 private: 67 char *fPasteText; 68 int32 fPasteTextLength; 69 text_run_array *fPasteRunArray; 70 int32 fPasteRunArrayLength; 71 }; 72 73 74 // ******** _BClearUndoBuffer_ ******* 75 class _BClearUndoBuffer_ : public _BUndoBuffer_ { 76 public: 77 _BClearUndoBuffer_(BTextView *textView); 78 ~_BClearUndoBuffer_(); 79 80 protected: 81 virtual void RedoSelf(BClipboard *); 82 }; 83 84 85 // ******** _BDropUndoBuffer_ ******** 86 class _BDropUndoBuffer_ : public _BUndoBuffer_ { 87 public: 88 _BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool); 89 ~_BDropUndoBuffer_(); 90 91 protected: 92 virtual void UndoSelf(BClipboard *); 93 virtual void RedoSelf(BClipboard *); 94 95 private: 96 char *fDropText; 97 int32 fDropTextLength; 98 text_run_array *fDropRunArray; 99 int32 fDropRunArrayLength; 100 101 int32 fDropLocation; 102 bool fInternalDrop; 103 }; 104 105 106 // ******** _BTypingUndoBuffer_ ******** 107 class _BTypingUndoBuffer_ : public _BUndoBuffer_ { 108 public: 109 _BTypingUndoBuffer_(BTextView *); 110 ~_BTypingUndoBuffer_(); 111 112 void InputCharacter(int32); 113 void BackwardErase(); 114 void ForwardErase(); 115 116 protected: 117 virtual void RedoSelf(BClipboard *); 118 virtual void UndoSelf(BClipboard *); 119 120 private: 121 void Reset(); 122 123 char *fTypedText; 124 int32 fTypedStart; 125 int32 fTypedEnd; 126 int32 fUndone; 127 }; 128 129 #endif //__UNDOBUFFER_H 130