diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-12-27 05:05:41 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-12-27 05:05:41 (GMT) |
commit | 241dc9c454320128dbb2857ae417c7a1c9608f92 (patch) | |
tree | 08509aa5c2d64c2ee5583ea54725c1540b832a38 | |
parent | b3b01c3248825fa510a9b69ecb062c8ebc3422f2 (diff) | |
parent | 246cbf23fa20e7d2533a4bc56ac1deb24d598521 (diff) | |
download | cpython-241dc9c454320128dbb2857ae417c7a1c9608f92.zip cpython-241dc9c454320128dbb2857ae417c7a1c9608f92.tar.gz cpython-241dc9c454320128dbb2857ae417c7a1c9608f92.tar.bz2 |
Merge with 3.6
-rw-r--r-- | Lib/idlelib/colorizer.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py index 7310bb2..7a919f1 100644 --- a/Lib/idlelib/colorizer.py +++ b/Lib/idlelib/colorizer.py @@ -21,7 +21,8 @@ def make_pat(): # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) - stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR|rb|rB|Rb|RB)?" + stringprefix = (r"(\br|R|u|U|f|F|fr|Fr|fR|FR|rf|rF|Rf|RF" + "|b|B|br|Br|bR|BR|rb|rB|Rb|RB)?") sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" @@ -261,8 +262,14 @@ def _color_delegator(parent): # htest # top = Toplevel(parent) top.title("Test ColorDelegator") x, y = map(int, parent.geometry().split('+')[1:]) - top.geometry("200x100+%d+%d" % (x + 250, y + 175)) - source = "if somename: x = 'abc' # comment\nprint\n" + top.geometry("600x200+%d+%d" % (x + 100, y + 175)) + source = ("# Following has syntax errors\n" + "if True: then int 1\nelif False: print 0\nelse: float(None)\n" + "#unicode and byte strings, valid prefixes should be colored\n" + "'x', '''x''', \"x\", \"\"\"x\"\"\"\n" + "r'x', u'x', R'x', U'x', f'x', F'x', ur'is invalid'\n" + "fr'x', Fr'x', fR'x', FR'x', rf'x', rF'x', Rf'x', RF'x'\n" + "b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x'.rB'x',Rb'x',RB'x'\n") text = Text(top, background="white") text.pack(expand=1, fill="both") text.insert("insert", source) |