• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KTextEditor

  • KTextEditor
  • MovingRange
Public Types | Public Member Functions | Protected Member Functions | Friends

KTextEditor::MovingRange Class Reference
MovingCursors and MovingRanges

A range which is bound to a specific Document, and maintains its position. More...

#include <movingrange.h>

List of all members.

Public Types

enum  EmptyBehavior { AllowEmpty = 0x0, InvalidateIfEmpty = 0x1 }
enum  InsertBehavior { DoNotExpand = 0x0, ExpandLeft = 0x1, ExpandRight = 0x2 }

Public Member Functions

virtual ~MovingRange ()
virtual Attribute::Ptr attribute () const =0
virtual bool attributeOnlyForViews () const =0
virtual Document * document () const =0
virtual EmptyBehavior emptyBehavior () const =0
virtual const MovingCursor & end () const =0
virtual MovingRangeFeedback * feedback () const =0
virtual InsertBehaviors insertBehaviors () const =0
bool isEmpty () const
 operator const Range () const
virtual void setAttribute (Attribute::Ptr attribute)=0
virtual void setAttributeOnlyForViews (bool onlyForViews)=0
virtual void setEmptyBehavior (EmptyBehavior emptyBehavior)=0
virtual void setFeedback (MovingRangeFeedback *feedback)=0
virtual void setInsertBehaviors (InsertBehaviors insertBehaviors)=0
void setRange (const Cursor &start, const Cursor &end)
virtual void setRange (const KTextEditor::Range &range)=0
virtual void setView (View *view)=0
virtual void setZDepth (qreal zDepth)=0
virtual const MovingCursor & start () const =0
const Range toRange () const
virtual View * view () const =0
virtual qreal zDepth () const =0
Comparison

The following functions perform checks against this range in comparison to other lines, columns, cursors, and ranges.

bool contains (const Range &range) const
bool contains (const Cursor &cursor) const
bool containsLine (int line) const
bool containsColumn (int column) const
bool overlaps (const Range &range) const
bool overlapsLine (int line) const
bool overlapsColumn (int column) const
bool onSingleLine () const

Protected Member Functions

 MovingRange ()

Friends

QDebug operator<< (QDebug s, const MovingRange *range)
QDebug operator<< (QDebug s, const MovingRange &range)

Detailed Description

A range which is bound to a specific Document, and maintains its position.

A MovingRange is an extension of the basic Range class. It maintains its position in the document. As a result of this, MovingRanges may not be copied, as they need to maintain a connection to the associated Document.

Create a new MovingRange like this:

 // Retrieve the MovingInterface
 KTextEditor::MovingInterface* moving =
     qobject_cast<KTextEditor::MovingInterface*>( yourDocument );

 if ( moving ) {
     KTextEditor::MovingRange* range = moving->newMovingRange();
 }

When finished with a MovingRange, simply delete it. If the document the cursor belong to is deleted, it will get deleted automatically.

See also:
Cursor, MovingCursor, Range and MovingInterface.
Author:
Christoph Cullmann <cullmann@kde.org>
Since:
4.5

Definition at line 68 of file movingrange.h.


Member Enumeration Documentation

enum KTextEditor::MovingRange::EmptyBehavior

Behavior of range if it becomes empty.

Enumerator:
AllowEmpty 

allow range to be empty

InvalidateIfEmpty 

invalidate range, if it becomes empty

Definition at line 88 of file movingrange.h.

enum KTextEditor::MovingRange::InsertBehavior

Determine how the range reacts to characters inserted immediately outside the range.

Enumerator:
DoNotExpand 

Don't expand to encapsulate new characters in either direction. This is the default.

ExpandLeft 

Expand to encapsulate new characters to the left of the range.

ExpandRight 

Expand to encapsulate new characters to the right of the range.

Definition at line 75 of file movingrange.h.


Constructor & Destructor Documentation

MovingRange::~MovingRange ( ) [virtual]

Destruct the moving range.

Definition at line 32 of file movingrange.cpp.

MovingRange::MovingRange ( ) [protected]

For inherited class only.

Definition at line 28 of file movingrange.cpp.


Member Function Documentation

virtual Attribute::Ptr KTextEditor::MovingRange::attribute ( ) const [pure virtual]

Gets the active Attribute for this range.

Returns:
a pointer to the active attribute
virtual bool KTextEditor::MovingRange::attributeOnlyForViews ( ) const [pure virtual]

Is this range's attribute only visible in views, not for example prints? Default is false.

Returns:
range visible only for views
bool KTextEditor::MovingRange::contains ( const Range &  range) const [inline]

Check whether the this range wholly encompasses range.

Parameters:
rangerange to check
Returns:
true, if this range contains range, otherwise false

Definition at line 335 of file movingrange.h.

bool KTextEditor::MovingRange::contains ( const Cursor &  cursor) const [inline]

Check to see if cursor is contained within this range, ie >= start() and < end().

Parameters:
cursorthe position to test for containment
Returns:
true if the cursor is contained within this range, otherwise false.

Definition at line 346 of file movingrange.h.

bool KTextEditor::MovingRange::containsColumn ( int  column) const [inline]

Check whether the range contains column.

Parameters:
columncolumn to check
Returns:
true if the range contains column, otherwise false

Definition at line 368 of file movingrange.h.

bool KTextEditor::MovingRange::containsLine ( int  line) const [inline]

Returns true if this range wholly encompasses line.

Parameters:
lineline to check
Returns:
true if the line is wholly encompassed by this range, otherwise false.

Definition at line 357 of file movingrange.h.

virtual Document* KTextEditor::MovingRange::document ( ) const [pure virtual]

Gets the document to which this range is bound.

Returns:
a pointer to the document
virtual EmptyBehavior KTextEditor::MovingRange::emptyBehavior ( ) const [pure virtual]

Will this range invalidate itself if it becomes empty?

Returns:
behavior on becoming empty
virtual const MovingCursor& KTextEditor::MovingRange::end ( ) const [pure virtual]

Retrieve end cursor of this range, read-only.

Returns:
end cursor
virtual MovingRangeFeedback* KTextEditor::MovingRange::feedback ( ) const [pure virtual]

Gets the active MovingRangeFeedback for this range.

Returns:
a pointer to the active MovingRangeFeedback
virtual InsertBehaviors KTextEditor::MovingRange::insertBehaviors ( ) const [pure virtual]

Get current insert behaviors.

Returns:
current insert behaviors
bool KTextEditor::MovingRange::isEmpty ( ) const [inline]

Returns true if this range contains no characters, ie.

the start() and end() positions are the same.

Returns:
true if the range contains no characters, otherwise false

Definition at line 317 of file movingrange.h.

bool KTextEditor::MovingRange::onSingleLine ( ) const [inline]

Check whether the start() and end() cursors of this range are on the same line.

Returns:
true if both the start and end positions are on the same line, otherwise false

Definition at line 413 of file movingrange.h.

KTextEditor::MovingRange::operator const Range ( ) const [inline]

Convert this clever range into a dumb one.

Equal to toRange, allowing to use implicit conversion.

Returns:
normal range

Definition at line 285 of file movingrange.h.

bool MovingRange::overlaps ( const Range &  range) const

Check whether the this range overlaps with range.

Parameters:
rangerange to check against
Returns:
true, if this range overlaps with range, otherwise false

Definition at line 42 of file movingrange.cpp.

bool KTextEditor::MovingRange::overlapsColumn ( int  column) const [inline]

Check to see if this range overlaps column; that is, if column is between start().column() and end().column().

This function is most likely to be useful in relation to block text editing.

Parameters:
columnthe column to test
Returns:
true if the column is between the range's starting and ending columns, otherwise false.

Definition at line 402 of file movingrange.h.

bool KTextEditor::MovingRange::overlapsLine ( int  line) const [inline]

Check whether the range overlaps at least part of line.

Parameters:
lineline to check
Returns:
true, if the range overlaps at least part of line, otherwise false

Definition at line 388 of file movingrange.h.

virtual void KTextEditor::MovingRange::setAttribute ( Attribute::Ptr  attribute) [pure virtual]

Sets the currently active attribute for this range.

This will trigger update of the relevant view parts, if the attribute changed.

