Open brupelo opened 3 years ago
Hi
Your review is really impressive Qutepart isn't actively developed now. But PR which implements multicursor feature is welcome. I can not estimate how difficult it will be because never use multicursor feature in other editors.
@andreikop Sad to hear the project isn't actively developed now, I thought it was when I was checking the commit history, prs, issues... when I read the code my first thought was the project had a lot of potential.
Regarding to implement this particular feature, if it was easy to implement it I'd certainly give it a shot but unfortunately it's not clear to me how I'd do it at a first glance. In fact, not sure if by using QTextCursor objects would be the way to go to implement it properly (with undo/redo). I guess a good first step would be that If someone has a good plan/ideas about the implementation details please just share with us, that way someone (myself included) could give it a shot.
Try to implement undo-redo with methods beginEditBlock()
, endEditBlock()
You call beginEditBlock()
, then do a series of edit operations and call endEditBlock()
. All operations are recorded as single operation.
I don't know how to draw multiple cursors. Probably by re-implementing paintEvent()
. See how indentation markers and whitespaces are drawn.
Yeah, sounds about right, probably paintEvent()
should be the proper place where you'd multiple cursors draw logic should be. You can see in one of the examples I've pasted above how that's done https://github.com/JuBan1/OpenTextEdit/blob/master/ote/textedit.cpp#L968-L1136 . You'll see in that code he's also using both begin/endBlock methods but not sure if you'd get the right effect when undoing/redoing as I haven't compiled/tested that code.
In any case, implementing this core feature
would be awesome because once such feature was in-place you could do nice things such as implementing on top of it some sort of emulation layer of the SublimeText API, why? Because with such an API you could reuse many SublimeText commands straightaway on the widget. But again, before going that route you'd need to have this important core feature properly implemented.
Hi, first of all let me tell you after reading this project code a bit I must to say I'm impressed, it is pretty awesome&cool :)
Why am I telling this? Thing is, I've explored almost all github for few months in order to find a standalone text editor widget for python+qt that offers similar "core functionality" than codemirror, monarch, sublimetext, vscode, atom, etc... in my experience I can tell you none of the qt attempts (not even qtcreator itself) I've found were able to reach the same level of "core features"... Why? Because implementing multicursor feature properly isn't trivial by all means.
For instance, take a look to the good old (Q)Scintilla, you'll see that widget has already attempted to implement multicursor few years ago but the whole experience is completely ruined mainly because it hasn't implemented properly undo/redo and also the feature itself is not very "consistent".
Anyway, my question to you is, how hard would be implementing the multicursor feature with undo/redo properly on qutepart? IMHO if such feature was implemented, this project would reach the "next level/milestone" and it'd probably become some sort of "reference" for the python+qt community for sure.
Btw, I'll paste here some resources I've found in the past in case it may help somehow:
Ps. The way codemirror implements that feature is quite nice actually.