--Boundary-00=_/9n+H2joFx6R3aa Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Tue 01 Apr 2008, Hamish Rodda wrote:> > True, and same problem for non-fixed size fonts. That's why block > selection is also very hard. So, ok then. Attached is a patch which incorporates the latest changes. Michel --Boundary-00=_/9n+H2joFx6R3aa Content-Type: text/x-diff; charset="utf-8"; name="viewportinterface.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="viewportinterface.patch" Index: interfaces/ktexteditor/viewportinterface.cpp =================================================================== --- interfaces/ktexteditor/viewportinterface.cpp (revision 0) +++ interfaces/ktexteditor/viewportinterface.cpp (revision 0) @@ -0,0 +1,45 @@ +/* This file is part of the KDE libraries + Copyright (C) 2008 Michel Ludwig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "viewportinterface.h" + +#include "range.h" + +using namespace KTextEditor; + +ViewportInterface::ViewportInterface() + : d(0) +{ +} + +ViewportInterface::~ViewportInterface() +{ +} + +QList ViewportInterface::displayLineRanges() const +{ + QList toReturn; + int numLines = displayLines(); + + for(int i = 0; i < numLines; ++i) + { + toReturn.append(displayLineRange(i)); + } + + return toReturn; +} Index: interfaces/ktexteditor/CMakeLists.txt =================================================================== --- interfaces/ktexteditor/CMakeLists.txt (revision 794532) +++ interfaces/ktexteditor/CMakeLists.txt (working copy) @@ -17,6 +17,7 @@ codecompletionmodel.cpp configinterface.cpp smartinterface.cpp + viewportinterface.cpp ) @@ -59,6 +60,7 @@ codecompletionmodel.h configinterface.h containerinterface.h + viewportinterface.h DESTINATION ${INCLUDE_INSTALL_DIR}/ktexteditor COMPONENT Devel) install( FILES ktexteditor.desktop ktexteditorplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) Index: interfaces/ktexteditor/viewportinterface.h =================================================================== --- interfaces/ktexteditor/viewportinterface.h (revision 0) +++ interfaces/ktexteditor/viewportinterface.h (revision 0) @@ -0,0 +1,142 @@ +/* This file is part of the KDE libraries + Copyright (C) 2008 Michel Ludwig + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KDELIBS_KTEXTEDITOR_VIEWPORTINTERFACE_H +#define KDELIBS_KTEXTEDITOR_VIEWPORTINTERFACE_H + +#include + +class KConfigGroup; + +#include +#include + +namespace KTextEditor +{ + +class Range; +class View; + +/** + * \brief Viewport interface extension for the View. + * + * \ingroup kte_group_view_extensions + * + * \section viewport_intro Introduction + * + * The ViewportInterface is an extension for Views which allows for notifications when the + * currently displayed document range changes. + * + * \section viewport_support Adding Viewport Support + * + * To add Viewport support a KTextEditor implementation has to derive the + * View class from ViewportInterface and reimplement the purely virtual methods defined + * in this interface. + * + * \section viewport_access Accessing the ViewportInterface + * + * The ViewportInterface is supposed to be an extension interface for a View, i.e. the + * View inherits the interface \e provided that it implements the interface. Use qobject_cast to + * access the implementation: + * \code + * // object is of type KTextEditor::View* + * KTextEditor::ViewportInterface *iface = + * qobject_cast( object ); + * + * if( iface ) { + * // interface is supported + * // do stuff + * } + * \endcode + * + * \since 4.1 + * \see KTextEditor::View + * \author Michel Ludwig \ + */ +class KTEXTEDITOR_EXPORT ViewportInterface +{ + public: + /** + * Constructor. + */ + ViewportInterface(); + + /** + * Virtual destructor. + */ + virtual ~ViewportInterface(); + + public: + // + // signals!! + // + /** + * This signal is emitted whenever the displayed document range in \p view + * changes. + * + * \param view View whose displayed document range has changed + * \warning This 'method' needs to be implemented as a signal! + * \since 4.1 + */ + virtual void displayRangeChanged(KTextEditor::View *view) = 0; + + public: + /** + * Get the ranges of the document which are currently displayed in the View. + * The default implementation uses the displayLineRange(int line) function to + * retrieve the document range for a given line. + * Please note that the values for the columns returned are also of particular + * importance due to the dynamic word wrap feature, for example. + * + * \return Range of the document which is currently displayed + * \since 4.1 + */ + virtual QList displayLineRanges() const; + + /** + * Get the number of lines that are currently displayed in the View. + * \return Number of lines that are currently displayed + * \since 4.1 + */ + virtual int displayLines() const = 0; + + /** + * Get the range of the document which is currently displayed at the given + * line in the View. + * Please note that the values for the columns returned are also of particular + * importance due to the dynamic word wrap feature, for example. + * + * \param line Line for which the displayed document range should be determined + * \return Range of the document which is currently displayed at the given line; + * an invalid Range is returned when the given \p line parameter does not + * specify a valid line + * \since 4.1 + */ + virtual KTextEditor::Range displayLineRange(int line) const = 0; + + private: + class ViewportInterfacePrivate* const d; +}; + +} + +Q_DECLARE_INTERFACE(KTextEditor::ViewportInterface, "org.kde.KTextEditor.ViewportInterface") + +#endif + +// kate: space-indent on; indent-width 2; replace-tabs on; Index: includes/KTextEditor/ViewportInterface =================================================================== --- includes/KTextEditor/ViewportInterface (revision 0) +++ includes/KTextEditor/ViewportInterface (revision 0) @@ -0,0 +1 @@ +#include "../../ktexteditor/viewportinterface.h" Index: includes/CMakeLists.txt =================================================================== --- includes/CMakeLists.txt (revision 794532) +++ includes/CMakeLists.txt (working copy) @@ -810,6 +810,7 @@ KTextEditor/TemplateInterface KTextEditor/TextHintInterface KTextEditor/VariableInterface + KTextEditor/ViewportInterface KTextEditor/View DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/KTextEditor ) --Boundary-00=_/9n+H2joFx6R3aa Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KTextEditor-Devel mailing list KTextEditor-Devel@kde.org https://mail.kde.org/mailman/listinfo/ktexteditor-devel --Boundary-00=_/9n+H2joFx6R3aa--