This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Draw multiple cursors with KTextEditor::View

Tags: None
(comma "," separated)
jo_link_noir
Registered Member
Posts
2
Karma
0
Hi,

I am developing a plugin to support multiple cursors in a document but I am having problems rendering.

Currently, to display a cursor, I made ​​a selection of 1 character with KtextEditor::MovingRange interface (KtextEditor::MovingCursor has no property of rendering). But this confuses the cursor position (before or after the selected character?) And it is not displayed when the virtual cursor is positioned at the end of line (there is no character to select ...)

So I made my own widget to display a cursor but I can not
  • Obtain the x, y position of my cursor to put in the view. KTextEditor::View::cursorToCoordinate gives me offset values​​... I feel that the border line and other are not taken into account.
  • Get the size of a line. I can identify with a positional difference between the current line and the one that follows or precedes, but if there is no line I must add a line for the position returned by cursorToCoordinate() to be valid.

I'm interested in any ideas ^-^.
My implementation is here.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Hi!

I'm not sure if writing a plugin for multiple cursors is the best approach. It will probably be quite difficult to get that working nicely. If KTE should support multiple cursors, I think it would be better to implement it in there directly.

Maybe you should start a discussion on the mailing list (kwrite-devel) about this -- other people have already been thinking about how to implement this best, and it might be fruitful to talk to them first :)

Best regards,
Sven


I'm working on the KDevelop IDE.
jo_link_noir
Registered Member
Posts
2
Karma
0
Hi!

Thank you for your answer.Sure, I had some problems I solved it a little dirty. I think it lacks a KTE interface to move a cursor (next or previous word / character, bracket matching, etc). The final result is satisfaisant however, the big problem is the visual rendering.

I start a discussion soon as I has more time.

Best regards,
Jonathan
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Rendering of the cursors should be done by kate's renderer, which is not accessible from a plugin. You could of course overlay additional widgets over the editor area, but that is an ugly hack and really shouldn't be done like that.


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]