Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add indentation guidelines #4572

Merged
merged 17 commits into from Jun 13, 2017

Conversation

rlaverde
Copy link
Member

@rlaverde rlaverde commented Jun 7, 2017

Fixes: #2987

I added a floating type panel, and move edgeline and indentguides to use it.

I didn't find a way to abstract all the logic in the PanelManager, and floatings Panels need to have a set_geometry method

This is how it looks like, It uses the comments color (same as edgeline)
spectacle j13255

@rlaverde rlaverde added this to the v4.0beta1 milestone Jun 7, 2017
@rlaverde rlaverde self-assigned this Jun 7, 2017
@goanpeca
Copy link
Member

goanpeca commented Jun 7, 2017

Nice :-), like this a lot!

self.color = Qt.darkGray
self.i_width = 4

self.setAttribute(Qt.WA_TransparentForMouseEvents)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why duplicate here?

Copy link
Member Author

@rlaverde rlaverde Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to delete it. when moving it to panel class

self._enabled = True

def paintEvent(self, event):
"""Override Qt method"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Period on docstrings

# -----------------------------------------------------------------

def set_enabled(self, state):
"""Toggle edge line visibility"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


def update_color(self):
"""
Set edgeline color using syntax highlighter color for comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

# (see spyder/__init__.py for details)

"""
This module contains the indentation guide panel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period

@ccordoba12
Copy link
Member

Screenshot, please? :-)

@rlaverde
Copy link
Member Author

rlaverde commented Jun 7, 2017

Screenshot, please? :-)

Added 😄

@ccordoba12
Copy link
Member

Neat, but the guidelines are discontinuous? Can we do something about it?

@goanpeca
Copy link
Member

goanpeca commented Jun 7, 2017

Neat, but the guidelines are discontinuous?

@ccordoba12, please post a screenshot of what you expect? on vscode, or sublime... or ?

@goanpeca
Copy link
Member

goanpeca commented Jun 7, 2017

@rlaverde screenshot?

@rlaverde
Copy link
Member Author

rlaverde commented Jun 7, 2017

Neat, but the guidelines are discontinuous? Can we do something about it?

It's drawn using only the current line, I added a little hack to avoid discontinuity (preserve previous indentation), I think this is the best possible without making it "smart" and adding a lot of complexity.

spectacle y14297

@goanpeca
Copy link
Member

goanpeca commented Jun 7, 2017

I think it looks ok, we will probably need information from the fold detector eventually to make it better? Cause I guess this is now python specific?

@rlaverde
Copy link
Member Author

rlaverde commented Jun 7, 2017

we will probably need information from the fold detector eventually to make it better?

I hadn't thought about that 🙈 It was way easy to use folding levels and less error prone. I looks the same as the last screenshot.

"""Calculate and set geometry of indentation guides panel."""
offset = self.editor.contentOffset()
x = self.editor.blockBoundingGeometry(self.editor.firstVisibleBlock()) \
.translated(offset.x(), offset.y()).left() + 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this 5?

Copy link
Member Author

@rlaverde rlaverde Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hardcoded offset used in the edgeline panel (I don't have any idea why, but if I delete it and the panel is misplaced) 😕

Copy link
Member

@goanpeca goanpeca Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm ok, we need to dig deeper to know where this 5 comes from :-p

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Pïerre is the only one who knows why that 5 is here :-/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is something like the margin of the editor (but I'm not sure)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok whatever it is, we need to put in a constant or use it within the methods that return the offsets, so that it is fixed in one place!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but that's not work for this PR, I'd say ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @rlaverde lets open a techdebt issue to track this problem so we can solve it later on

else:
self.update(0, qrect.y(),
self.width(),
qrect.height())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's implemented in the PanelManager class, It's enough to set scrollable=True in a Panel to make it scroll with the editor

@ccordoba12
Copy link
Member

This looks terrific!! Great work @rlaverde!

A couple of comments:

  1. Please add a menu entry in the Source menu to easily activate/deactivate these guidelines. This is similar to the Show blank spaces entry.
  2. A test for this would be desirable (even if very simple).

@goanpeca
Copy link
Member

goanpeca commented Jun 8, 2017

A test for this would be desirable (even if very simple).

This is a UI exclusive thing, it would be kinda hard to test I think :-|

@goanpeca
Copy link
Member

goanpeca commented Jun 8, 2017

Please add a menu entry in the Source menu to easily activate/deactivate these guidelines. This is similar to the Show blank spaces entry.

@ccordoba12 I would say spaces and guidelines fall in the same thing, so maybe we can just merge these options together? I say that in the spirit of keeping the UI and options simple. Thoughts?

@ccordoba12
Copy link
Member

ccordoba12 commented Jun 8, 2017

This is a UI exclusive thing, it would be kinda hard to test I think :-|

A test could consist in creating a Python file with indentation and test that guidelines are visible. That would be enough for me.

I would say spaces and guidelines fall in the same thing, so maybe we can just merge these options together? I say that in the spirit of keeping the UI and options simple. Thoughts?

I would like to use guidelines only, so I'd prefer to maintain the two options separate.

@goanpeca
Copy link
Member

goanpeca commented Jun 8, 2017

A test could consist of creating a Python file with indentation and test that guidelines are visible.

Guidelines are painted, not a widget, how do you check that?

@rlaverde
Copy link
Member Author

rlaverde commented Jun 8, 2017

I added a simple test that check that panels are added to the editor and are enabled, I don't know how to test the internal behavior of the Paint method.

@goanpeca
Copy link
Member

goanpeca commented Jun 8, 2017

I don't know how to test the internal behavior of the Paint method.

Neither do I.... aside from doing more complex image processing... with a screenshot/pixmap of the editor widget

@ccordoba12
Copy link
Member

ccordoba12 commented Jun 9, 2017

I don't know how to test the internal behavior of the Paint method.

Fair enough. The test you added is sufficient.


So the only thing missing here is adding an entry to the Source menu. Then I'll merge :-)

@ccordoba12
Copy link
Member

Is this ready?

@ccordoba12 ccordoba12 changed the title PR: Indentation guides panel PR: Add indentation guidelines Jun 13, 2017
@rlaverde
Copy link
Member Author

Is this ready?

Yes, the refactoring related to the hardcoded offset will be addressed in other PR

@ccordoba12
Copy link
Member

Great, thanks!

@ccordoba12 ccordoba12 merged commit c6955dc into spyder-ide:master Jun 13, 2017
@rlaverde rlaverde deleted the indentation-guides-panel branch June 13, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants