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
PR: Add indentation guidelines #4572
Conversation
Nice :-), like this a lot! |
self.color = Qt.darkGray | ||
self.i_width = 4 | ||
|
||
self.setAttribute(Qt.WA_TransparentForMouseEvents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why duplicate here?
There was a problem hiding this comment.
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""" |
There was a problem hiding this comment.
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""" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
period
Screenshot, please? :-) |
…t is implemented in Panel class.
Added 😄 |
Neat, but the guidelines are discontinuous? Can we do something about it? |
@ccordoba12, please post a screenshot of what you expect? on vscode, or sublime... or ? |
@rlaverde screenshot? |
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? |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this 5
?
There was a problem hiding this comment.
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) 😕
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 :-/
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 ;-)
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
This looks terrific!! Great work @rlaverde! A couple of comments:
|
This is a UI exclusive thing, it would be kinda hard to test I think :-| |
@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? |
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 like to use guidelines only, so I'd prefer to maintain the two options separate. |
Guidelines are painted, not a widget, how do you check that? |
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. |
Neither do I.... aside from doing more complex image processing... with a screenshot/pixmap of the editor widget |
Fair enough. The test you added is sufficient. So the only thing missing here is adding an entry to the |
Is this ready? |
Yes, the refactoring related to the hardcoded offset will be addressed in other PR |
Great, thanks! |
Fixes: #2987
I added a floating type panel, and move
edgeline
andindentguides
to use it.I didn't find a way to abstract all the logic in the
PanelManager
, and floatings Panels need to have aset_geometry
methodThis is how it looks like, It uses the comments color (same as edgeline)