Parameters:
attributeAttribute to assign to this range. If null, simply removes the previous Attribute.
virtual void KTextEditor::MovingRange::setAttributeOnlyForViews ( bool  onlyForViews) [pure virtual]

Set if this range's attribute is only visible in views, not for example prints.

Parameters:
onlyForViewsattribute only valid for views
virtual void KTextEditor::MovingRange::setEmptyBehavior ( EmptyBehavior  emptyBehavior) [pure virtual]

Set if this range will invalidate itself if it becomes empty.

Parameters:
emptyBehaviorbehavior on becoming empty
virtual void KTextEditor::MovingRange::setFeedback ( MovingRangeFeedback *  feedback) [pure virtual]

Sets the currently active MovingRangeFeedback for this range.

This will trigger evaluation if feedback must be send again (for example if mouse is already inside range).

Parameters:
attributeMovingRangeFeedback to assign to this range. If null, simply removes the previous MovingRangeFeedback.
virtual void KTextEditor::MovingRange::setInsertBehaviors ( InsertBehaviors  insertBehaviors) [pure virtual]

Set insert behaviors.

Parameters:
insertBehaviorsnew insert behaviors
void MovingRange::setRange ( const Cursor &  start,
const Cursor &  end 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Set the range of this range A TextRange is not allowed to be empty, as soon as start == end position, it will become automatically invalid!

Parameters:
startnew start for this clever range
endnew end for this clever range

Definition at line 36 of file movingrange.cpp.

virtual void KTextEditor::MovingRange::setRange ( const KTextEditor::Range &  range) [pure virtual]

Set the range of this range.

A TextRange is not allowed to be empty, as soon as start == end position, it will become automatically invalid!

Parameters:
rangenew range for this clever range
virtual void KTextEditor::MovingRange::setView ( View *  view) [pure virtual]

Sets the currently active view for this range.

This will trigger update of the relevant view parts, if the view changed. Set view before the attribute, that will avoid not needed redraws.

Parameters:
attributeView to assign to this range. If null, simply removes the previous view.
virtual void KTextEditor::MovingRange::setZDepth ( qreal  zDepth) [pure virtual]

Set the current Z-depth of this range.

Ranges with smaller Z-depth than others will win during rendering. This will trigger update of the relevant view parts, if the depth changed. Set depth before the attribute, that will avoid not needed redraws. Default is 0.0.

Parameters:
zDepthnew Z-depth of this range
virtual const MovingCursor& KTextEditor::MovingRange::start ( ) const [pure virtual]

Retrieve start cursor of this range, read-only.

Returns:
start cursor
const Range KTextEditor::MovingRange::toRange ( ) const [inline]

Convert this clever range into a dumb one.

Returns:
normal range

Definition at line 279 of file movingrange.h.

virtual View* KTextEditor::MovingRange::view ( ) const [pure virtual]

Gets the active view for this range.

Might be already invalid, internally only used for pointer comparisons.

Returns:
a pointer to the active view
virtual qreal KTextEditor::MovingRange::zDepth ( ) const [pure virtual]

Gets the current Z-depth of this range.

Ranges with smaller Z-depth than others will win during rendering. Default is 0.0.

Defined depths for common kind of ranges use in editor components implenting this interface, smaller depths are more more in the foreground and will win during rendering:

  • Selection == -100000.0
  • Search == -10000.0
  • Bracket Highlighting == -1000.0
  • Folding Hover == -100.0
Returns:
current Z-depth of this range

Friends And Related Function Documentation

QDebug operator<< ( QDebug  s,
const MovingRange *  range 
) [friend]

kDebug() stream operator.

Writes this range to the debug output in a nicely formatted way.

Parameters:
sdebug stream
cursorrange to print
Returns:
debug stream

Definition at line 293 of file movingrange.h.

QDebug operator<< ( QDebug  s,
const MovingRange &  range 
) [friend]

kDebug() stream operator.

Writes this range to the debug output in a nicely formatted way.

Parameters:
sdebug stream
rangerange to print
Returns:
debug stream

Definition at line 307 of file movingrange.h.


The documentation for this class was generated from the following files:
  • movingrange.h
  • movingrange.cpp

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal