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
3c8045ac
Kaydet (Commit)
3c8045ac
authored
Agu 16, 1991
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added activate/deactivate.
minsize --> getminsize. Added 'boxed' option. Added lost of code to realize (?)
üst
9b1bfc88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
22 deletions
+146
-22
TextEdit.py
Lib/lib-stdwin/TextEdit.py
+73
-11
TextEdit.py
Lib/stdwin/TextEdit.py
+73
-11
No files found.
Lib/lib-stdwin/TextEdit.py
Dosyayı görüntüle @
3c8045ac
# Text editing widget
# Text editing widget
# NB: this always assumes fixed bounds.
# For auto-growing TextEdit windows, different code would be needed.
from
stdwinevents
import
*
from
stdwinevents
import
*
class
TextEdit
():
class
TextEdit
():
...
@@ -11,7 +14,14 @@ class TextEdit():
...
@@ -11,7 +14,14 @@ class TextEdit():
self
.
rows
=
rows
self
.
rows
=
rows
self
.
text
=
''
self
.
text
=
''
# Creation of the editor is done in realize()
# Creation of the editor is done in realize()
self
.
editor
=
0
self
.
editor
=
None
self
.
dh
=
self
.
dv
=
0
return
self
#
def
createboxed
(
self
,
(
parent
,
(
cols
,
rows
),
(
dh
,
dv
))):
self
=
self
.
create
(
parent
,
(
cols
,
rows
))
self
.
dh
=
max
(
0
,
dh
)
self
.
dv
=
max
(
0
,
dv
)
return
self
return
self
#
#
def
settext
(
self
,
text
):
def
settext
(
self
,
text
):
...
@@ -24,26 +34,69 @@ class TextEdit():
...
@@ -24,26 +34,69 @@ class TextEdit():
del
self
.
editor
del
self
.
editor
del
self
.
window
del
self
.
window
#
#
def
minsize
(
self
,
m
):
def
getminsize
(
self
,
(
m
,
(
width
,
height
))):
return
self
.
cols
*
m
.
textwidth
(
'in'
)
/
2
,
self
.
rows
*
m
.
lineheight
()
width
=
max
(
0
,
width
-
2
*
self
.
dh
)
height
=
max
(
0
,
height
-
2
*
self
.
dv
)
if
width
>
0
and
self
.
editor
:
(
left
,
top
),
(
right
,
bottom
)
=
self
.
editor
.
getrect
()
act_width
,
act_height
=
right
-
left
,
bottom
-
top
if
width
>=
act_width
:
width
=
width
+
2
*
self
.
dh
height
=
max
(
height
,
act_height
)
+
2
*
self
.
dv
return
width
,
height
width
=
max
(
width
,
self
.
cols
*
m
.
textwidth
(
'in'
)
/
2
)
+
2
*
self
.
dh
height
=
max
(
height
,
self
.
rows
*
m
.
lineheight
())
+
2
*
self
.
dv
return
width
,
height
#
def
setbounds
(
self
,
bounds
):
def
setbounds
(
self
,
bounds
):
self
.
bounds
=
bounds
self
.
bounds
=
bounds
if
self
.
editor
:
if
self
.
editor
:
self
.
editor
.
move
(
bounds
)
(
left
,
top
),
(
right
,
bottom
)
=
bounds
def
getbounds
(
self
,
bounds
):
left
=
left
+
self
.
dh
if
self
.
editor
:
top
=
top
+
self
.
dv
return
self
.
editor
.
getrect
()
right
=
right
-
self
.
dh
else
:
bottom
=
bottom
-
self
.
dv
return
self
.
bounds
self
.
editor
.
move
((
left
,
top
),
(
right
,
bottom
))
if
self
.
dh
and
self
.
dv
:
(
left
,
top
),
(
right
,
bottom
)
=
bounds
left
=
left
+
1
top
=
top
+
1
right
=
right
-
1
bottom
=
bottom
-
1
bounds
=
(
left
,
top
),
(
right
,
bottom
)
self
.
editor
.
setview
(
bounds
)
#
def
getbounds
(
self
):
return
self
.
bounds
#
def
realize
(
self
):
def
realize
(
self
):
self
.
window
=
self
.
parent
.
getwindow
()
self
.
window
=
self
.
parent
.
getwindow
()
self
.
editor
=
self
.
window
.
textcreate
(
self
.
bounds
)
(
left
,
top
),
(
right
,
bottom
)
=
self
.
bounds
left
=
left
+
self
.
dh
top
=
top
+
self
.
dv
right
=
right
-
self
.
dh
bottom
=
bottom
-
self
.
dv
self
.
editor
=
\
self
.
window
.
textcreate
((
left
,
top
),
(
right
,
bottom
))
self
.
editor
.
setactive
(
0
)
bounds
=
self
.
bounds
if
self
.
dh
and
self
.
dv
:
(
left
,
top
),
(
right
,
bottom
)
=
bounds
left
=
left
+
1
top
=
top
+
1
right
=
right
-
1
bottom
=
bottom
-
1
bounds
=
(
left
,
top
),
(
right
,
bottom
)
self
.
editor
.
setview
(
bounds
)
self
.
editor
.
settext
(
self
.
text
)
self
.
editor
.
settext
(
self
.
text
)
self
.
parent
.
need_mouse
(
self
)
self
.
parent
.
need_mouse
(
self
)
self
.
parent
.
need_keybd
(
self
)
self
.
parent
.
need_keybd
(
self
)
self
.
parent
.
need_altdraw
(
self
)
self
.
parent
.
need_altdraw
(
self
)
#
def
draw
(
self
,
(
d
,
area
)):
def
draw
(
self
,
(
d
,
area
)):
pass
if
self
.
dh
and
self
.
dv
:
d
.
box
(
self
.
bounds
)
#
def
altdraw
(
self
,
area
):
def
altdraw
(
self
,
area
):
self
.
editor
.
draw
(
area
)
self
.
editor
.
draw
(
area
)
#
#
...
@@ -51,11 +104,20 @@ class TextEdit():
...
@@ -51,11 +104,20 @@ class TextEdit():
#
#
def
mouse_down
(
self
,
detail
):
def
mouse_down
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_DOWN
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_DOWN
,
self
.
window
,
detail
)
#
def
mouse_move
(
self
,
detail
):
def
mouse_move
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_MOVE
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_MOVE
,
self
.
window
,
detail
)
#
def
mouse_up
(
self
,
detail
):
def
mouse_up
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_UP
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_UP
,
self
.
window
,
detail
)
#
#
def
keybd
(
self
,
(
type
,
detail
)):
def
keybd
(
self
,
(
type
,
detail
)):
x
=
self
.
editor
.
event
(
type
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
type
,
self
.
window
,
detail
)
#
#
def
activate
(
self
):
self
.
editor
.
setfocus
(
0
,
30000
)
self
.
editor
.
setactive
(
1
)
#
def
deactivate
(
self
):
self
.
editor
.
setactive
(
0
)
#
Lib/stdwin/TextEdit.py
Dosyayı görüntüle @
3c8045ac
# Text editing widget
# Text editing widget
# NB: this always assumes fixed bounds.
# For auto-growing TextEdit windows, different code would be needed.
from
stdwinevents
import
*
from
stdwinevents
import
*
class
TextEdit
():
class
TextEdit
():
...
@@ -11,7 +14,14 @@ class TextEdit():
...
@@ -11,7 +14,14 @@ class TextEdit():
self
.
rows
=
rows
self
.
rows
=
rows
self
.
text
=
''
self
.
text
=
''
# Creation of the editor is done in realize()
# Creation of the editor is done in realize()
self
.
editor
=
0
self
.
editor
=
None
self
.
dh
=
self
.
dv
=
0
return
self
#
def
createboxed
(
self
,
(
parent
,
(
cols
,
rows
),
(
dh
,
dv
))):
self
=
self
.
create
(
parent
,
(
cols
,
rows
))
self
.
dh
=
max
(
0
,
dh
)
self
.
dv
=
max
(
0
,
dv
)
return
self
return
self
#
#
def
settext
(
self
,
text
):
def
settext
(
self
,
text
):
...
@@ -24,26 +34,69 @@ class TextEdit():
...
@@ -24,26 +34,69 @@ class TextEdit():
del
self
.
editor
del
self
.
editor
del
self
.
window
del
self
.
window
#
#
def
minsize
(
self
,
m
):
def
getminsize
(
self
,
(
m
,
(
width
,
height
))):
return
self
.
cols
*
m
.
textwidth
(
'in'
)
/
2
,
self
.
rows
*
m
.
lineheight
()
width
=
max
(
0
,
width
-
2
*
self
.
dh
)
height
=
max
(
0
,
height
-
2
*
self
.
dv
)
if
width
>
0
and
self
.
editor
:
(
left
,
top
),
(
right
,
bottom
)
=
self
.
editor
.
getrect
()
act_width
,
act_height
=
right
-
left
,
bottom
-
top
if
width
>=
act_width
:
width
=
width
+
2
*
self
.
dh
height
=
max
(
height
,
act_height
)
+
2
*
self
.
dv
return
width
,
height
width
=
max
(
width
,
self
.
cols
*
m
.
textwidth
(
'in'
)
/
2
)
+
2
*
self
.
dh
height
=
max
(
height
,
self
.
rows
*
m
.
lineheight
())
+
2
*
self
.
dv
return
width
,
height
#
def
setbounds
(
self
,
bounds
):
def
setbounds
(
self
,
bounds
):
self
.
bounds
=
bounds
self
.
bounds
=
bounds
if
self
.
editor
:
if
self
.
editor
:
self
.
editor
.
move
(
bounds
)
(
left
,
top
),
(
right
,
bottom
)
=
bounds
def
getbounds
(
self
,
bounds
):
left
=
left
+
self
.
dh
if
self
.
editor
:
top
=
top
+
self
.
dv
return
self
.
editor
.
getrect
()
right
=
right
-
self
.
dh
else
:
bottom
=
bottom
-
self
.
dv
return
self
.
bounds
self
.
editor
.
move
((
left
,
top
),
(
right
,
bottom
))
if
self
.
dh
and
self
.
dv
:
(
left
,
top
),
(
right
,
bottom
)
=
bounds
left
=
left
+
1
top
=
top
+
1
right
=
right
-
1
bottom
=
bottom
-
1
bounds
=
(
left
,
top
),
(
right
,
bottom
)
self
.
editor
.
setview
(
bounds
)
#
def
getbounds
(
self
):
return
self
.
bounds
#
def
realize
(
self
):
def
realize
(
self
):
self
.
window
=
self
.
parent
.
getwindow
()
self
.
window
=
self
.
parent
.
getwindow
()
self
.
editor
=
self
.
window
.
textcreate
(
self
.
bounds
)
(
left
,
top
),
(
right
,
bottom
)
=
self
.
bounds
left
=
left
+
self
.
dh
top
=
top
+
self
.
dv
right
=
right
-
self
.
dh
bottom
=
bottom
-
self
.
dv
self
.
editor
=
\
self
.
window
.
textcreate
((
left
,
top
),
(
right
,
bottom
))
self
.
editor
.
setactive
(
0
)
bounds
=
self
.
bounds
if
self
.
dh
and
self
.
dv
:
(
left
,
top
),
(
right
,
bottom
)
=
bounds
left
=
left
+
1
top
=
top
+
1
right
=
right
-
1
bottom
=
bottom
-
1
bounds
=
(
left
,
top
),
(
right
,
bottom
)
self
.
editor
.
setview
(
bounds
)
self
.
editor
.
settext
(
self
.
text
)
self
.
editor
.
settext
(
self
.
text
)
self
.
parent
.
need_mouse
(
self
)
self
.
parent
.
need_mouse
(
self
)
self
.
parent
.
need_keybd
(
self
)
self
.
parent
.
need_keybd
(
self
)
self
.
parent
.
need_altdraw
(
self
)
self
.
parent
.
need_altdraw
(
self
)
#
def
draw
(
self
,
(
d
,
area
)):
def
draw
(
self
,
(
d
,
area
)):
pass
if
self
.
dh
and
self
.
dv
:
d
.
box
(
self
.
bounds
)
#
def
altdraw
(
self
,
area
):
def
altdraw
(
self
,
area
):
self
.
editor
.
draw
(
area
)
self
.
editor
.
draw
(
area
)
#
#
...
@@ -51,11 +104,20 @@ class TextEdit():
...
@@ -51,11 +104,20 @@ class TextEdit():
#
#
def
mouse_down
(
self
,
detail
):
def
mouse_down
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_DOWN
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_DOWN
,
self
.
window
,
detail
)
#
def
mouse_move
(
self
,
detail
):
def
mouse_move
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_MOVE
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_MOVE
,
self
.
window
,
detail
)
#
def
mouse_up
(
self
,
detail
):
def
mouse_up
(
self
,
detail
):
x
=
self
.
editor
.
event
(
WE_MOUSE_UP
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
WE_MOUSE_UP
,
self
.
window
,
detail
)
#
#
def
keybd
(
self
,
(
type
,
detail
)):
def
keybd
(
self
,
(
type
,
detail
)):
x
=
self
.
editor
.
event
(
type
,
self
.
window
,
detail
)
x
=
self
.
editor
.
event
(
type
,
self
.
window
,
detail
)
#
#
def
activate
(
self
):
self
.
editor
.
setfocus
(
0
,
30000
)
self
.
editor
.
setactive
(
1
)
#
def
deactivate
(
self
):
self
.
editor
.
setactive
(
0
)
#
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