Reply to topic

Multi-selection (multi-cursor) on Kate and Kdevelop

szutmael
Registered Member
Posts
9
Karma
0
Hello,

I don't know if it's the right place to post this but I would really like to see the multi-selection one day become a reality on kate and kdevelop.

So I tried to make modifications from the multicursor branch of ktexteditor https://cgit.kde.org/ktexteditor.git/tr ... ulticursor

Here is a short video that summarizes my changes: https://youtu.be/NTEfew4yqUg

So, given the compatibility problems (see tickets https://phabricator.kde.org/T3661 and https://phabricator.kde.org/T3662) with the different selection modes (block and persistent) and since the multi-cursor does not yet exist outside the block selection anyway, it would be better to disable these two modes (block and persistent) if you choose the multi-selection.

In this sense, I added an option (see the video) to explicitly choose this mode (which would not be the default mode): Settings > Configure Kate > Editing > Text Navigation > Text selection mode > Multiple

However, I was unable at that time to disable Toggle block selection when selecting "Multiple".

So what I modified (and which works):

However, unlike the initial keyboard shortcut CTRL + META, I have chosen to use only the META key (Windows Key = Super in the video).

With the mouse:

- META + double left click: selects a word and adds it to the selection list
- META + simple left click on a selection: removes the pointed selection from the selection list

On the keyboard:

- META + F : selects the next occurrence of the selection (you must already have something
selected) and adds it to the selection list
- META + SHIFT + F: Forgets the last selection then searches for the next occurrence
and adds it to the selection list
- META + ESC: removes the last selection from the selection list

However, the problems are as follows:

- I guess it still crashes with the vi mode (I don't know vi): https://bugs.kde.org/show_bug.cgi?id=397525
- The modifications I made on the multicursor branch are just horrible hacks because I am a total noob in KDE
- The multicursor branch is already too old since the last merge since master. I tried unsuccessfully a rebase or a merge, but as I know nothing about internal architecture, it is impossible for me to do this work. (last commit author Sven Brauch <mail@svenbrauch.de> 2018-08-13 10:27:57 +0200 : https://cgit.kde.org/ktexteditor.git/co ... ulticursor)

Would the author of the branch or someone else be interested in this work for a future merge? Is there anyone else interested in the multi-cursor?
jsalatas
Registered Member
Posts
61
Karma
2
OS
That may be interesting :)

is your code somehow available?
szutmael
Registered Member
Posts
9
Karma
0
My code is not yet available because it is too messy. I think I will clean up it a little and publish it in a very separate repository, just to show what was done.

I don't want to review this code now in the official repositories (anyway, I don't have developer access) in order to avoid attracting the wrath of the maintainers ^^

I would like to make an AppImage too, but that sound a little bit difficult for a kde application (unless someone tells me how to do it.)
szutmael
Registered Member
Posts
9
Karma
0
jsalatas
Registered Member
Posts
61
Karma
2
OS
Great thanks!

I just stared the project. I'm also interested in that in that feature and I also have some programming experience with ktexteditor, so I may (or may not :) ) be able to have a look at it.

Nice job btw!
szutmael
Registered Member
Posts
9
Karma
0
jsalatas
Registered Member
Posts
61
Karma
2
OS
Cool. I watch it there as well. I may have a look at the code some time. I guess that everyone involved with it will push to your branch eventually. Right?
szutmael
Registered Member
Posts
9
Karma
0
Thank you for your support ^^ You can do whatever you like so yes you can push on my repos or just work on you own repository.

What I did was just a proposal. Maybe other people want other keyboard shortcuts for example, or make it configurable.

I don't have a lot of time to devote to this but obviously any help will be welcome ^^

And I don't know if Sven Brauch https://phabricator.kde.org/p/brauch/ will have the possibility to do a new master merge on the branch.
jsalatas
Registered Member
Posts
61
Karma
2
OS
Here is an attempt to merge. Some of the features you introduced don't seem to work any more, so I'm not creating a pull request :)

https://github.com/jsalatas/ktexteditor ... ulticursor

I like you ideas about the selections as a concept, but I don't know yet if I like the whole implementation. I was expecting to see something that inherits the block select functionality which also has the concept of multiple of multiple cursors, and I was hoping to extend/refactor it that a block selection is just a special case of multi-selection and multi-cursor in general :\
szutmael
Registered Member
Posts
9
Karma
0
Oh what a so great news! This is a very good basis to start working on it again :-) I don't like the code I made either: ;D

I don't have a lot of time right now, I'm going to do what I can to make it work again ...
Thank you again for the effort you put in!
szutmael
Registered Member
Posts
9
Karma
0
I've already spent two days on it and I still haven't managed to get it working again... Even with a correct data structure, for example two vectors (for two selections) only the first selection is displayed. I'm a little... disappointed.
szutmael
Registered Member
Posts
9
Karma
0
Does anyone know where the selectionned text is repainted (*NOT* the cursors themselves), i.e. the background color ?
Code: Select all
Q_EMIT view()->selectionChanged(view());
seems not working as expected from my point of view (nothing happen)
jsalatas
Registered Member
Posts
61
Karma
2
OS
Isn't the like repainted (and eventually the cursor(s) and selection(s) that contain)? :\

I don't have the code in front of me right now, but (if I'm not wrong) there is a concept of invalidating a line and thus making it redraw.
szutmael
Registered Member
Posts
9
Karma
0
Oh that's interesting ... thanks ^^
jsalatas
Registered Member
Posts
61
Karma
2
OS
BTW, forgot to mention that previously. It seems that you added a configuration setting to turn on/off the multicursor feature. However the multicursor feature is always on if I'm not wrong?

Hmmm.... maybe I was wrong about the cache thing before, or at least maybe there is an easier way. Sorry about that :(

If you check here
https://github.com/KDE/ktexteditor/blob ... .cpp#L3522

you may just need to repeat what is below the line for every cursor/selection? That might work if you can access the data :\

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Exabot [Bot], Google [Bot], gregorymartinez, oxwivi, rokagames71, samuelvenable, Section_8, Yahoo [Bot]