Bug 68962 - Hooks for getting the text under the mouse cursor
Summary: Hooks for getting the text under the mouse cursor
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: SVN
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-24 20:52 UTC by Jon Smirl
Modified: 2011-08-30 14:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Smirl 2003-11-24 20:52:41 UTC
Version:           CVS (using KDE Devel)
Installed from:    Compiled sources

KDevelop is missing a major feature in it debugger. When the mouse is left idle (hover) over the source code a popup window should appear with the variable's value. This is a sorely needed feature when debugging programs with lots of variables.

KDevelop can't implement this feature because Kate is missing the hooks for getting the text from under the mouse cursor. Could Kate please implement the needed hooks?
Comment 1 Hamish Rodda 2003-12-01 16:04:52 UTC
I'm certainly interested in this and it is pretty easy to do.  It will require a new extension because of the way the KTextEditor interfaces are designed, and as this counts as a new feature it will have to wait for 3.3/4.0 (unless you can convince the feature freeze police).

How would you like this interface to look? A function to retrieve the text cursor position corresponding to the mouse position at the time the function is called is an obvious choice.  We could also have a request / signal model, where you ask for events every x ms of idle mouse time, if that's easier.

Anyway, for now, if you were really keen (and don't mind an ugly hack) you could, after a set amount of idle time, save the current cursor position and selection boundaries, generate a mouse click, grab the cursor position, and set it all back again.  But it would be an ugly hack as things go.

I'm also happy to branch ktexteditor for now if you're eager to try this out asap.

Cheers, Hamish.
Comment 2 Hamish Rodda 2003-12-01 16:08:38 UTC
Actually, it would seem to me that this is possible using KTextEditor::TextHintInterface, or am I mistaken? I'm happy to help / answer any questions about it / fix bugs etc.
Comment 3 Jon Smirl 2003-12-01 16:31:46 UTC
I added you offer to the kdevelop bug
http://bugs.kde.org/show_bug.cgi?id=60168

You might want to add yourself to the cc list on that one and make the kdevelop bug depend on this one.
Comment 4 Christoph Cullmann 2003-12-02 21:21:33 UTC
Subject: Re:  Hooks for getting the text under the mouse cursor

> Actually, it would seem to me that this is possible using
> KTextEditor::TextHintInterface, or am I mistaken? I'm happy to help /
> answer any questions about it / fix bugs etc.
yes, it is texthintinterface, atm, the implementation in kate part does not 
show the needed popup, only does some debug output. For right implementation, 
we should look at qeditor in kdevelop (they have implemented it there and I 
hope they have it working and not just for fun). Not much is missing, but as 
I have no time to fix it & play with kdevelop and test it before 3.2, I guess 
if you want it working somebody else must play a bit with it, should not be 
much work and no bigger changes.

cu
Christoph

Comment 5 Christian Parpart 2005-12-15 17:53:11 UTC
actually, we've even KDE 3.5 already out there, and it's even 2 years since this bug has been opened and assigned and yet, nothing happened on the coder front.

What's up? I'd certainly want this feature for good as well :-)

Although, I'd like to point here to my thread I started in the kdevelop-devel mailing list with subject "improving debugging experience ;)" where I was talking exactly about such a behavior (just with a little more improvement over a simple tooltip).

Comments?
Comment 6 Christian Parpart 2005-12-15 17:58:38 UTC
err, fool me. my comments do just implicitely belong to this bug, I was refering to #60168. sorry for causing inconveniences ;)
Comment 7 Victor Tyurin 2006-01-06 16:25:49 UTC
To all people responsible on katepart:

Does anybody know, why implementor of TextHintInterface should implement timeout setting ability in enableTextHints?

This timeout makes implementation of TextHintInterface much more difficult, because we can't use standart QTooltip with its MaybeTip function overloading!

TextHintInterface:
virtual void 	enableTextHints (int timeout)=0;

I think, we should use standart QT's tooltip timeout in that interface, or we should ignore  timeout argument.

I've realized tooltips in my katepart using QTooltip::MaybeTip, it works well with my test project.

See http://computing.ee.ethz.ch/sepp/qt-3.1.1-mo/qtooltip.html#maybeTip, and example (dynamic tooltips): http://computing.ee.ethz.ch/sepp/qt-3.1.1-mo/tooltip-example.html#x449.

Please, say me, what do you think on such implementation?
It's quite simple, and works good...
I can post my kateviewinternal.cpp/h here...
Comment 8 Dominik Haumann 2011-08-12 12:18:18 UTC
Is this still an issue?

We have an interface now that provides access to text cursor through mouse/pixel coordinates: 
class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface
{
  public:
    /**
     * Get the text-cursor in the document from the screen coordinates,
     * relative to the view widget.
     *
     * To map a cursor to pixel coordinates (the reverse transformation)
     * use KTextEditor::View::cursorToCoordinate().
     *
     * \param coord coordinates relative to the view widget
     * \return cursor in the View, that points onto the character under
     *         the given coordinate. May be KTextEditor::Cursor::invalid().
     */
    virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0;
}
Comment 9 Dominik Haumann 2011-08-30 14:55:18 UTC
fixed through the interface function:
KTextEditor::Cursor CoordinatesToCursorInterface::coordinatesToCursor(const QPoint& coord) const

Close, as we got no feedback anymore.