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 code folding to the Editor #3833

Merged
merged 22 commits into from
Jan 31, 2017
Merged

Conversation

rlaverde
Copy link
Member

@rlaverde rlaverde commented Dec 13, 2016

Fixes #706


Progress:

  • Add pyqode code decoration.py folding.py utils.py codefolding.py managers/decoration.py
  • Register FoldingPanel to codeeditor (at the moment It's displayed as an empty panel)

TODO:

  • Reconnect Signals
  • Fix comment out editor.add.menu()
  • Delete inner lines if folding line is deleted
  • Implement pyqode SyntaxHighlighter.highlightBlock functionality that call FoldDetector.process_block, in each block
  • Fix error with Syntax higtlighter and multiple line comments
  • Fix error with mouse event (mouse position is a little wrong)
  • Change docstrings to make reference to spyder classes
  • Rebase it after PR: Add Panels and PanelsManager, and use it to add LineNumberArea to editor #3778
  • Add pyqode copyright and license and links to source files
  • Reword, reorder and squash some commits
  • Test that everything is working

Somethings that I'm not sure if should be do it:
- Remove decoration.py and implement It's functionality in CodeEditor I think is ok to leave it
- Remove utils.py and use CodeEditor functionality (and implement missing functionalities) I think is ok to leave it too

Things that I'll address in other PRs

  • Move some codeeditor functions to TextHelper, and delete redundant functions
  • Inners foldings should be preserved when folding unfolding their parent
  • Add shortcuts and menu for codefolding actions
  • Some style improvements (only show arrows when mouseover, different colors, only decorate selected block, use different icons for folding arrows)
  • Implement others fold detectors (apart of the indentation fold detector)

@ccordoba12
Copy link
Member

Great work @rlaverde!

Could you post a screenshot for this new feature as part of the description? Thanks!

@rlaverde
Copy link
Member Author

@ccordoba12 at the current state it's not possible, It just show an empty panel, I think that after implemented the missing part in SyntaxHighlighter, it will work :)

@rlaverde
Copy link
Member Author

There are a lot some things missing, but It's working now 😄
code_folding

@ccordoba12
Copy link
Member

This is really cool!! Thanks a lot @rlaverde!!

How folding is computed? Using regexs?

@rlaverde
Copy link
Member Author

How folding is computed? Using regexs?

Using Indentation, although It could be extended to use other methods
https://github.com/spyder-ide/spyder/pull/3833/files#diff-6ceb5fb1fd412eaffd5a62296d5c688bR138

@ccordoba12
Copy link
Member

Using Indentation, although It could be extended to use other methods

Ok, that's fine for Python, but we definitely need to add other methods for languages like C/C++ and Fortran ;-)

In any case this is a hell of a improvement!! Good job :-)

@rlaverde rlaverde force-pushed the codefolding branch 3 times, most recently from 436dbc6 to 078100a Compare December 22, 2016 14:55
@rlaverde rlaverde force-pushed the codefolding branch 3 times, most recently from f9d36b4 to f9f6b80 Compare December 24, 2016 15:33
@rlaverde
Copy link
Member Author

@goanpeca @ccordoba12 This is ready, only missing a rebase with master after #3778 merge

@rlaverde rlaverde changed the title [WIP] PR: Codefolding PR: Codefolding Dec 24, 2016
@goanpeca
Copy link
Member

goanpeca commented Dec 24, 2016

Woot! so baby jesus is getting code folding after all 🤣

@ccordoba12
Copy link
Member

Great work @rlaverde! Really nice Christmas present for Spyder!!

I have one question: is this only applied to Python files (for now)?

@ccordoba12
Copy link
Member

One important suggestion before reviewing: please use FontAwesome icons for the folding marks, and not just the PNG's you provided. That's very important to preserve not only consistency but also our ability to render correctly in high DPI screens.

@goanpeca
Copy link
Member

One important suggestion before reviewing: please use FontAwesome icons for the folding marks, and not just the PNG's you provided. That's very important to preserve not only consistency but also our ability to render correctly in high DPI screens.

@rlaverde yes, could we use those icons better :-) ?

@ccordoba12
Copy link
Member

Png's are fine for the Spyder 2 theme, but we also need to use FontAwesome icons :-)

@goanpeca
Copy link
Member

@rlaverde could you rebase now that panels are merged?

@rlaverde rlaverde force-pushed the codefolding branch 2 times, most recently from 75d3d0e to 7f22c1d Compare December 27, 2016 15:28
@rlaverde
Copy link
Member Author

rlaverde commented Dec 27, 2016

I have one question: is this only applied to Python files (for now)?

This is applied to all files, folding are detected using indentation (with the len of indent_chars)

One important suggestion before reviewing: please use FontAwesome icons for the folding marks, and not just the PNG's you provided. That's very important to preserve not only consistency but also our ability to render correctly in high DPI screens.

Ready, I deleted old pngs and use caret font awesome icons. (I squashed the commit)

could you rebase now that panels are merged?

I just rebase it with master 😄

@goanpeca
Copy link
Member

@ccordoba12 are we planning on having pngs with Spyder 4.0?

I would say that on 4.0 we should only support ttf fonts via qtawesome?

@ccordoba12
Copy link
Member

I would say that on 4.0 we should only support ttf fonts via qtawesome?

I agree, but until we do that we're still supporting the Spyder 2 theme :-)

@goanpeca
Copy link
Member

I agree, but until we do that we're still supporting the Spyder 2 theme :-)

But this is on Master... so why should we support it on master?

Use QStyleOptionViewItem for PyQt4 and PyQt5.
Emit this signals in corresponding methods.
- Make syntaxHighlighter process blocks for folding.
- Change syntaxHiglighter calls to use TextBlockHelper.
- Add simple docstrings highlight_block methods, and fix some style issues.
Fix some style issues in docstrings
@goanpeca
Copy link
Member

@ccordoba12 unless you have more comments this is ready to be merged

@ccordoba12
Copy link
Member

Ok, let's go with it so that @rlaverde can keep enhancing it on master.

This is a huge improvement!!! Thanks @rlaverde for working on it :-)

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.

4 participants