diff --git a/Lib/idlelib/config-extensions.def b/Lib/idlelib/config-extensions.def index e8d417bac0d497d..330ab535f270922 100644 --- a/Lib/idlelib/config-extensions.def +++ b/Lib/idlelib/config-extensions.def @@ -19,7 +19,7 @@ max-width= 72 style= expression flash-delay= 500 bell= True - +highlighting = hilite # IDLE reads several config files to determine user preferences. This # file is the default configuration file for IDLE extensions settings. # diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 683c36e9776c28d..84df13f1137ff2d 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -1775,6 +1775,8 @@ def create_page_general(self): StringVar(self), ('extensions', 'AutoComplete', 'popupwait')) self.paren_style = tracers.add( StringVar(self), ('extensions', 'ParenMatch', 'style')) + self.paren_highlight = tracers.add( + StringVar(self), ('extensions', 'ParenMatch', 'highlight')) self.flash_delay = tracers.add( StringVar(self), ('extensions', 'ParenMatch', 'flash-delay')) self.paren_bell = tracers.add( @@ -1826,6 +1828,12 @@ def create_page_general(self): self.paren_style_type = OptionMenu( frame_paren1, self.paren_style, 'expression', "opener","parens","expression") + paren_highlight_title = Label(frame_paren1, + text=' Paren Match Colors') + self.paren_highlight_type = OptionMenu( + frame_paren1, self.paren_highlight, 'hilite', + 'normal','keyword','definition','builtin','comment','string', + 'hilite','hit','cursor','break','stdout','stderr') frame_paren2 = Frame(frame_window, borderwidth=0) paren_time_title = Label( frame_paren2, text='Time Match Displayed (milliseconds)\n' @@ -1900,8 +1908,10 @@ def create_page_general(self): self.auto_wait_int.pack(side=TOP, padx=10, pady=5) # frame_paren. frame_paren1.pack(side=TOP, padx=5, pady=0, fill=X) - paren_style_title.pack(side=LEFT, anchor=W, padx=5, pady=5) - self.paren_style_type.pack(side=TOP, padx=10, pady=5) + paren_style_title.pack(side=LEFT, anchor=W, padx=5, pady=0) + self.paren_style_type.pack(side=LEFT, padx=5, pady=0) + paren_highlight_title.pack(side=LEFT, anchor=W, padx=5, pady=0) + self.paren_highlight_type.pack(side=LEFT, padx=5, pady=0) frame_paren2.pack(side=TOP, padx=5, pady=0, fill=X) paren_time_title.pack(side=LEFT, anchor=W, padx=5) self.bell_on.pack(side=RIGHT, anchor=E, padx=15, pady=5) @@ -1943,6 +1953,8 @@ def load_general_cfg(self): 'extensions', 'AutoComplete', 'popupwait', type='int')) self.paren_style.set(idleConf.GetOption( 'extensions', 'ParenMatch', 'style')) + self.paren_highlight.set(idleConf.GetOption( + 'extensions', 'ParenMatch', 'highlight')) self.flash_delay.set(idleConf.GetOption( 'extensions', 'ParenMatch', 'flash-delay', type='int')) self.paren_bell.set(idleConf.GetOption( diff --git a/Lib/idlelib/idle_test/test_parenmatch.py b/Lib/idlelib/idle_test/test_parenmatch.py index 6943a70c997c1c7..c394af27d3183fe 100644 --- a/Lib/idlelib/idle_test/test_parenmatch.py +++ b/Lib/idlelib/idle_test/test_parenmatch.py @@ -6,7 +6,6 @@ from idlelib.parenmatch import ParenMatch from test.support import requires requires('gui') - import unittest from unittest.mock import Mock from tkinter import Tk, Text @@ -53,28 +52,26 @@ def test_paren_styles(self): pm = self.get_parenmatch() for style, range1, range2 in ( ('opener', ('1.10', '1.11'), ('1.10', '1.11')), - ('default',('1.10', '1.11'),('1.10', '1.11')), + ('default', ('1.10', '1.11'), ('1.10', '1.11')), ('parens', ('1.14', '1.15'), ('1.15', '1.16')), ('expression', ('1.10', '1.15'), ('1.10', '1.16'))): with self.subTest(style=style): text.delete('1.0', 'end') pm.set_style(style) text.insert('insert', 'def foobar(a, b') - pm.flash_paren_event('event') - self.assertIn('<>', text.event_info()) + self.assertIn('<>', + text.event_info()) if style == 'parens': self.assertTupleEqual(text.tag_nextrange('paren', '1.0'), ('1.10', '1.11')) self.assertTupleEqual( text.tag_prevrange('paren', 'end'), range1) - text.insert('insert', ')') pm.restore_event() self.assertNotIn('<>', text.event_info()) self.assertEqual(text.tag_prevrange('paren', 'end'), ()) - pm.paren_closed_event('event') self.assertTupleEqual( text.tag_prevrange('paren', 'end'), range2) @@ -87,14 +84,11 @@ def test_paren_corner(self): """ text = self.text pm = self.get_parenmatch() - text.insert('insert', '# this is a commen)') pm.paren_closed_event('event') - text.insert('insert', '\ndef') pm.flash_paren_event('event') pm.paren_closed_event('event') - text.insert('insert', ' a, *arg)') pm.paren_closed_event('event') diff --git a/Lib/idlelib/parenmatch.py b/Lib/idlelib/parenmatch.py index 12212150c6dc8eb..1c2b93a0a3b366b 100644 --- a/Lib/idlelib/parenmatch.py +++ b/Lib/idlelib/parenmatch.py @@ -7,8 +7,9 @@ from idlelib.hyperparser import HyperParser from idlelib.config import idleConf -_openers = {')':'(',']':'[','}':'{'} -CHECK_DELAY = 100 # milliseconds +_openers = {')': '(', ']': '[', '}': '{'} +CHECK_DELAY = 100 # milliseconds + class ParenMatch: """Highlight matching openers and closers, (), [], and {}. @@ -53,13 +54,17 @@ def __init__(self, editwin): @classmethod def reload(cls): cls.STYLE = idleConf.GetOption( - 'extensions','ParenMatch','style', default='opener') + 'extensions', 'ParenMatch', 'style', default='opener') cls.FLASH_DELAY = idleConf.GetOption( - 'extensions','ParenMatch','flash-delay', type='int',default=500) + 'extensions', 'ParenMatch', 'flash-delay', type='int', + default=500) cls.BELL = idleConf.GetOption( - 'extensions','ParenMatch','bell', type='bool', default=1) - cls.HILITE_CONFIG = idleConf.GetHighlight(idleConf.CurrentTheme(), - 'hilite') + 'extensions', 'ParenMatch', 'bell', type='bool', default=1) + cls.HILITE_CONFIG = idleConf.GetHighlight( + idleConf.CurrentTheme(), idleConf.GetOption( + 'extensions', 'ParenMatch', 'highlighting', type='string', + default='hilite') + ) def activate_restore(self): "Activate mechanism to restore text from highlighting." @@ -140,7 +145,8 @@ def create_tag_parens(self, indices): rightindex = indices[1]+"+1c" else: rightindex = indices[1] - self.text.tag_add("paren", indices[0], indices[0]+"+1c", rightindex+"-1c", rightindex) + self.text.tag_add("paren", indices[0], indices[0] + "+1c", + rightindex + "-1c", rightindex) self.text.tag_config("paren", self.HILITE_CONFIG) def create_tag_expression(self, indices): @@ -162,6 +168,7 @@ def set_timeout_none(self): # if the event is for the most recent timer and the insert has changed, # or schedules another call for itself. self.counter += 1 + def callme(callme, self=self, c=self.counter, index=self.text.index("insert")): if index != self.text.index("insert"): @@ -171,7 +178,8 @@ def callme(callme, self=self, c=self.counter, self.editwin.text_frame.after(CHECK_DELAY, callme, callme) def set_timeout_last(self): - """The last highlight created will be removed after FLASH_DELAY millisecs""" + """The last highlight created will be removed + after FLASH_DELAY millisecs""" # associate a counter with an event; only disable the "paren" # tag if the event is for the most recent timer. self.counter += 1 diff --git a/Tools/ssl/multissltests.py b/Tools/ssl/multissltests.py old mode 100755 new mode 100644