Repository navigation
gh-63075: IDLE editor - Auto insertion of the closers #3520
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
Changes from 1 commit
5c57faf
d49170f
8c3a966
757bb38
d7e136c
b178af5
2adebb9
86c3d4c
1c246fc
0418ad0
097a0d8
4232e77
a7b29f5
e30b7b4
252672b
999b573
1a74591
3501c45
232f711
f095c53
a661bfa
5c90a8f
5a6a007
709b434
b9b1f9a
8b76ccb
b986c12
f86acaa
5805462
165b548
aee5d02
cb161bd
dc09a2b
100463e
3fbaa90
60ff82f
e3f6f16
a253f0c
fe8eb7a
caa7774
c29184e
c62f726
d0e009f
9e889c2
6afdea3
7de27db
a2e76a7
2265b53
03eed24
207b0ca
00acd22
2d2bfbd
fe76cd3
d2966e0
6845bb0
b7afebb
b1a4101
7a53366
d3b6848
eb58d39
119bbfc
814efbe
7f596b9
26323e2
7862d8a
2f19ca8
6d2fa26
15f8d82
d141abc
caa9240
21f4482
25ba0f8
a4cd0e3
cffa9d6
9aaa395
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
copied wrong file to wrong place between where I can test code and my git folder.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| Author: Charles M. Wohlganger | ||
| charles.wohlganger@gmail.com | ||
|
|
||
| Last Updated: 12-Aug-2017 by Charles Wohlganger | ||
| Last Updated: 13-Aug-2017 by Charles Wohlganger | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove. Already obsolete. The git log has revision history. |
||
|
|
||
| Add to the end of config-extensions.def : | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Config options will be added to config-general.def. The general tab already needs to be split for another issue. This issue, and a complete patch, will depend on how we do that, and then how to lay out the option buttons. |
||
|
|
||
|
|
@@ -19,7 +19,7 @@ | |
| comment_space = True | ||
| [ParenClose_cfgBindings] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete section. Not needed for hard-coded features. |
||
| p-open = <Key-parenleft> <Key-bracketleft> <Key-braceleft> | ||
| t-open = <Key-'> <Key-"> | ||
| t-open = <Key-quotedbl> <Key-quoteright> | ||
| p-close = <Key-parenright> <Key-bracketright> <Key-braceright> | ||
|
terryjreedy marked this conversation as resolved.
|
||
|
|
||
| """ | ||
|
|
@@ -37,54 +37,44 @@ class ParenClose: | |
| symbol is typed and the same one is to the right of it, that symbols is | ||
| deleted before the new one is typed, effectively skipping over the closure. | ||
| ''' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand these. |
||
| def __init__(self, editwin=None): #setting default to none makes testing easier | ||
| def __init__(self, editwin=None): # Setting default to none makes testing easier. | ||
| if editwin: | ||
| self.text = editwin.text | ||
| else: | ||
| self.text=None | ||
| self.paren_close = idleConf.GetOption( | ||
| 'extensions', 'ParenClose', 'paren_close', default=True) | ||
| 'extensions', 'ParenClose', 'paren_close', type = bool, default=True) | ||
| self.tick_close = idleConf.GetOption( | ||
| 'extensions', 'ParenClose', 'tick_close', default=True) | ||
| 'extensions', 'ParenClose', 'tick_close', type = bool, default=True) | ||
| self.skip_closures = idleConf.GetOption( | ||
| 'extensions', 'ParenClose', 'skip_closures', default=True) | ||
| #sometimes idleConf loads boolean False as string "False" | ||
| if self.paren_close == 'False': | ||
| self.paren_close = False | ||
| if self.tick_close == 'False': | ||
| self.tick_close = False | ||
| if self.skip_closures == 'False': | ||
| self.skip_closures = False | ||
| 'extensions', 'ParenClose', 'skip_closures', type = bool, default=True) | ||
|
|
||
| def p_open_event(self, event): | ||
| if self.paren_close: | ||
| closer = {'(': ')', '[': ']', '{': '}'}[event.char] | ||
| closer = {'(': ')', '[': ']', '{': '}', "'":"'", '"':'"'}[event.char] | ||
| pos = self.text.index('insert') | ||
| self.text.insert(pos, closer) | ||
| self.text.mark_set('insert', pos) | ||
|
|
||
| def p_close_event(self, event): | ||
| pos = self.text.index('insert') | ||
| if self.skip_closures \ | ||
| and self.text.get(pos, pos + ' +1c') == event.char: | ||
| self.text.delete(pos, pos + '+1c') | ||
| return True | ||
| return False | ||
|
|
||
| def t_open_event(self, event): | ||
| if self.tick_close: | ||
| pos = self.text.index('insert') | ||
| if self.text.get(pos + ' -2c', pos) == event.char * 2 \ | ||
| and self.text.get(pos, pos + ' +1c') != event.char: | ||
| # Instead of one tick, add two ticks if there are two; | ||
| # Instead of one tick, add three ticks if there are two; | ||
| # user wants to make docstring or multiline. | ||
| self.text.insert(pos, event.char * 3) | ||
| self.text.mark_set('insert', pos) | ||
| else: | ||
| if self.skip_closures \ | ||
| and self.text.get(pos, pos + ' +1c') == event.char: | ||
| self.text.delete(pos, pos + ' +1c') | ||
| else: | ||
| self.text.insert(pos, event.char) | ||
| self.text.mark_set('insert', pos) | ||
| elif not self.p_close_event(event): | ||
| self.p_open_event(event) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not yet looked at the instance method code. |
||
|
|
||
| if __name__ == '__main__': | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already in parenmatch. |
||
| import unittest | ||
|
|
||
This file was deleted.
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.
Remove. This already has input from 3 other people. I will list Charles as original author in the news entry.