Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
17f2e4ac
Kaydet (Commit)
17f2e4ac
authored
Tem 05, 2008
tarafından
Facundo Batista
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #3239. Differentiate the ascii call from the curses one and
the builtin one.
üst
083902af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
textpad.py
Lib/curses/textpad.py
+19
-18
No files found.
Lib/curses/textpad.py
Dosyayı görüntüle @
17f2e4ac
"""Simple textbox editing widget with Emacs-like keybindings."""
"""Simple textbox editing widget with Emacs-like keybindings."""
import
curses
,
ascii
import
curses
import
curses.ascii
def
rectangle
(
win
,
uly
,
ulx
,
lry
,
lrx
):
def
rectangle
(
win
,
uly
,
ulx
,
lry
,
lrx
):
"""Draw a rectangle with corners at the provided upper-left
"""Draw a rectangle with corners at the provided upper-left
...
@@ -54,7 +55,7 @@ class Textbox:
...
@@ -54,7 +55,7 @@ class Textbox:
returning the index of the last non-blank character."""
returning the index of the last non-blank character."""
last
=
self
.
maxx
last
=
self
.
maxx
while
True
:
while
True
:
if
ascii
.
ascii
(
self
.
win
.
inch
(
y
,
last
))
!=
ascii
.
SP
:
if
curses
.
ascii
.
ascii
(
self
.
win
.
inch
(
y
,
last
))
!=
curses
.
ascii
.
SP
:
last
=
min
(
self
.
maxx
,
last
+
1
)
last
=
min
(
self
.
maxx
,
last
+
1
)
break
break
elif
last
==
0
:
elif
last
==
0
:
...
@@ -76,7 +77,7 @@ class Textbox:
...
@@ -76,7 +77,7 @@ class Textbox:
pass
pass
if
self
.
insert_mode
:
if
self
.
insert_mode
:
(
backy
,
backx
)
=
self
.
win
.
getyx
()
(
backy
,
backx
)
=
self
.
win
.
getyx
()
if
ascii
.
isprint
(
oldch
):
if
curses
.
ascii
.
isprint
(
oldch
):
self
.
_insert_printable_char
(
oldch
)
self
.
_insert_printable_char
(
oldch
)
self
.
win
.
move
(
backy
,
backx
)
self
.
win
.
move
(
backy
,
backx
)
...
@@ -84,12 +85,12 @@ class Textbox:
...
@@ -84,12 +85,12 @@ class Textbox:
"Process a single editing command."
"Process a single editing command."
(
y
,
x
)
=
self
.
win
.
getyx
()
(
y
,
x
)
=
self
.
win
.
getyx
()
self
.
lastcmd
=
ch
self
.
lastcmd
=
ch
if
ascii
.
isprint
(
ch
):
if
curses
.
ascii
.
isprint
(
ch
):
if
y
<
self
.
maxy
or
x
<
self
.
maxx
:
if
y
<
self
.
maxy
or
x
<
self
.
maxx
:
self
.
_insert_printable_char
(
ch
)
self
.
_insert_printable_char
(
ch
)
elif
ch
==
ascii
.
SOH
:
# ^a
elif
ch
==
curses
.
ascii
.
SOH
:
# ^a
self
.
win
.
move
(
y
,
0
)
self
.
win
.
move
(
y
,
0
)
elif
ch
in
(
ascii
.
STX
,
curses
.
KEY_LEFT
,
ascii
.
BS
,
curses
.
KEY_BACKSPACE
):
elif
ch
in
(
curses
.
ascii
.
STX
,
curses
.
KEY_LEFT
,
curses
.
ascii
.
BS
,
curses
.
KEY_BACKSPACE
):
if
x
>
0
:
if
x
>
0
:
self
.
win
.
move
(
y
,
x
-
1
)
self
.
win
.
move
(
y
,
x
-
1
)
elif
y
==
0
:
elif
y
==
0
:
...
@@ -98,46 +99,46 @@ class Textbox:
...
@@ -98,46 +99,46 @@ class Textbox:
self
.
win
.
move
(
y
-
1
,
self
.
_end_of_line
(
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
(
curses
.
ascii
.
BS
,
curses
.
KEY_BACKSPACE
):
self
.
win
.
delch
()
self
.
win
.
delch
()
elif
ch
==
ascii
.
EOT
:
# ^d
elif
ch
==
curses
.
ascii
.
EOT
:
# ^d
self
.
win
.
delch
()
self
.
win
.
delch
()
elif
ch
==
ascii
.
ENQ
:
# ^e
elif
ch
==
curses
.
ascii
.
ENQ
:
# ^e
if
self
.
stripspaces
:
if
self
.
stripspaces
:
self
.
win
.
move
(
y
,
self
.
_end_of_line
(
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
(
curses
.
ascii
.
ACK
,
curses
.
KEY_RIGHT
):
# ^f
if
x
<
self
.
maxx
:
if
x
<
self
.
maxx
:
self
.
win
.
move
(
y
,
x
+
1
)
self
.
win
.
move
(
y
,
x
+
1
)
elif
y
==
self
.
maxy
:
elif
y
==
self
.
maxy
:
pass
pass
else
:
else
:
self
.
win
.
move
(
y
+
1
,
0
)
self
.
win
.
move
(
y
+
1
,
0
)
elif
ch
==
ascii
.
BEL
:
# ^g
elif
ch
==
curses
.
ascii
.
BEL
:
# ^g
return
0
return
0
elif
ch
==
ascii
.
NL
:
# ^j
elif
ch
==
curses
.
ascii
.
NL
:
# ^j
if
self
.
maxy
==
0
:
if
self
.
maxy
==
0
:
return
0
return
0
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
==
curses
.
ascii
.
VT
:
# ^k
if
x
==
0
and
self
.
_end_of_line
(
y
)
==
0
:
if
x
==
0
and
self
.
_end_of_line
(
y
)
==
0
:
self
.
win
.
deleteln
()
self
.
win
.
deleteln
()
else
:
else
:
# first undo the effect of self._end_of_line
# first undo the effect of self._end_of_line
self
.
win
.
move
(
y
,
x
)
self
.
win
.
move
(
y
,
x
)
self
.
win
.
clrtoeol
()
self
.
win
.
clrtoeol
()
elif
ch
==
ascii
.
FF
:
# ^l
elif
ch
==
curses
.
ascii
.
FF
:
# ^l
self
.
win
.
refresh
()
self
.
win
.
refresh
()
elif
ch
in
(
ascii
.
SO
,
curses
.
KEY_DOWN
):
# ^n
elif
ch
in
(
curses
.
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
):
if
x
>
self
.
_end_of_line
(
y
+
1
):
self
.
win
.
move
(
y
+
1
,
self
.
_end_of_line
(
y
+
1
))
self
.
win
.
move
(
y
+
1
,
self
.
_end_of_line
(
y
+
1
))
elif
ch
==
ascii
.
SI
:
# ^o
elif
ch
==
curses
.
ascii
.
SI
:
# ^o
self
.
win
.
insertln
()
self
.
win
.
insertln
()
elif
ch
in
(
ascii
.
DLE
,
curses
.
KEY_UP
):
# ^p
elif
ch
in
(
curses
.
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
):
if
x
>
self
.
_end_of_line
(
y
-
1
):
...
@@ -155,7 +156,7 @@ class Textbox:
...
@@ -155,7 +156,7 @@ class Textbox:
for
x
in
range
(
self
.
maxx
+
1
):
for
x
in
range
(
self
.
maxx
+
1
):
if
self
.
stripspaces
and
x
>
stop
:
if
self
.
stripspaces
and
x
>
stop
:
break
break
result
=
result
+
chr
(
ascii
.
ascii
(
self
.
win
.
inch
(
y
,
x
)))
result
=
result
+
chr
(
curses
.
ascii
.
ascii
(
self
.
win
.
inch
(
y
,
x
)))
if
self
.
maxy
>
0
:
if
self
.
maxy
>
0
:
result
=
result
+
"
\n
"
result
=
result
+
"
\n
"
return
result
return
result
...
...
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