* style cleanup - no functional change
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37984 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
* Stefano Ceccherini ([email protected])
|
* Stefano Ceccherini ([email protected])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -18,13 +19,16 @@
|
|||||||
|
|
||||||
#include "TextGapBuffer.h"
|
#include "TextGapBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
static const int32 kTextGapBufferBlockSize = 2048;
|
static const int32 kTextGapBufferBlockSize = 2048;
|
||||||
|
|
||||||
|
|
||||||
TextGapBuffer::TextGapBuffer()
|
TextGapBuffer::TextGapBuffer()
|
||||||
: fItemCount(0),
|
:
|
||||||
|
fItemCount(0),
|
||||||
fBuffer(NULL),
|
fBuffer(NULL),
|
||||||
fBufferCount(kTextGapBufferBlockSize + fItemCount),
|
fBufferCount(kTextGapBufferBlockSize + fItemCount),
|
||||||
fGapIndex(fItemCount),
|
fGapIndex(fItemCount),
|
||||||
@@ -69,7 +73,8 @@ TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex)
|
TextGapBuffer::InsertText(BFile* file, int32 fileOffset, int32 inNumItems,
|
||||||
|
int32 inAtIndex)
|
||||||
{
|
{
|
||||||
off_t fileSize;
|
off_t fileSize;
|
||||||
|
|
||||||
@@ -203,8 +208,8 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
|||||||
result = fScratchBuffer;
|
result = fScratchBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this could be improved. We are overwriting what we did some lines ago,
|
// TODO: this could be improved. We are overwriting what we did some lines
|
||||||
// we could just avoid to do that.
|
// ago, we could just avoid to do that.
|
||||||
if (fPasswordMode) {
|
if (fPasswordMode) {
|
||||||
uint32 numChars = UTF8CountChars(result, numBytes);
|
uint32 numChars = UTF8CountChars(result, numBytes);
|
||||||
uint32 charLen = UTF8CountBytes(B_UTF8_BULLET, 1);
|
uint32 charLen = UTF8CountBytes(B_UTF8_BULLET, 1);
|
||||||
|
|||||||
@@ -5,48 +5,50 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Marc Flerackers ([email protected])
|
* Marc Flerackers ([email protected])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TEXTGAPBUFFER_H
|
#ifndef __TEXTGAPBUFFER_H
|
||||||
#define __TEXTGAPBUFFER_H
|
#define __TEXTGAPBUFFER_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
|
|
||||||
class BFile;
|
class BFile;
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
class TextGapBuffer {
|
class TextGapBuffer {
|
||||||
public:
|
public:
|
||||||
TextGapBuffer();
|
TextGapBuffer();
|
||||||
virtual ~TextGapBuffer();
|
~TextGapBuffer();
|
||||||
|
|
||||||
void InsertText(const char* inText, int32 inNumItems,
|
void InsertText(const char* inText, int32 inNumItems,
|
||||||
int32 inAtIndex);
|
int32 inAtIndex);
|
||||||
void InsertText(BFile *file, int32 fileOffset, int32 amount,
|
void InsertText(BFile* file, int32 fileOffset,
|
||||||
int32 atIndex);
|
int32 amount, int32 atIndex);
|
||||||
void RemoveRange(int32 start, int32 end);
|
void RemoveRange(int32 start, int32 end);
|
||||||
|
|
||||||
void MoveGapTo(int32 toIndex);
|
void MoveGapTo(int32 toIndex);
|
||||||
void SizeGapTo(int32 inCount);
|
void SizeGapTo(int32 inCount);
|
||||||
|
|
||||||
bool FindChar(char inChar, int32 fromIndex, int32 *ioDelta);
|
bool FindChar(char inChar, int32 fromIndex,
|
||||||
|
int32* ioDelta);
|
||||||
|
|
||||||
const char* Text();
|
const char* Text();
|
||||||
const char* RealText();
|
const char* RealText();
|
||||||
int32 Length() const;
|
int32 Length() const;
|
||||||
|
|
||||||
const char* GetString(int32 fromOffset, int32* numBytes);
|
const char* GetString(int32 fromOffset, int32* numBytes);
|
||||||
void GetString(int32 offset, int32 length, char *buffer);
|
void GetString(int32 offset, int32 length,
|
||||||
|
char* buffer);
|
||||||
|
|
||||||
char RealCharAt(int32 offset) const;
|
char RealCharAt(int32 offset) const;
|
||||||
|
|
||||||
bool PasswordMode() const;
|
bool PasswordMode() const;
|
||||||
void SetPasswordMode(bool);
|
void SetPasswordMode(bool);
|
||||||
|
|
||||||
// void Resize(int32 size);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32 fItemCount; // logical count
|
int32 fItemCount; // logical count
|
||||||
char* fBuffer; // allocated memory
|
char* fBuffer; // allocated memory
|
||||||
@@ -78,6 +80,8 @@ TextGapBuffer::RealCharAt(int32 index) const
|
|||||||
return index < fGapIndex ? fBuffer[index] : fBuffer[index + fGapCount];
|
return index < fGapIndex ? fBuffer[index] : fBuffer[index + fGapCount];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif //__TEXTGAPBUFFER_H
|
#endif //__TEXTGAPBUFFER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user