History log of /haiku/src/kits/interface/textview_support/TextGapBuffer.cpp
Revision Date Author Comments
# 3c857341 31-Dec-2015 Augustin Cavalier <waddlesplash@gmail.com>

BTextView: Don't crash if the file supplied is zero-length.

Fixes #12551.


# 63effa09 26-Apr-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fix typo (missing pointer dereference).
Found by PVS-Studio developer Svyatoslav Razmyslov.
Also update my email address.


# 0bbed962 19-Sep-2014 Stefano Ceccherini <stefano.ceccherini@gmail.com>

TextGapBuffer: Style changes
Change long to int32
Removed useless parenthesis


# 0eb9b74e 19-Sep-2014 Stefano Ceccherini <stefano.ceccherini@gmail.com>

BTextView: Fixed GetText().
Patch by Pete Goodeve which fixes a problem in TextGapBuffer::GetString()
used by BTextView::GetText(). Thanks! Fixes #8447.


# 9be774b5 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Compilation and 64-bit fixes to libbe.so sources.

Fixed the usual issues - printf format strings, uint32 instead of
addr_t, etc. One thing that isn't so nice is several places where
BList is used to store (u)int32, these require a double cast to addr_t
then void* to silence a warning on x86_64.


# a4bcdeaa 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

Fix another glitch reported in #6435
* when shrinking the gap, avoid that deleting the next character will shrink
the gap again


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37989 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7e31a05c 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

Close #6435:
* fix problem in TextGapBuffer which could lead to data loss at end of buffer
when deleting large chunks of text


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37987 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3423856 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

* style cleanup - no functional change

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37984 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c4c164a 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Make the result a proper const char *.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2272ecea 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

zooey+mmlr:
* Ensure that there is still buffer left when 0-terminating the buffer in
RealText().
* Remove the fExtraCount member and instead make it into a constant as that's
how it's used and more obvious.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36306 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c4e7641 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

zooey+mmlr:
* Large cleanup in _FindLineBreak(), be a bit more clever by storing the found
offsets instead of calculating them multiple times, use
_TabExpandedStyledWidth() instead of _StyledWidth() and manual tab calculation
which was also broken (it assumed tabs were consequtive which was possibly not
the case).
* Modified CanEndLine() to also return true when going from non-whitespace to
whitespace and the other way around which is more logical (so we'd break after
the word and not after word + whitespace, even though we actually do that
in the end by eating whitespace after words in _FindLineBreak()).
* The TextGapBuffer is not necessarily 0 terminated, so RealCharAt() needs to
check if the index is at the end of the string and return 0 in that case.
Before it would access the buffer "out by one" which could've lead to a crash.
* Simplified the gap moving calculations by removing some no-op calculations.
* Added debugger calls in TextGapBuffer in case of invalid use.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36304 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec7d1680 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Automatic whitespace cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36301 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eb09230 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Resolve further warnings on GCC4.
* Enable -Werror on GCC4 builds as well (limited to the same selected targets).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 90b7764d 21-Sep-2008 Rene Gollent <anevilyak@gmail.com>

Move WidthBuffer and TextGapBuffer into BPrivate and use them from there in BPoseView and BTextView. This (correctly) fixes the previous gcc4 build issues.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a682d981 20-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

Quite a cleanup action to avoid polluting the global namespace with private
BTextView classes:

* Declared the directly used BTextView helper classes as private BTextView
classes and changed all affected files.
* Realized that Tracker's BPoseView was (accidentally?) using what used to
be _BWidthBuffer_. It had declared it's own class with the same name and
same members/size in headers/private/tracker/TextViewSupport.h, but the
implementation was nowhere to be found. I can only explain this that
the BTextView implementation was then actually linked and used. But the big
problem was that it was used without locking (unlike in BTextView)! When
many Tracker windows opened during system startup or later and they happened
to each request characters not yet in the cache, I imagine things could have
gone bad and corrupted memory. Anyways, since I can see the usefulness of
the cache, BPoseView uses BTextView::WidthBuffer on purpose now. And I moved
the locking inside BTextView::WidthBuffer::StringWidth().
* Adjusted InterfaceDefs.cpp accordingly.
* TODO: Move subsequent classes into BTextView namespace as well, ie derived
classes that BTextView doesn't directly know about. All stuff in src/kits/
inteface/textview_support/
* Added preliminary and not yet implemented layout friendly BTextView
constructors.
* I will try to handle the insets imposed by BTextView::fTextRect a bit
differently when used inside the new layout management framework. For this,
I added BTextView::SetInsets() and GetInsets(). SetInsets() doesn't do
anything yet.

