@@ -60,14 +60,14 @@ class EditorWindow:
60
60
from idlelib .sidebar import LineNumbers
61
61
from idlelib .format import FormatParagraph , FormatRegion , Indents , Rstrip
62
62
from idlelib .parenmatch import ParenMatch
63
- from idlelib .squeezer import Squeezer
64
63
from idlelib .zoomheight import ZoomHeight
65
64
66
65
filesystemencoding = sys .getfilesystemencoding () # for file names
67
66
help_url = None
68
67
69
68
allow_code_context = True
70
69
allow_line_numbers = True
70
+ user_input_insert_tags = None
71
71
72
72
def __init__ (self , flist = None , filename = None , key = None , root = None ):
73
73
# Delay import: runscript imports pyshell imports EditorWindow.
@@ -784,9 +784,7 @@ def _addcolorizer(self):
784
784
self .color = self .ColorDelegator ()
785
785
# can add more colorizers here...
786
786
if self .color :
787
- self .per .removefilter (self .undo )
788
- self .per .insertfilter (self .color )
789
- self .per .insertfilter (self .undo )
787
+ self .per .insertfilterafter (filter = self .color , after = self .undo )
790
788
791
789
def _rmcolorizer (self ):
792
790
if not self .color :
@@ -1303,8 +1301,6 @@ def smart_backspace_event(self, event):
1303
1301
# Debug prompt is multilined....
1304
1302
ncharsdeleted = 0
1305
1303
while 1 :
1306
- if chars == self .prompt_last_line : # '' unless PyShell
1307
- break
1308
1304
chars = chars [:- 1 ]
1309
1305
ncharsdeleted = ncharsdeleted + 1
1310
1306
have = len (chars .expandtabs (tabwidth ))
@@ -1313,7 +1309,8 @@ def smart_backspace_event(self, event):
1313
1309
text .undo_block_start ()
1314
1310
text .delete ("insert-%dc" % ncharsdeleted , "insert" )
1315
1311
if have < want :
1316
- text .insert ("insert" , ' ' * (want - have ))
1312
+ text .insert ("insert" , ' ' * (want - have ),
1313
+ self .user_input_insert_tags )
1317
1314
text .undo_block_stop ()
1318
1315
return "break"
1319
1316
@@ -1346,7 +1343,7 @@ def smart_indent_event(self, event):
1346
1343
effective = len (prefix .expandtabs (self .tabwidth ))
1347
1344
n = self .indentwidth
1348
1345
pad = ' ' * (n - effective % n )
1349
- text .insert ("insert" , pad )
1346
+ text .insert ("insert" , pad , self . user_input_insert_tags )
1350
1347
text .see ("insert" )
1351
1348
return "break"
1352
1349
finally :
@@ -1377,13 +1374,14 @@ def newline_and_indent_event(self, event):
1377
1374
if i == n :
1378
1375
# The cursor is in or at leading indentation in a continuation
1379
1376
# line; just inject an empty line at the start.
1380
- text .insert ("insert linestart" , '\n ' )
1377
+ text .insert ("insert linestart" , '\n ' ,
1378
+ self .user_input_insert_tags )
1381
1379
return "break"
1382
1380
indent = line [:i ]
1383
1381
1384
1382
# Strip whitespace before insert point unless it's in the prompt.
1385
1383
i = 0
1386
- while line and line [- 1 ] in " \t " and line != self . prompt_last_line :
1384
+ while line and line [- 1 ] in " \t " :
1387
1385
line = line [:- 1 ]
1388
1386
i += 1
1389
1387
if i :
@@ -1394,7 +1392,7 @@ def newline_and_indent_event(self, event):
1394
1392
text .delete ("insert" )
1395
1393
1396
1394
# Insert new line.
1397
- text .insert ("insert" , '\n ' )
1395
+ text .insert ("insert" , '\n ' , self . user_input_insert_tags )
1398
1396
1399
1397
# Adjust indentation for continuations and block open/close.
1400
1398
# First need to find the last statement.
@@ -1430,7 +1428,7 @@ def newline_and_indent_event(self, event):
1430
1428
elif c == pyparse .C_STRING_NEXT_LINES :
1431
1429
# Inside a string which started before this line;
1432
1430
# just mimic the current indent.
1433
- text .insert ("insert" , indent )
1431
+ text .insert ("insert" , indent , self . user_input_insert_tags )
1434
1432
elif c == pyparse .C_BRACKET :
1435
1433
# Line up with the first (if any) element of the
1436
1434
# last open bracket structure; else indent one
@@ -1444,7 +1442,8 @@ def newline_and_indent_event(self, event):
1444
1442
# beyond leftmost =; else to beyond first chunk of
1445
1443
# non-whitespace on initial line.
1446
1444
if y .get_num_lines_in_stmt () > 1 :
1447
- text .insert ("insert" , indent )
1445
+ text .insert ("insert" , indent ,
1446
+ self .user_input_insert_tags )
1448
1447
else :
1449
1448
self .reindent_to (y .compute_backslash_indent ())
1450
1449
else :
@@ -1455,7 +1454,7 @@ def newline_and_indent_event(self, event):
1455
1454
# indentation of initial line of closest preceding
1456
1455
# interesting statement.
1457
1456
indent = y .get_base_indent_string ()
1458
- text .insert ("insert" , indent )
1457
+ text .insert ("insert" , indent , self . user_input_insert_tags )
1459
1458
if y .is_block_opener ():
1460
1459
self .smart_indent_event (event )
1461
1460
elif indent and y .is_block_closer ():
@@ -1502,7 +1501,8 @@ def reindent_to(self, column):
1502
1501
if text .compare ("insert linestart" , "!=" , "insert" ):
1503
1502
text .delete ("insert linestart" , "insert" )
1504
1503
if column :
1505
- text .insert ("insert" , self ._make_blanks (column ))
1504
+ text .insert ("insert" , self ._make_blanks (column ),
1505
+ self .user_input_insert_tags )
1506
1506
text .undo_block_stop ()
1507
1507
1508
1508
# Guess indentwidth from text content.
0 commit comments