D14826: inline note interface wip #2

2018-08-14 Thread Michal Srb
michalsrb added a comment.


  Thank you for working on this. This interface would work for the 
kdev-sourceinfo use case just as well as the old one.
  
  I think the problem with the old interface that you described is valid. This 
version gives more flexibility to the `InlineNotesProvider` with regards to how 
it stores the notes internally.
  
  Do you have plan how to track the movement of the notes during edits? Maybe 
the InlineNote could also hold revision number for which it was created?

INLINE COMMENTS

> inlinenoteinterface.h:145
> + */
> +virtual QVector inlineNotes(int line) const = 0;
> +

Perhaps this could be `QVarLengthArray` of some size too?

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D14826

To: brauch, michalsrb, dhaumann, cullmann
Cc: anthonyfieroni, kwrite-devel, kde-frameworks-devel, michaelh, kevinapavew, 
ngraham, bruns, demsking, cullmann, sars, dhaumann


D12662: Add InlineNoteInterface

2018-08-13 Thread Michal Srb
michalsrb added a comment.


  In D12662#307752 , @brauch wrote:
  
  > I'd like to play with this a bit wrt what can be done in KDevelop with it 
(I want the problem popups gone). Would you mind if I do some changes along the 
way? I would post an updated patch here, in case I actually come up with useful 
changes ...
  
  
  No problem, go ahead.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb, #ktexteditor
Cc: kwrite-devel, kde-frameworks-devel, dhaumann, cullmann, ngraham, brauch, 
michaelh, kevinapavew, bruns, demsking, sars


D12662: Add InlineNoteInterface

2018-08-13 Thread Michal Srb
michalsrb added a comment.


  Sorry, I had almost no time to work on it. I got stuck trying to figure out 
how to properly handle the notes at the beginning of the lines.
  
  Then I created KDevelop plugin as experiment to try if the interface is 
usable:
  https://github.com/michalsrb/kdev-sourceinfo
  
  F6190087: final-anim.gif 
  
  With that experience I think two things should be done differently:
  
  - The notes should use something like `MovingCursor` instead of fixed line + 
column, so they move when the text is edited, instead of waiting for refresh 
from the provider.
  - Currently the notes are "glued" to the character on their left side - it is 
not possible to place cursor in between that letter and the note. It feels 
unnatural when editing. In other editors (e.g. IntelliJ) the note behaves as 
separate character/object and the cursor can be placed on both sides. The note 
is still not editable, pressing backspace or delete just skips over the note. 
Any advice on how to achieve this with ktexteditor would be helpful.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb, #ktexteditor
Cc: kwrite-devel, kde-frameworks-devel, dhaumann, cullmann, ngraham, brauch, 
michaelh, kevinapavew, bruns, demsking, sars


D13536: Do not cancel old clipboard selection if it is same as the new one.

2018-06-14 Thread Michal Srb
michalsrb abandoned this revision.
michalsrb added a comment.


  Already submitted: https://phabricator.kde.org/D13535

REPOSITORY
  R127 KWayland

REVISION DETAIL
  https://phabricator.kde.org/D13536

To: michalsrb
Cc: kde-frameworks-devel, michaelh, ngraham, bruns


D13536: Do not cancel old clipboard selection if it is same as the new one.

2018-06-14 Thread Michal Srb
michalsrb created this revision.
Restricted Application added a project: Frameworks.
Restricted Application added a subscriber: kde-frameworks-devel.
michalsrb requested review of this revision.

REVISION SUMMARY
  GTK applications seem to call wl_data_device::set_selection multiple times 
with
  the same wl_data_source object, replacing it with itself. If we cancel it, 
they
  will destroy it and the selection will be gone.
  
  With this patch it is again possible to copy from GTK applications.
  
  BUG: 395366

REPOSITORY
  R127 KWayland

REVISION DETAIL
  https://phabricator.kde.org/D13536

AFFECTED FILES
  src/server/datadevice_interface.cpp

To: michalsrb
Cc: kde-frameworks-devel, michaelh, ngraham, bruns


D12662: Add InlineNoteInterface

2018-05-02 Thread Michal Srb
michalsrb added a comment.


  In D12662#257342 , @brauch wrote:
  
  > Looks good from the implementation too so far. One thing I do not see is 
any changes to the cursorToX / xToCursor functions, is there really no change 
required there?
  
  
  No change was really needed. As the spaces are created when laying out the 
line, either by offsetting the start of the line or by formatting the text, it 
gets stored in the layout and the cursorToX / xToCursor work as expected. Even 
moving the cursor around with arrow keys works nicely (the cursor moves to the 
closest position above/below even if one of the lines is shifted).
  
  > Some things which come to my mind for testing would be:
  > 
  > - is selection rendered correctly if it includes notes, at the end, 
beginning, or middle of lines, also mult-line selections?
  
  I thought regular selection works fine, but actually I just found a glitch; 
if there is a note at the beginning of the line, it does not render the 
selection background under it:
  
  F5831112: Screenshot_20180502_205152.png 

  
  A selection in block mode behaves like if the notes are not there:
  
  F5831117: Screenshot_20180502_205212.png 

  
  I can't tell whether it is good or bad behavior. Do you think it should stay 
this way - selecting the block of the real text, or should it instead select a 
"visual" block?
  
  I was thinking it would be best to avoid this problem and hide the notes when 
doing block mode selection, but should that be done by ktexteditor directly, or 
by the user of the interface? I also imagine that anything that uses it would 
provide some quick on/off toggle for cases like this.
  
  > - what happens when clicking or dragging from or into the notes?
  
  Clicking into the note always places the text cursor on the right side of the 
note - in other words, the note acts as extension of the letter on its left. 
Dragging makes normal selection from that position.
  
  > - does it still work properly with dynamic word-wrap on?
  
  Hmm, looks like notes at the beginning of the text ruin the breaking of the 
line:
  
  F5831141: Screenshot_20180502_212929.png 

  
  And it also does not place the notes well if the wrapped line keeps keeps 
indentation, like in this case:
  
  F5831123: Screenshot_20180502_210236.png 

  
  > - does it work properly with code-folding? what happens if a note is at the 
border of a folding region?
  
  It works fine. When a line is hidden, so are the notes in it.
  
  One more thing that needs to be decided: At this moment if a note is placed 
past the end of the text too far to the right and word-wrap is on, it does not 
wrap, but renders partially or completely out of view. (This happens kinda by 
default as the layout of the line is not modified for notes out of the text.) 
My thinking was that it does not matter as one would either place notes in the 
text, or outside at a column that will be visible without scrolling/wrapping. 
But if you think it should wrap, I can try to find a way to make that happen.
  
  Thank you for the review, I'll fix these problems and make the changes you 
noted.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb, #ktexteditor
Cc: brauch, #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, 
cullmann, sars, dhaumann


D12662: Add InlineNoteInterface

2018-05-02 Thread Michal Srb
michalsrb added a comment.


  Here are screenshots from the sample plugin:
  
  F5831086: txt.png  F5831085: cpp.png 
 F5831084: qml.png 

  
  The plugin provides notes that are just hardcoded for those specific files. 
The style of the notes is completely up to the user of the interface.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb, #ktexteditor
Cc: brauch, #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, 
cullmann, sars, dhaumann


D12662: Add InlineNoteInterface

2018-05-02 Thread Michal Srb
michalsrb added a comment.


  This is my first attempt to propose such API, it may not be ideal.
  
  If the inline note is placed into text, the space for it is created using 
QTextCharFormat's absolute spacing between the two letters. I admit it is quite 
a misuse, but it was the least intrusive way to create the space. Everything 
else seems to work with it out of the box without further modifications.
  
  A kate plugin that demonstrates how to use it is here:
  https://github.com/michalsrb/sampleinlinenotesplugin
  
  You can find screenshots in the "samples" directory.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb
Cc: #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, cullmann, 
sars, dhaumann


D12662: Add InlineNoteInterface

2018-05-02 Thread Michal Srb
michalsrb added a reviewer: KTextEditor.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

To: michalsrb, #ktexteditor
Cc: #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, cullmann, 
sars, dhaumann


D12662: Add InlineNoteInterface

2018-05-02 Thread Michal Srb
michalsrb created this revision.
Restricted Application added projects: Kate, Frameworks.
Restricted Application added a subscriber: Frameworks.
michalsrb requested review of this revision.

REVISION SUMMARY
  The inline note interface provides a way to render arbitrary things in
  the text. The layout of the line is adapted to create space for the note.
  
  Possible applications include showing a name of a function parameter on call
  side or rendering square with color preview next to CSS color property.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12662

AFFECTED FILES
  src/document/katedocument.cpp
  src/document/katedocument.h
  src/include/CMakeLists.txt
  src/include/ktexteditor/inlinenoteinterface.h
  src/render/katerenderer.cpp
  src/utils/ktexteditor.cpp
  src/view/kateview.h

To: michalsrb
Cc: #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, cullmann, 
sars, dhaumann


Asking for recommendations on how to add a feature to KTextEditor

2018-04-09 Thread Michal Srb
Hi,

I would like to ask for hints/recommendations on how to implement a
feature for KTextEditor.

My ultimate goal is to make a plugin for KDevelop that will show some
additional information in the code itself. For example names of
function arguments at call site. Something like this in intellij:
https://d3nmt5vlzunoa1.cloudfront.net/idea/files/2016/09/Screen-Shot-2016-09-27-at-10.29.15.png

For this I would need a way to render something in the text, affecting
the layout of the line. It would be nice to be able to place any
general widget or image into the line, but even plain text would be
sufficient. It must behave differently than the "real" text around it,
such that it can not be edited, cursor skips it, copying does not copy
it, etc.

So far I thought of adding something like `AnnotationViewInterface`,
which would allow to add this kind of immutable text on line+column
position. Then in `KateRenderer` it could take these into
consideration when layouting the line and render it in. It would be
visible in the text, but never become a real part of the text.

Would you recommend some other approach, or is there perhaps a way to
do it without modifying KTextEditor?

Thank you,
Michal Srb