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

List:       ktexteditor-devel
Subject:    Proposed new mark interface
From:       Hamish Rodda <rodda () kde ! org>
Date:       2008-04-17 13:06:21
Message-ID: 200804172306.23598.rodda () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

At the kdevelop meeting we discussed some problems that we are having with the 
current mark interface, specifically:

* it is not possible to easily track a mark (as the line may move), one has to 
keep a copy of the structure and update it every time it changes

* the current interface allows the user to insert the marks that are allowed 
at any position, but we want to limit the valid positions and first determine 
that they are valid (eg. whether a breakpoint can be set or not)

I have attached a proposal for a new mark interface.  Highlights:
* mark types are changed from masks to regular integers (masks no longer 
needed)

* smart cursors now used to represent a mark 
  * you can now insert a mark at any point in a line, and it will behave 
properly if you press enter before the mark point
  * you can get notification of moves via the smart cursor feedback mechanisms

* custom mark types can now be created in a way which is friendly to multiple 
plugins using the interface

* mark types can be set to manual mode
  * in manual mode, only requestAddMark / requestRemoveMark are emitted when a 
user tries to insert a mark
  * it is then up to the client app to handle this (as documented)

Feedback sought :)  (No implementation exists yet)

Also, supporting the old interface is possible but it would be much nicer 
code-wise to stop supporting it of course, I presume we want to maintain 
backwards compatibility?

Cheers,
Hamish.

["markinterface2.h" (text/x-c++hdr)]

/* This file is part of the KDE project
   Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org)
   Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation)
   Copyright (C) 2008 Hamish Rodda (rodda@kde.org)

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   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_MARKINTERFACE2_H
#define KDELIBS_KTEXTEDITOR_MARKINTERFACE2_H

#include <ktexteditor/ktexteditor_export.h>

#include <QtCore/QHash>
#include <QtCore/QObject>

class QPixmap;

namespace KTextEditor
{

class Document;

class KTEXTEDITOR_EXPORT MarkInterface2
{
  public:
    MarkInterface2 ();

    /**
     * Virtual destructor.
     */
    virtual ~MarkInterface2 ();

    virtual QList<SmartCursor*> marks() const = 0;
    virtual QList<SmartCursor*> marksForLine(int line) const = 0;

    enum MarkTypes
    {
      Bookmark,
      BreakpointActive,
      BreakpointReached,
      BreakpointDisabled,
      Execution,
      Warning,
      Error,
      FirstCustomType = 1000
    };

    /**
     * Create a new custom mark type
     */
    int createNewMarkType(const QString& description = QString(), const QPixmap& pixmap = QPixmap());
    void deleteMarkType(int type);

    virtual void setMarkTypeEditable( int type ) = 0;


    /**
     * Tell the editor that the marks of the given \a type will be manually
     * handled by the client application, ie. when a user requests to insert
     * a new mark, only the request will be emitted, and it will be the client
     * application's duty to insert the mark or notify the user of failure.
     */
    void setMarkTypeManual(int type, bool manual = true);

    void setDefaultMarkType(int type);

    virtual SmartCursor* addMark(const Cursor& position, int type) = 0;
    virtual void changeMarkType(SmartCursor* mark, int newType) = 0;
    virtual void removeMark(SmartCursor* mark) = 0;

    /**
     * Clears all marks of the given \a type (-1 for all marks) and deletes
     * the smart cursors associated with them.
     */
    virtual void clearMarks(int type = -1) = 0;

    virtual void setMarkPixmap(int type, const QPixmap &pixmap ) = 0;

    virtual QPixmap markPixmap(int type) const = 0;

    virtual void setMarkDescription(int type, const QString &text ) = 0;

    virtual QString markDescription(int type) const = 0;

  Q_SIGNALS:
    void requestAddMark(const Cursor& position, int type);
    void requestRemoveMark(const Cursor& position, int type);

    void markAdded(SmartCursor* mark, int type);
    void markTypeChanged(SmartCursor* mark, int newType, int oldType);
    void markRemoved(SmartCursor* mark);

  private:
    class MarkInterfacePrivate* const d;
};

}

Q_DECLARE_INTERFACE(KTextEditor::MarkInterface, "org.kde.KTextEditor.MarkInterface2")

#endif

// kate: space-indent on; indent-width 2; replace-tabs on;

["signature.asc" (application/pgp-signature)]

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


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

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