So far, everything seems to work still... ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27654 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35671cdc 23-Feb-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

avoid double function call.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23b6ac7e 01-Nov-2007 Stephan Aßmus <superstippi@gmx.de>

this should complete the work on password mode for BTextView:
* fixed +/- 1 bug in _BTextGapBuffer_::GetString()
* used the correct text and offsets in BTextView whenever the visible
text is to be used
* when copying to the clipboard, copy the bullets
* when dragging the text, drag the bullets
TODO:
* test more with UTF8 chars in the original text (I am unsure if fSelStart
and so on is really in bytes rather than glyphs)
* test with multiple font styles



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e94ad1e2 31-Aug-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

If typing is hidden, don't reply to B_COPY or B_CUT messages, but beep()
in this case. Note that the public methods still let you copy and cut
the real text. Also prevented stealing passwords via scripting (not
tested, though). Fixes bug #1354
Got rid of the _BTextGapBuffer_::[] operator since using it creates less readable code.
Also Implemented _BTextGapBuffer_::RealText() and used it instead of Text() inside BTextView. Will make sense later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22129 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de20f0fa 01-Oct-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

some changes, fixed a rendering bug

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18987 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 25ba188a 27-Sep-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

added a parameter to _BTextGapBuffer_::GetString() so that the caller knows how many bytes are really returned. password mode looks better now

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 575a68b3 14-Sep-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented BTextView::HideTyping(). Now it will display B_UTF8_BULLET
chars instead of the real text if this option is enabled. Note that
there are problems with the text width, i.e. the calculation is still
done with the "real" chars, leading to text corruption.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b31b14e0 28-Aug-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Renamed BTextView folder to textview_support


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18663 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 63effa099cceeb049e562c3cbd9128fd1e2fc264 26-Apr-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fix typo (missing pointer dereference).
Found by PVS-Studio developer Svyatoslav Razmyslov.
Also update my email address.


# 0bbed9620a12f90abc29b0c454f8d15574bb4f71 19-Sep-2014 Stefano Ceccherini <stefano.ceccherini@gmail.com>

TextGapBuffer: Style changes
Change long to int32
Removed useless parenthesis


# 0eb9b74e00b7656d4ba8f6b2735a486b483bf08b 19-Sep-2014 Stefano Ceccherini <stefano.ceccherini@gmail.com>

BTextView: Fixed GetText().
Patch by Pete Goodeve which fixes a problem in TextGapBuffer::GetString()
used by BTextView::GetText(). Thanks! Fixes #8447.


# 9be774b553296a712704078314f2291ae5fc352c 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Compilation and 64-bit fixes to libbe.so sources.

Fixed the usual issues - printf format strings, uint32 instead of
addr_t, etc. One thing that isn't so nice is several places where
BList is used to store (u)int32, these require a double cast to addr_t
then void* to silence a warning on x86_64.


# a4bcdeaaf1c5d8cbbbbdb2f4a87bd6bed14b796c 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

Fix another glitch reported in #6435
* when shrinking the gap, avoid that deleting the next character will shrink
the gap again


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37989 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7e31a05ca501754c1be178dd167bd4f37170d0ae 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

Close #6435:
* fix problem in TextGapBuffer which could lead to data loss at end of buffer
when deleting large chunks of text


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37987 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c34238562be48b7c02339898eb34bce45a10eb17 09-Aug-2010 Oliver Tappe <zooey@hirschkaefer.de>

* style cleanup - no functional change

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37984 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c4c164a91b97c389f01d92650c11b809a8ec890 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Make the result a proper const char *.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2272ecea2647f43104a26bdc03bdd0ae48515d84 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

zooey+mmlr:
* Ensure that there is still buffer left when 0-terminating the buffer in
RealText().
* Remove the fExtraCount member and instead make it into a constant as that's
how it's used and more obvious.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36306 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c4e7641a732891a776f88c3c46b237de9220f88 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

zooey+mmlr:
* Large cleanup in _FindLineBreak(), be a bit more clever by storing the found
offsets instead of calculating them multiple times, use
_TabExpandedStyledWidth() instead of _StyledWidth() and manual tab calculation
which was also broken (it assumed tabs were consequtive which was possibly not
the case).
* Modified CanEndLine() to also return true when going from non-whitespace to
whitespace and the other way around which is more logical (so we'd break after
the word and not after word + whitespace, even though we actually do that
in the end by eating whitespace after words in _FindLineBreak()).
* The TextGapBuffer is not necessarily 0 terminated, so RealCharAt() needs to
check if the index is at the end of the string and return 0 in that case.
Before it would access the buffer "out by one" which could've lead to a crash.
* Simplified the gap moving calculations by removing some no-op calculations.
* Added debugger calls in TextGapBuffer in case of invalid use.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36304 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec7d16808176099e6cdac7c0780e2d0946ba0236 15-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Automatic whitespace cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36301 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eb09230bae52bcdf045e1f1920b67205c29adc8 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Resolve further warnings on GCC4.
* Enable -Werror on GCC4 builds as well (limited to the same selected targets).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 90b7764dc354ff1bcb01abf78dafe16faa820725 21-Sep-2008 Rene Gollent <anevilyak@gmail.com>

Move WidthBuffer and TextGapBuffer into BPrivate and use them from there in BPoseView and BTextView. This (correctly) fixes the previous gcc4 build issues.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a682d9819fae1e26cef1390bb33b5d5c73304642 20-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

Quite a cleanup action to avoid polluting the global namespace with private
BTextView classes:

* Declared the directly used BTextView helper classes as private BTextView
classes and changed all affected files.
* Realized that Tracker's BPoseView was (accidentally?) using what used to
be _BWidthBuffer_. It had declared it's own class with the same name and
same members/size in headers/private/tracker/TextViewSupport.h, but the
implementation was nowhere to be found. I can only explain this that
the BTextView implementation was then actually linked and used. But the big
problem was that it was used without locking (unlike in BTextView)! When
many Tracker windows opened during system startup or later and they happened
to each request characters not yet in the cache, I imagine things could have
gone bad and corrupted memory. Anyways, since I can see the usefulness of
the cache, BPoseView uses BTextView::WidthBuffer on purpose now. And I moved
the locking inside BTextView::WidthBuffer::StringWidth().
* Adjusted InterfaceDefs.cpp accordingly.
* TODO: Move subsequent classes into BTextView namespace as well, ie derived
classes that BTextView doesn't directly know about. All stuff in src/kits/
inteface/textview_support/
* Added preliminary and not yet implemented layout friendly BTextView
constructors.
* I will try to handle the insets imposed by BTextView::fTextRect a bit
differently when used inside the new layout management framework. For this,
I added BTextView::SetInsets() and GetInsets(). SetInsets() doesn't do
anything yet.

So far, everything seems to work still... ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27654 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35671cdcc5affc4b944de12f52681171e9434ee0 23-Feb-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

avoid double function call.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23b6ac7e15e7144d28d15007a29361bc41ec4537 01-Nov-2007 Stephan Aßmus <superstippi@gmx.de>

this should complete the work on password mode for BTextView:
* fixed +/- 1 bug in _BTextGapBuffer_::GetString()
* used the correct text and offsets in BTextView whenever the visible
text is to be used
* when copying to the clipboard, copy the bullets
* when dragging the text, drag the bullets
TODO:
* test more with UTF8 chars in the original text (I am unsure if fSelStart
and so on is really in bytes rather than glyphs)
* test with multiple font styles



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e94ad1e24d1fafa275a99a7edad869d2a1a825d4 31-Aug-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

If typing is hidden, don't reply to B_COPY or B_CUT messages, but beep()
in this case. Note that the public methods still let you copy and cut
the real text. Also prevented stealing passwords via scripting (not
tested, though). Fixes bug #1354
Got rid of the _BTextGapBuffer_::[] operator since using it creates less readable code.
Also Implemented _BTextGapBuffer_::RealText() and used it instead of Text() inside BTextView. Will make sense later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22129 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de20f0facaa2afcc46cde051e683bd65af8e3f84 01-Oct-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

some changes, fixed a rendering bug

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18987 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 25ba188a07355107b2da915d49d8c21308511cb6 27-Sep-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

added a parameter to _BTextGapBuffer_::GetString() so that the caller knows how many bytes are really returned. password mode looks better now

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 575a68b31798043cc91b0f5d648514525dabaf99 14-Sep-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Implemented BTextView::HideTyping(). Now it will display B_UTF8_BULLET
chars instead of the real text if this option is enabled. Note that
there are problems with the text width, i.e. the calculation is still
done with the "real" chars, leading to text corruption.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b31b14e033ffc2c4850235821c9390a151abd2c9 28-Aug-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Renamed BTextView folder to textview_support


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18663 a95241bf-73f2-0310-859d-f6bbb57e9c96