2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Marc Flerackers (mflerackers@androme.be)
8 #ifndef __TEXTGAPBUFFER_H
9 #define __TEXTGAPBUFFER_H
12 #include <SupportDefs.h>
27 void InsertText(const char* inText
, int32 inNumItems
,
29 bool InsertText(BFile
* file
, int32 fileOffset
,
30 int32 amount
, int32 atIndex
);
31 void RemoveRange(int32 start
, int32 end
);
33 bool FindChar(char inChar
, int32 fromIndex
,
37 const char* RealText();
40 const char* GetString(int32 fromOffset
, int32
* numBytes
);
41 void GetString(int32 offset
, int32 length
,
44 char RealCharAt(int32 offset
) const;
46 bool PasswordMode() const;
47 void SetPasswordMode(bool);
50 void _MoveGapTo(int32 toIndex
);
51 void _EnlargeGapTo(int32 inCount
);
52 void _ShrinkGapTo(int32 inCount
);
54 int32 fItemCount
; // logical count
55 char* fBuffer
; // allocated memory
56 int32 fBufferCount
; // physical count
57 int32 fGapIndex
; // gap position
58 int32 fGapCount
; // gap count
59 char* fScratchBuffer
; // for GetString
60 int32 fScratchSize
; // scratch size
66 TextGapBuffer::Length() const
73 TextGapBuffer::RealCharAt(int32 index
) const
75 if (index
< 0 || index
>= fItemCount
) {
76 if (index
!= fItemCount
)
77 debugger("RealCharAt: invalid index supplied");
81 return index
< fGapIndex
? fBuffer
[index
] : fBuffer
[index
+ fGapCount
];
85 } // namespace BPrivate
88 #endif //__TEXTGAPBUFFER_H