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

List:       ktexteditor-devel
Subject:    Re: [RFC] new Interface to provide custom label/line
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2008-03-02 13:21:22
Message-ID: 20080302132121.GD20517 () morpheus ! apaku ! dnsalias ! org
[Download RAW message or body]

On 12.01.08 12:26:05, Andreas Pakulat wrote:
> On 12.01.08 13:48:47, Hamish Rodda wrote:
> > On Sun, 6 Jan 2008 03:48:12 am Andreas Pakulat wrote:
> > > Hi,
> > >
> > > for KDevelop4 I'd like to have support for showing a custom label for
> > > each line of a text file. I don't yet have any specific idea how to
> > > implement this as I don't have much (if any) experience how you guys
> > > design the KTE interfaces.
> > 
> > Moving to ktexteditor-devel, where the api stuff should be discussed...
> 
> Oh, wasn't aware that it exists. Thanks.
> 
> > > Why feature-wishes are: Setting a text which is shown on a new border
> > > similar to the linenumbers, changing the background for the text and
> > > providing tooltip information for that text. The text can be set for
> > > each line in the file.
> > 
> > What do you plan to do with this interface?
> 
> Showing the authors userid directly on the border.
> 
> > What should happen when the text is too long?
> 
> Add an elipsis. I think using a small (maybe configurable) fixed font
> and limiting this to maybe 10 or 12 chars should be quite ok.
> 
> >  How wide should the border column be?
> 
> See above, 10 to 12 chars maybe. Its really intended just for very
> little information directly shown, most important for VCS is the
> username and also the coloring to see which parts of a file where
> changed together. Anything else would be in a tooltip when hovering over
> the border...

Ping? Ok, well maybe I need to provide some more substance. I'm thinking
about something along these lines:

class LineAnnotationInterface 
{
public:
    /**
     * Set a new annotation provider
     * @param provider the provider to use for the data on the
     * annotation border
     */
    void setLineAnnotationProvider( LineAnnotationProvider* provider );

    /**
     * @returns the current annotation provider or null if none is set.
     */
    LineAnnotationProvider* lineAnnotationProvider();

    /**
     * Show or hide the border for the annotation
     * @param show if true shows the border, else hides it
     */
    void showAnnotationBorder( bool show );
};

class LineAnnotationProvider 
{
public:
    enum DataRole 
    {
        BackgroundRole /** Used to provide custom background, for 
        example custom color */,
        ForegroundRole /** Used to provide custom foreground, for
        example custom text color */,
        TextRole /** Used to provide the text thats displayed on the
        views border */ ,
        TooltipRole /** a tooltip thats displayed when hovering over the
        border */
    };

    /**
     * returns the needed data for the given role on the given line
     * @line the line to fetch annotation information for
     * @role the role describing what type of information to fetch
     */
    QVariant data( int line, LineAnnotationProvider::DataRole role ) = 0;
};

Thats really all I need. The client code can then set its own provider
implementation (in KDevelop to provide VCS annotation information) and
Kate would just need to allow to show/hide the border (or let the client
to it programmatically). 

One cool feature could be to also use the background role (or at least
the color from it) to tint the normal view background when hovering over
the border. Would make it really easy to see which lines belong to the
same annotation (i.e. same revision from svn).

Andreas

-- 
You will not be elected to public office this year.
_______________________________________________
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