[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: MovingCursor + Ranges, Features
From:       Michel Ludwig <michel.ludwig () gmail ! com>
Date:       2010-04-21 21:39:21
Message-ID: 201004212239.22540.michel.ludwig () gmail ! com
[Download RAW message or body]

Hi Christoph,

On Wed 21 Apr 2010 19:19:57 Christoph Cullmann wrote:
> We have now a feedback class ;)

Thanks for that :-)

> Any more wishs?

I think it would also be good to add some debugging output functions as it is 
done in the attached patch (copied from range.h/cursor.h). Moreover, some 
range comparisons like the following would be good to have as well 
(eliminating the need to convert moving ranges to simple ranges)

bool 	boundaryAtCursor (const Cursor &cursor) const
bool 	boundaryOnColumn (int column) const
bool 	boundaryOnLine (int line) const
bool 	contains (const Cursor &cursor) const
bool 	contains (const Range &range) const
bool 	containsColumn (int column) const
bool 	containsLine (int line) const
bool 	overlaps (const Range &range) const
bool 	overlapsColumn (int column) const
bool 	overlapsLine (int line) const
int 	positionRelativeToCursor (const Cursor &cursor) const
int 	positionRelativeToLine (int line) const 

Well, at least 'contains', 'containsLine', and 'overlaps' because the spell 
checking stuff needs that ;-)

Michel


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
["output.patch" (text/x-patch)]

diff --git a/ktexteditor/movingcursor.h b/ktexteditor/movingcursor.h
index dbcc865..b639cc1 100644
--- a/ktexteditor/movingcursor.h
+++ b/ktexteditor/movingcursor.h
@@ -182,6 +182,21 @@ class KTEXTEDITOR_EXPORT MovingCursor
      * @return normal cursor
      */
     operator const Cursor () const { return Cursor (line(), column()); }
+
+  //
+  // output
+  //
+  public:
+    /**
+     * kDebug() stream operator.  Writes this cursor to the debug output in a nicely formatted way.
+     */
+    inline friend QDebug operator<< (QDebug s, const MovingCursor& cursor) {
+      if (&cursor)
+        s.nospace() << "(" << cursor.line() << ", " << cursor.column() << ")";
+      else
+        s.nospace() << "(null cursor)";
+      return s.space();
+    }
 };
 
 }
diff --git a/ktexteditor/movingrange.h b/ktexteditor/movingrange.h
index 059e71a..0a33545 100644
--- a/ktexteditor/movingrange.h
+++ b/ktexteditor/movingrange.h
@@ -237,6 +237,21 @@ class KTEXTEDITOR_EXPORT MovingRange
      * @return normal range
      */
     operator const Range () const { return Range (start().toCursor(), end().toCursor()); }
+
+  //
+  // output
+  //
+  public:
+    /**
+     * kDebug() stream operator.  Writes this range to the debug output in a nicely formatted way.
+     */
+    inline friend QDebug operator<< (QDebug s, const MovingRange& range) {
+      if (&range)
+        s << "[" << range.start() << " -> " << range.end() << "]";
+      else
+        s << "(null range)";
+      return s;
+    }
 };
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(MovingRange::InsertBehaviors)


_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic