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

Command like "Balance Parens" from sc.app #602

Closed
jamshark70 opened this issue Oct 14, 2012 · 8 comments
Closed

Command like "Balance Parens" from sc.app #602

jamshark70 opened this issue Oct 14, 2012 · 8 comments

Comments

@jamshark70
Copy link
Contributor

I raised this suggestion in #444, but it got lost. It would be very useful to be able to select not only "regions" delimited by () but also to expand the selection to include everything in the next outer layer of brackets. I used this feature a lot in sc.app, and in emacs, I could get close to the same functionality using C-M-f and C-M-b. There is nothing in the ide that does anything like this, and sometimes, I really wish it were easier.

@sidechained
Copy link

I'd like to see this too!

Graham
On Oct 14, 2012 3:39 PM, "jamshark70" notifications@github.com wrote:

I raised this suggestion in #444#444,
but it got lost. It would be very useful to be able to select not only
"regions" delimited by () but also to expand the selection to include
everything in the next outer layer of brackets. I used this feature a lot
in sc.app, and in emacs, I could get close to the same functionality using
C-M-f and C-M-b. There is nothing in the ide that does anything like this,
and sometimes, I really wish it were easier.


Reply to this email directly or view it on GitHubhttps://github.com//issues/602.

@mtmccrea
Copy link
Member

mtmccrea commented Jan 7, 2013

+1. This would be great!

@jamshark70
Copy link
Contributor Author

Bumping with a question for Jakob: If I wanted to implement this, where would I begin?

I just had to hunt by hand for the closing brace of a long if-branch. Why isn't the IDE searching for that brace for me? (Compare emacs: cursor before the opening brace, then ctrl-alt-F.)

Tired of it -- I want to implement it myself. We really need this feature.

@jleben
Copy link
Member

jleben commented Feb 28, 2013

Hi James,

I'm glad you want to contribute :)

You'll need to add some key handling in ScCodeEditor::keyPressEvent() at:
/editors/sc-ide/widgets/code_editor/sc_editor.cpp

If you need to search for existing brackets in the document, take a look at how TokenIterator class is used, for example in ScCodeEditor::matchBrackets() in the same file. Also take at look at its header file, because it has useful comments about its methods:
/editors/sc-ide/widgets/code_editor/token.hpp

Cheers

@jleben
Copy link
Member

jleben commented Feb 28, 2013

Hmm, couple more thoughts:
Instead of handling key press events directly, it's better to make it an "action" with configurable shortcut.
See MultiEditor::createActions():
/editors/sc-ide/widgets/multi_editor.cpp

The action will need to be connected to the signal multiplexer just as the SelectRegion action, which will distribute the action trigger to whatever editor is currently active. Then you add the corresponding "slot" method to ScCodeEditor where you implement the functionality.

Moreover there are already GotoPreviousBlock and GotoNextBlock actions which will jump to next/previous outer bracket. Maybe it would make sense to rather just add SelectToNextBlock and SelectToPreviousBlock which would do the same, only it would select everything between old cursor position and new position after the jump.

@jleben
Copy link
Member

jleben commented Apr 1, 2013

Done.

@jleben jleben closed this as completed Apr 1, 2013
@mtmccrea
Copy link
Member

Perhaps this should be a new issue, but...

It seems that the functionality is currently selecting a Region not the Enclosed Block. The shortcut assigned to Select Enclosed Block appears to select the Region, while the shortcut for Select Region, doesn't do anything.

SC IDE 3.6.6

@telephon
Copy link
Member

Works as expected here (in 3.7alpha): cmd-shift-R selects region, cmd-shift-B selects block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants