Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
33f2b7b2
Commit
33f2b7b2
authored
Jan 03, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added something like Tim Peters' backspace patch.
parent
0c65e250
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
Tools/idle/AutoIndent.py
Tools/idle/AutoIndent.py
+28
-2
No files found.
Tools/idle/AutoIndent.py
View file @
33f2b7b2
...
...
@@ -47,8 +47,12 @@ class AutoIndent:
]),
]
windows_keydefs
=
{
keydefs
=
{
'<<smart-backspace>>'
:
[
'<Key-BackSpace>'
],
'<<newline-and-indent>>'
:
[
'<Key-Return>'
,
'<KP_Enter>'
],
}
windows_keydefs
=
{
'<<indent-region>>'
:
[
'<Control-bracketright>'
],
'<<dedent-region>>'
:
[
'<Control-bracketleft>'
],
'<<comment-region>>'
:
[
'<Alt-Key-3>'
],
...
...
@@ -58,7 +62,6 @@ class AutoIndent:
}
unix_keydefs
=
{
'<<newline-and-indent>>'
:
[
'<Key-Return>'
,
'<KP_Enter>'
],
'<<indent-region>>'
:
[
'<Alt-bracketright>'
,
'<Meta-bracketright>'
,
'<Control-bracketright>'
],
...
...
@@ -86,6 +89,29 @@ class AutoIndent:
else
:
raise
KeyError
,
"bad option name: %s"
%
`key`
def
smart_backspace_event
(
self
,
event
):
text
=
self
.
text
try
:
first
=
text
.
index
(
"sel.first"
)
last
=
text
.
index
(
"sel.last"
)
except
TclError
:
first
=
last
=
None
if
first
and
last
:
text
.
delete
(
first
,
last
)
text
.
mark_set
(
"insert"
,
first
)
return
"break"
# After Tim Peters
ndelete
=
1
chars
=
text
.
get
(
"insert linestart"
,
"insert"
)
i
=
0
n
=
len
(
chars
)
while
i
<
n
and
chars
[
i
]
in
"
\
t
"
:
i
=
i
+
1
if
i
==
n
and
chars
[
-
4
:]
==
" "
:
ndelete
=
4
text
.
delete
(
"insert - %d chars"
%
ndelete
,
"insert"
)
return
"break"
def
newline_and_indent_event
(
self
,
event
):
text
=
self
.
text
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment