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
090d6eb5
Commit
090d6eb5
authored
Aug 04, 2000
by
Eric S. Raymond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected a bug in handling of ^N and ^P with stripspaces on.
parent
58d131e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
Lib/curses/textpad.py
Lib/curses/textpad.py
+12
-8
No files found.
Lib/curses/textpad.py
View file @
090d6eb5
...
@@ -20,13 +20,13 @@ class Textbox:
...
@@ -20,13 +20,13 @@ class Textbox:
Ctrl-A Go to left edge of window.
Ctrl-A Go to left edge of window.
Ctrl-B Cursor left, wrapping to previous line if appropriate.
Ctrl-B Cursor left, wrapping to previous line if appropriate.
Ctrl-D Delete character under cursor.
Ctrl-D Delete character under cursor.
Ctrl-E Go to right edge (
nospaces off) or end of line (no
spaces on).
Ctrl-E Go to right edge (
stripspaces off) or end of line (strip
spaces on).
Ctrl-F Cursor right, wrapping to next line when appropriate.
Ctrl-F Cursor right, wrapping to next line when appropriate.
Ctrl-G Terminate, returning the window contents.
Ctrl-G Terminate, returning the window contents.
Ctrl-H Delete character backward.
Ctrl-H Delete character backward.
Ctrl-J Terminate if the window is 1 line, otherwise insert newline.
Ctrl-J Terminate if the window is 1 line, otherwise insert newline.
Ctrl-K If line is blank, delete it, otherwise clear to end of line.
Ctrl-K If line is blank, delete it, otherwise clear to end of line.
Ctrl-L Refresh screen
Ctrl-L Refresh screen
.
Ctrl-N Cursor down; move down one line.
Ctrl-N Cursor down; move down one line.
Ctrl-O Insert a blank line at cursor location.
Ctrl-O Insert a blank line at cursor location.
Ctrl-P Cursor up; move up one line.
Ctrl-P Cursor up; move up one line.
...
@@ -46,7 +46,7 @@ class Textbox:
...
@@ -46,7 +46,7 @@ class Textbox:
self
.
lastcmd
=
None
self
.
lastcmd
=
None
win
.
keypad
(
1
)
win
.
keypad
(
1
)
def
firstblank
(
self
,
y
):
def
_end_of_line
(
self
,
y
):
"Go to the location of the first blank on the given line."
"Go to the location of the first blank on the given line."
last
=
self
.
maxx
last
=
self
.
maxx
while
1
:
while
1
:
...
@@ -79,7 +79,7 @@ class Textbox:
...
@@ -79,7 +79,7 @@ class Textbox:
elif
y
==
0
:
elif
y
==
0
:
pass
pass
elif
self
.
stripspaces
:
elif
self
.
stripspaces
:
self
.
win
.
move
(
y
-
1
,
self
.
firstblank
(
y
-
1
))
self
.
win
.
move
(
y
-
1
,
self
.
_end_of_line
(
y
-
1
))
else
:
else
:
self
.
win
.
move
(
y
-
1
,
self
.
maxx
)
self
.
win
.
move
(
y
-
1
,
self
.
maxx
)
if
ch
in
(
ascii
.
BS
,
curses
.
KEY_BACKSPACE
):
if
ch
in
(
ascii
.
BS
,
curses
.
KEY_BACKSPACE
):
...
@@ -88,7 +88,7 @@ class Textbox:
...
@@ -88,7 +88,7 @@ class Textbox:
self
.
win
.
delch
()
self
.
win
.
delch
()
elif
ch
==
ascii
.
ENQ
:
# ^e
elif
ch
==
ascii
.
ENQ
:
# ^e
if
self
.
stripspaces
:
if
self
.
stripspaces
:
self
.
win
.
move
(
y
,
self
.
firstblank
(
y
))
self
.
win
.
move
(
y
,
self
.
_end_of_line
(
y
))
else
:
else
:
self
.
win
.
move
(
y
,
self
.
maxx
)
self
.
win
.
move
(
y
,
self
.
maxx
)
elif
ch
in
(
ascii
.
ACK
,
curses
.
KEY_RIGHT
):
# ^f
elif
ch
in
(
ascii
.
ACK
,
curses
.
KEY_RIGHT
):
# ^f
...
@@ -106,7 +106,7 @@ class Textbox:
...
@@ -106,7 +106,7 @@ class Textbox:
elif
y
<
self
.
maxy
:
elif
y
<
self
.
maxy
:
self
.
win
.
move
(
y
+
1
,
0
)
self
.
win
.
move
(
y
+
1
,
0
)
elif
ch
==
ascii
.
VT
:
# ^k
elif
ch
==
ascii
.
VT
:
# ^k
if
x
==
0
and
self
.
firstblank
(
y
)
==
0
:
if
x
==
0
and
self
.
_end_of_line
(
y
)
==
0
:
self
.
win
.
deleteln
()
self
.
win
.
deleteln
()
else
:
else
:
self
.
win
.
clrtoeol
()
self
.
win
.
clrtoeol
()
...
@@ -115,11 +115,15 @@ class Textbox:
...
@@ -115,11 +115,15 @@ class Textbox:
elif
ch
in
(
ascii
.
SO
,
curses
.
KEY_DOWN
):
# ^n
elif
ch
in
(
ascii
.
SO
,
curses
.
KEY_DOWN
):
# ^n
if
y
<
self
.
maxy
:
if
y
<
self
.
maxy
:
self
.
win
.
move
(
y
+
1
,
x
)
self
.
win
.
move
(
y
+
1
,
x
)
if
x
>
self
.
_end_of_line
(
y
+
1
):
self
.
win
.
move
(
y
+
1
,
self
.
_end_of_line
(
y
+
1
))
elif
ch
==
ascii
.
SI
:
# ^o
elif
ch
==
ascii
.
SI
:
# ^o
self
.
win
.
insertln
()
self
.
win
.
insertln
()
elif
ch
in
(
ascii
.
DLE
,
curses
.
KEY_UP
):
# ^p
elif
ch
in
(
ascii
.
DLE
,
curses
.
KEY_UP
):
# ^p
if
y
>
0
:
if
y
>
0
:
self
.
win
.
move
(
y
-
1
,
x
)
self
.
win
.
move
(
y
-
1
,
x
)
if
x
>
self
.
_end_of_line
(
y
-
1
):
self
.
win
.
move
(
y
-
1
,
self
.
_end_of_line
(
y
-
1
))
return
1
return
1
def
gather
(
self
):
def
gather
(
self
):
...
@@ -127,8 +131,8 @@ class Textbox:
...
@@ -127,8 +131,8 @@ class Textbox:
result
=
""
result
=
""
for
y
in
range
(
self
.
maxy
+
1
):
for
y
in
range
(
self
.
maxy
+
1
):
self
.
win
.
move
(
y
,
0
)
self
.
win
.
move
(
y
,
0
)
stop
=
self
.
firstblank
(
y
)
stop
=
self
.
_end_of_line
(
y
)
#sys.stderr.write("y=%d,
firstblank
(y)=%d\n" % (y, stop))
#sys.stderr.write("y=%d,
_end_of_line
(y)=%d\n" % (y, stop))
if
stop
==
0
and
self
.
stripspaces
:
if
stop
==
0
and
self
.
stripspaces
:
continue
continue
for
x
in
range
(
self
.
maxx
+
1
):
for
x
in
range
(
self
.
maxx
+
1
):
...
...
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