diff --git a/src/kits/interface/BTextView/LineBuffer.cpp b/src/kits/interface/BTextView/LineBuffer.cpp index 567977e6ca..1142c3ef79 100644 --- a/src/kits/interface/BTextView/LineBuffer.cpp +++ b/src/kits/interface/BTextView/LineBuffer.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Copyright (c) 2001-2003, OpenBeOS +// Copyright (c) 2001-2004, Haiku, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -24,41 +24,34 @@ // Description: Line storage used by BTextView //------------------------------------------------------------------------------ -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include "LineBuffer.h" -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - -//------------------------------------------------------------------------------ _BLineBuffer_::_BLineBuffer_() : _BTextViewSupportBuffer_(20, 2) { } -//------------------------------------------------------------------------------ + + _BLineBuffer_::~_BLineBuffer_() { } -//------------------------------------------------------------------------------ + + void _BLineBuffer_::InsertLine(STELine *inLine, int32 index) { InsertItemsAt(1, index, inLine); } -//------------------------------------------------------------------------------ + + void _BLineBuffer_::RemoveLines(int32 index, int32 count) { RemoveItemsAt(count, index); } -//------------------------------------------------------------------------------ + + void _BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset) { @@ -71,7 +64,8 @@ _BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset) BumpOffset(fromOffset - toOffset, fromLine + 1); } -//------------------------------------------------------------------------------ + + int32 _BLineBuffer_::OffsetToLine(int32 offset) const { @@ -86,14 +80,14 @@ _BLineBuffer_::OffsetToLine(int32 offset) const break; else minIndex = index + 1; - } - else + } else maxIndex = index; } return index; } -//------------------------------------------------------------------------------ + + int32 _BLineBuffer_::PixelToLine(float pixel) const { int32 minIndex = 0; @@ -107,32 +101,25 @@ int32 _BLineBuffer_::PixelToLine(float pixel) const break; else minIndex = index + 1; - } - else + } else maxIndex = index; } return index; } -//------------------------------------------------------------------------------ + + void _BLineBuffer_::BumpOrigin(float delta, long index) { for (long i = index; i < fItemCount; i++) fBuffer[i].origin += delta; } -//------------------------------------------------------------------------------ + + void _BLineBuffer_::BumpOffset(int32 delta, int32 index) { for (long i = index; i < fItemCount; i++) fBuffer[i].offset += delta; } -//------------------------------------------------------------------------------ - -/* - * $Log $ - * - * $Id $ - * - */ diff --git a/src/kits/interface/BTextView/StyleBuffer.h b/src/kits/interface/BTextView/StyleBuffer.h index a41b7b1696..52860e88a1 100644 --- a/src/kits/interface/BTextView/StyleBuffer.h +++ b/src/kits/interface/BTextView/StyleBuffer.h @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Copyright (c) 2001-2003, OpenBeOS +// Copyright (c) 2001-2004, Haiku, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -24,9 +24,6 @@ // Description: Style storage used by BTextView //------------------------------------------------------------------------------ -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include #include #include @@ -39,16 +36,19 @@ typedef struct STEStyle { rgb_color color; // pen color } STEStyle, *STEStylePtr; + typedef struct STEStyleRun { long offset; // byte offset of first character of run STEStyle style; // style info } STEStyleRun, *STEStyleRunPtr; + typedef struct STEStyleRange { long count; // number of style runs STEStyleRun runs[1]; // array of count number of runs } STEStyleRange, *STEStyleRangePtr; + typedef struct STEStyleRecord { long refs; // reference count for this style float ascent; // ascent for this style @@ -56,12 +56,12 @@ typedef struct STEStyleRecord { STEStyle style; // style info } STEStyleRecord, *STEStyleRecordPtr; + typedef struct STEStyleRunDesc { long offset; // byte offset of first character of run long index; // index of corresponding style record } STEStyleRunDesc, *STEStyleRunDescPtr; -// Globals --------------------------------------------------------------------- // _BStyleRunDescBuffer_ class ------------------------------------------------- class _BStyleRunDescBuffer_ : public _BTextViewSupportBuffer_ { @@ -77,13 +77,14 @@ public: const STEStyleRunDescPtr operator[](int32 index) const; }; -//------------------------------------------------------------------------------ -inline const -STEStyleRunDescPtr _BStyleRunDescBuffer_::operator[](int32 index) const + + +inline const STEStyleRunDescPtr +_BStyleRunDescBuffer_::operator[](int32 index) const { return &fBuffer[index]; } -//------------------------------------------------------------------------------ + // _BStyleRecordBuffer_ class -------------------------------------------------- class _BStyleRecordBuffer_ : public _BTextViewSupportBuffer_ { @@ -100,13 +101,14 @@ public: const STEStyleRecordPtr operator[](int32 index) const; }; -//------------------------------------------------------------------------------ -inline const -STEStyleRecordPtr _BStyleRecordBuffer_::operator[](int32 index) const + + +inline const STEStyleRecordPtr +_BStyleRecordBuffer_::operator[](int32 index) const { return &fBuffer[index]; } -//------------------------------------------------------------------------------ + class _BInlineInput_; // _BStyleBuffer_ class -------------------------------------------------------- @@ -162,29 +164,24 @@ protected: bool fValidNullStyle; STEStyle fNullStyle; }; -//------------------------------------------------------------------------------ + + inline int32 _BStyleBuffer_::NumRuns() const { return fStyleRunDesc.ItemCount(); } -//------------------------------------------------------------------------------ -inline const -_BStyleRunDescBuffer_ &_BStyleBuffer_::RunBuffer() const + + +inline const _BStyleRunDescBuffer_& +_BStyleBuffer_::RunBuffer() const { return fStyleRunDesc; } -//------------------------------------------------------------------------------ -inline const -_BStyleRecordBuffer_ &_BStyleBuffer_::RecordBuffer() const + + +inline const _BStyleRecordBuffer_& +_BStyleBuffer_::RecordBuffer() const { return fStyleRecord; } -//------------------------------------------------------------------------------ - -/* - * $Log $ - * - * $Id $ - * - */ diff --git a/src/kits/interface/BTextView/TextGapBuffer.cpp b/src/kits/interface/BTextView/TextGapBuffer.cpp index 2a2ecd0a89..30d1ff89fb 100644 --- a/src/kits/interface/BTextView/TextGapBuffer.cpp +++ b/src/kits/interface/BTextView/TextGapBuffer.cpp @@ -20,27 +20,19 @@ // DEALINGS IN THE SOFTWARE. // // File Name: TextGapBuffer.cpp -// Author: Marc Flerackers (mflerackers@androme.be) +// Authors: Marc Flerackers (mflerackers@androme.be) +// Stefano Ceccherini (burton666@libero.it) // Description: Text storage used by BTextView //------------------------------------------------------------------------------ -// Standard Includes ----------------------------------------------------------- #include #include -// System Includes ------------------------------------------------------------- #include -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- #include "TextGapBuffer.h" -// Local Defines --------------------------------------------------------------- -// Globals --------------------------------------------------------------------- - -//------------------------------------------------------------------------------ _BTextGapBuffer_::_BTextGapBuffer_() : fExtraCount(2048), fItemCount(0), @@ -55,13 +47,15 @@ _BTextGapBuffer_::_BTextGapBuffer_() fBuffer = (char *)malloc(fExtraCount + fItemCount); fScratchBuffer = NULL; } -//------------------------------------------------------------------------------ + + _BTextGapBuffer_::~_BTextGapBuffer_() { free(fBuffer); free(fScratchBuffer); } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex) @@ -84,7 +78,8 @@ _BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, fGapIndex += inNumItems; fItemCount += inNumItems; } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex) { @@ -119,7 +114,8 @@ _BTextGapBuffer_::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, in fItemCount += inNumItems; } } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::RemoveRange(int32 start, int32 end) { @@ -140,7 +136,8 @@ _BTextGapBuffer_::RemoveRange(int32 start, int32 end) if (fGapCount > fExtraCount) SizeGapTo(fExtraCount); } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::MoveGapTo(int32 toIndex) { @@ -157,8 +154,7 @@ _BTextGapBuffer_::MoveGapTo(int32 toIndex) dstIndex = fGapIndex; count = fGapCount + (toIndex - srcIndex); count = (count > trailGapCount) ? trailGapCount : count; - } - else { + } else { srcIndex = toIndex; dstIndex = toIndex + (gapEndIndex - fGapIndex); count = gapEndIndex - dstIndex; @@ -169,7 +165,8 @@ _BTextGapBuffer_::MoveGapTo(int32 toIndex) fGapIndex = toIndex; } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::SizeGapTo(long inCount) { @@ -184,7 +181,8 @@ _BTextGapBuffer_::SizeGapTo(long inCount) fGapCount = inCount; fBufferCount = fItemCount + fGapCount; } -//------------------------------------------------------------------------------ + + const char * _BTextGapBuffer_::GetString(int32 fromOffset, int32 numChars) { @@ -215,7 +213,8 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 numChars) return result; } -//------------------------------------------------------------------------------ + + bool _BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta) { @@ -231,7 +230,8 @@ _BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta) return false; } -//------------------------------------------------------------------------------ + + const char * _BTextGapBuffer_::Text() { @@ -240,12 +240,15 @@ _BTextGapBuffer_::Text() return fBuffer; } -//------------------------------------------------------------------------------ -/*char *_BTextGapBuffer_::RealText() + + +/*char * +_BTextGapBuffer_::RealText() { return fText; }*/ -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer) { @@ -285,27 +288,24 @@ _BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer) buffer[length] = '\0'; } -//------------------------------------------------------------------------------ + + char _BTextGapBuffer_::RealCharAt(int32 offset) const { return (offset < fGapIndex) ? fBuffer[offset] : fBuffer[offset + fGapCount]; } -//------------------------------------------------------------------------------ + + bool _BTextGapBuffer_::PasswordMode() const { return fPasswordMode; } -//------------------------------------------------------------------------------ + + void _BTextGapBuffer_::SetPasswordMode(bool state) { fPasswordMode = state; } -/* - * $Log $ - * - * $Id $ - * - */ diff --git a/src/kits/interface/BTextView/TextGapBuffer.h b/src/kits/interface/BTextView/TextGapBuffer.h index 5eacc4b527..ce1cfb61c0 100644 --- a/src/kits/interface/BTextView/TextGapBuffer.h +++ b/src/kits/interface/BTextView/TextGapBuffer.h @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Copyright (c) 2001-2004, Haiku +// Copyright (c) 2001-2004, Haiku, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -26,18 +26,8 @@ #ifndef __TEXTGAPBUFFER_H #define __TEXTGAPBUFFER_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- class BFile; // _BTextGapBuffer_ class ------------------------------------------------------ @@ -84,13 +74,15 @@ protected: int32 fScratchSize; // scratch size bool fPasswordMode; }; -//------------------------------------------------------------------------------ + + inline int32 _BTextGapBuffer_::Length() const { return fItemCount; } -//------------------------------------------------------------------------------ + + inline char _BTextGapBuffer_::operator[](long index) const { @@ -98,9 +90,3 @@ _BTextGapBuffer_::operator[](long index) const } #endif //__TEXTGAPBUFFER_H -/* - * $Log $ - * - * $Id $ - * - */ diff --git a/src/kits/interface/BTextView/UndoBuffer.h b/src/kits/interface/BTextView/UndoBuffer.h index 3a3f50bfc8..fefda1593e 100644 --- a/src/kits/interface/BTextView/UndoBuffer.h +++ b/src/kits/interface/BTextView/UndoBuffer.h @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Copyright (c) 2003, OpenBeOS +// Copyright (c) 2003-2004, Haiku, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -27,13 +27,12 @@ #ifndef __UNDOBUFFER_H #define __UNDOBUFFER_H -// System Includes ------------------------------------------------------------- #include + class BClipboard; -class _BUndoBuffer_ -{ +class _BUndoBuffer_ { public: _BUndoBuffer_(BTextView *, undo_state); virtual ~_BUndoBuffer_(); @@ -55,32 +54,33 @@ protected: int32 fRunArrayLength; bool fRedo; + private: - undo_state fState; }; // ******** _BCutUndoBuffer_ ******* -class _BCutUndoBuffer_ : public _BUndoBuffer_ -{ +class _BCutUndoBuffer_ : public _BUndoBuffer_ { public: _BCutUndoBuffer_(BTextView *textView); ~_BCutUndoBuffer_(); + protected: virtual void RedoSelf(BClipboard *); }; // ******** _BPasteUndoBuffer_ ******* -class _BPasteUndoBuffer_ : public _BUndoBuffer_ -{ +class _BPasteUndoBuffer_ : public _BUndoBuffer_ { public: _BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32); ~_BPasteUndoBuffer_(); + protected: virtual void UndoSelf(BClipboard *); virtual void RedoSelf(BClipboard *); + private: char *fPasteText; int32 fPasteTextLength; @@ -90,25 +90,26 @@ private: // ******** _BClearUndoBuffer_ ******* -class _BClearUndoBuffer_ : public _BUndoBuffer_ -{ +class _BClearUndoBuffer_ : public _BUndoBuffer_ { public: _BClearUndoBuffer_(BTextView *textView); ~_BClearUndoBuffer_(); + protected: virtual void RedoSelf(BClipboard *); }; // ******** _BDropUndoBuffer_ ******** -class _BDropUndoBuffer_ : public _BUndoBuffer_ -{ +class _BDropUndoBuffer_ : public _BUndoBuffer_ { public: _BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool); ~_BDropUndoBuffer_(); + protected: virtual void UndoSelf(BClipboard *); virtual void RedoSelf(BClipboard *); + private: char *fDropText; int32 fDropTextLength; @@ -121,18 +122,19 @@ private: // ******** _BTypingUndoBuffer_ ******** -class _BTypingUndoBuffer_ : public _BUndoBuffer_ -{ +class _BTypingUndoBuffer_ : public _BUndoBuffer_ { public: _BTypingUndoBuffer_(BTextView *); ~_BTypingUndoBuffer_(); void InputCharacter(int32); void BackwardErase(); - void ForwardErase(); + void ForwardErase(); + protected: virtual void RedoSelf(BClipboard *); virtual void UndoSelf(BClipboard *); + private: void Reset();