vfs: check userland buffers before reading them.
[haiku.git] / src / kits / interface / textview_support / LineBuffer.h
blob81e124eb78bdc2970255f48a49e560b8d0becd24
1 /*
2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Marc Flerackers (mflerackers@androme.be)
7 */
8 #ifndef __LINE_BUFFER_H
9 #define __LINE_BUFFER_H
12 #include <SupportDefs.h>
13 #include <TextView.h>
15 #include "TextViewSupportBuffer.h"
17 struct STELine {
18 long offset; // offset of first character of line
19 float origin; // pixel position of top of line
20 float ascent; // maximum ascent for line
21 float width; // cached width of line in pixels
25 class BTextView::LineBuffer : public _BTextViewSupportBuffer_<STELine> {
27 public:
28 LineBuffer();
29 virtual ~LineBuffer();
31 void InsertLine(STELine* inLine, int32 index);
32 void RemoveLines(int32 index, int32 count = 1);
33 void RemoveLineRange(int32 fromOffset,
34 int32 toOffset);
36 int32 OffsetToLine(int32 offset) const;
37 int32 PixelToLine(float pixel) const;
39 void BumpOrigin(float delta, int32 index);
40 void BumpOffset(int32 delta, int32 index);
42 int32 NumLines() const;
43 float MaxWidth() const;
44 STELine* operator[](int32 index) const;
48 inline int32
49 BTextView::LineBuffer::NumLines() const
51 return fItemCount - 1;
55 inline STELine *
56 BTextView::LineBuffer::operator[](int32 index) const
58 return &fBuffer[index];
62 #endif // __LINE_BUFFER_H