summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/calendar.py3
-rw-r--r--Lib/lib-stdwin/BoxParent.py5
-rw-r--r--Lib/lib-stdwin/DirList.py2
-rw-r--r--Lib/lib-stdwin/HVSplit.py4
-rw-r--r--Lib/lib-stdwin/Split.py13
-rw-r--r--Lib/lib-stdwin/TransParent.py12
-rw-r--r--Lib/lib-stdwin/WindowParent.py4
-rw-r--r--Lib/lib-stdwin/mainloop.py48
-rw-r--r--Lib/mimetools.py2
-rw-r--r--Lib/regexp.py8
-rwxr-xr-xLib/stdwin/BoxParent.py5
-rwxr-xr-xLib/stdwin/DirList.py2
-rwxr-xr-xLib/stdwin/HVSplit.py4
-rwxr-xr-xLib/stdwin/Split.py13
-rwxr-xr-xLib/stdwin/TransParent.py12
-rwxr-xr-xLib/stdwin/WindowParent.py4
-rwxr-xr-xLib/stdwin/mainloop.py48
-rw-r--r--Lib/whrandom.py2
18 files changed, 113 insertions, 78 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 62fb27f..13c8bbb 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -31,6 +31,7 @@ error = 'calendar error'
# Turn seconds since epoch into calendar time
def gmtime(secs):
if secs < 0: raise error, 'negative input to gmtime()'
+ secs = int(secs)
mins, secs = divmod(secs, 60)
hours, mins = divmod(mins, 60)
days, hours = divmod(hours, 24)
@@ -146,7 +147,7 @@ def monthcalendar(year, month):
key = `year` + month_abbr[month]
try:
return mc_cache[key]
- except IOError:
+ except KeyError:
mc_cache[key] = ret = _monthcalendar(year, month)
return ret
diff --git a/Lib/lib-stdwin/BoxParent.py b/Lib/lib-stdwin/BoxParent.py
index a44995d..c792731 100644
--- a/Lib/lib-stdwin/BoxParent.py
+++ b/Lib/lib-stdwin/BoxParent.py
@@ -27,15 +27,14 @@ class BoxParent(TransParent):
def getbounds(self):
return self.bounds
#
- def draw(self, args):
- d, area = args
+ def draw(self, d, area):
(left, top), (right, bottom) = self.bounds
left = left + 1
top = top + 1
right = right - 1
bottom = bottom - 1
d.box((left, top), (right, bottom))
- TransParent.draw(self, args) # XXX clip to innerbounds?
+ TransParent.draw(self, d, area) # XXX clip to innerbounds?
#
# XXX should scroll clip to innerbounds???
# XXX currently the only user restricts itself to child's bounds
diff --git a/Lib/lib-stdwin/DirList.py b/Lib/lib-stdwin/DirList.py
index 4b98b1d..446d33b 100644
--- a/Lib/lib-stdwin/DirList.py
+++ b/Lib/lib-stdwin/DirList.py
@@ -28,7 +28,7 @@ class DirList(VSplit):
class DirListWindow(WindowParent):
#
def create(self, dirname):
- self = WindowParent.create(self, (dirname, (0, 0)))
+ self = WindowParent.create(self, dirname, (0, 0))
child = DirList().create(self, dirname)
self.realize()
return self
diff --git a/Lib/lib-stdwin/HVSplit.py b/Lib/lib-stdwin/HVSplit.py
index c42327d..62e0de7 100644
--- a/Lib/lib-stdwin/HVSplit.py
+++ b/Lib/lib-stdwin/HVSplit.py
@@ -55,8 +55,8 @@ class HVSplit(Split):
class HSplit(HVSplit):
def create(self, parent):
- return HVSplit.create(self, (parent, 0))
+ return HVSplit.create(self, parent, 0)
class VSplit(HVSplit):
def create(self, parent):
- return HVSplit.create(self, (parent, 1))
+ return HVSplit.create(self, parent, 1)
diff --git a/Lib/lib-stdwin/Split.py b/Lib/lib-stdwin/Split.py
index 8eb0254..5ff9808 100644
--- a/Lib/lib-stdwin/Split.py
+++ b/Lib/lib-stdwin/Split.py
@@ -50,10 +50,10 @@ class Split:
for child in self.children:
child.realize()
#
- def draw(self, d_detail):
+ def draw(self, d, detail):
# (Could avoid calls to children outside the area)
for child in self.children:
- child.draw(d_detail)
+ child.draw(d, detail)
#
def altdraw(self, detail):
for child in self.altdraw_interest:
@@ -112,15 +112,14 @@ class Split:
if self.keybd_focus:
self.keybd_focus.deactivate()
#
- def keybd(self, type_detail):
+ def keybd(self, type, detail):
if not self.keybd_focus:
self.set_keybd_focus(self.keybd_interest[0])
- type, detail = type_detail
if type == WE_COMMAND and detail == WC_TAB and \
len(self.keybd_interest) > 1:
self.next_keybd_focus()
return
- self.keybd_focus.keybd(type_detail)
+ self.keybd_focus.keybd(type, detail)
#
def timer(self):
for child in self.timer_interest:
@@ -206,7 +205,7 @@ class Split:
#
def change(self, area):
self.parent.change(area)
- def scroll(self, area_vector):
- self.parent.scroll(area_vector)
+ def scroll(self, area, vector):
+ self.parent.scroll(area, vector)
def settimer(self, itimer):
self.parent.settimer(itimer)
diff --git a/Lib/lib-stdwin/TransParent.py b/Lib/lib-stdwin/TransParent.py
index 27e9bbd..49dcd3d 100644
--- a/Lib/lib-stdwin/TransParent.py
+++ b/Lib/lib-stdwin/TransParent.py
@@ -60,12 +60,12 @@ class TransParent(ManageOneChild):
def realize(self):
if self.child:
self.child.realize()
- def draw(self, args):
+ def draw(self, d, area):
if self.child:
- self.child.draw(args)
- def altdraw(self, args):
+ self.child.draw(d, area)
+ def altdraw(self, area):
if self.child:
- self.child.altdraw(args)
+ self.child.altdraw(area)
#
# Downcalls only made after certain upcalls
#
@@ -117,7 +117,7 @@ class TransParent(ManageOneChild):
#
def change(self, area):
self.parent.change(area)
- def scroll(self, args):
- self.parent.scroll(args)
+ def scroll(self, area, vector):
+ self.parent.scroll(area, vector)
def settimer(self, itimer):
self.parent.settimer(itimer)
diff --git a/Lib/lib-stdwin/WindowParent.py b/Lib/lib-stdwin/WindowParent.py
index 1964d38..cdec10b 100644
--- a/Lib/lib-stdwin/WindowParent.py
+++ b/Lib/lib-stdwin/WindowParent.py
@@ -136,9 +136,9 @@ class WindowParent(ManageOneChild):
if self.win:
self.win.change(area)
#
- def scroll(self, args):
+ def scroll(self, area, vector):
if self.win:
- self.win.scroll(args)
+ self.win.scroll(area, vector)
#
def settimer(self, itimer):
if self.win:
diff --git a/Lib/lib-stdwin/mainloop.py b/Lib/lib-stdwin/mainloop.py
index f1fe617..6b574cf 100644
--- a/Lib/lib-stdwin/mainloop.py
+++ b/Lib/lib-stdwin/mainloop.py
@@ -4,6 +4,9 @@
# - have a 'dispatch' function as a window member
+# XXX This is UNIX specific! For the Mac we need to use a simpler version!
+
+
import stdwin, stdwinq
from stdwinevents import *
@@ -123,23 +126,38 @@ def do_select():
# Python's stdwin.getevent() turns WE_COMMAND/WC_CANCEL events
# into KeyboardInterrupt exceptions; these are turned back in events.
#
+recursion_level = 0 # Hack to make it reentrant
def mainloop():
- stdwin_select_handler() # Process events already in stdwin queue
- fd = stdwin.fileno()
- while 1:
- if windows:
- registerfd(fd, 'r', stdwin_select_handler)
- try:
- while windows:
+ global recursion_level
+ recursion_level = recursion_level + 1
+ try:
+ stdwin_select_handler() # Process events already in queue
+ fd = stdwin.fileno()
+ while 1:
+ if windows:
+ if recursion_level == 1:
+ registerfd(fd, 'r', stdwin_select_handler)
+ try:
+ while windows:
+ do_select()
+ stdwin_select_handler()
+ finally:
+ if recursion_level == 1:
+ unregisterfd(fd)
+ elif fdlist:
+ while fdlist and not windows:
do_select()
- stdwin_select_handler()
- finally:
- unregisterfd(fd)
- elif fdlist:
- while fdlist and not windows:
- do_select()
- else:
- break
+ else:
+ break
+ finally:
+ recursion_level = recursion_level - 1
+
+
+# Check for events without ever blocking
+#
+def check():
+ stdwin_select_handler()
+ # XXX Should check for socket stuff as well
# Handle stdwin events until none are left
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index 79c6fb1..84eff9d 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -108,6 +108,6 @@ def choose_boundary():
pid = `os.getpid()`
seed = `rand.rand()`
_prefix = hostid + '.' + uid + '.' + pid
- timestamp = `time.time()`
+ timestamp = `int(time.time())`
seed = `rand.rand()`
return _prefix + '.' + timestamp + '.' + seed
diff --git a/Lib/regexp.py b/Lib/regexp.py
index 2b8a5c0..755f65a 100644
--- a/Lib/regexp.py
+++ b/Lib/regexp.py
@@ -11,11 +11,13 @@ class Prog:
finally:
xxx = regex.set_syntax(save_syntax)
return self
- def match(self, args):
- if type(args) == type(()):
+ def match(self, *args):
+ if len(args) == 2:
str, offset = args
+ elif len(args) == 1:
+ str, offset = args[0], 0
else:
- str, offset = args, 0
+ raise TypeError, 'wrong argument count'
if self.prog.search(str, offset) < 0:
return ()
regs = self.prog.regs
diff --git a/Lib/stdwin/BoxParent.py b/Lib/stdwin/BoxParent.py
index a44995d..c792731 100755
--- a/Lib/stdwin/BoxParent.py
+++ b/Lib/stdwin/BoxParent.py
@@ -27,15 +27,14 @@ class BoxParent(TransParent):
def getbounds(self):
return self.bounds
#
- def draw(self, args):
- d, area = args
+ def draw(self, d, area):
(left, top), (right, bottom) = self.bounds
left = left + 1
top = top + 1
right = right - 1
bottom = bottom - 1
d.box((left, top), (right, bottom))
- TransParent.draw(self, args) # XXX clip to innerbounds?
+ TransParent.draw(self, d, area) # XXX clip to innerbounds?
#
# XXX should scroll clip to innerbounds???
# XXX currently the only user restricts itself to child's bounds
diff --git a/Lib/stdwin/DirList.py b/Lib/stdwin/DirList.py
index 4b98b1d..446d33b 100755
--- a/Lib/stdwin/DirList.py
+++ b/Lib/stdwin/DirList.py
@@ -28,7 +28,7 @@ class DirList(VSplit):
class DirListWindow(WindowParent):
#
def create(self, dirname):
- self = WindowParent.create(self, (dirname, (0, 0)))
+ self = WindowParent.create(self, dirname, (0, 0))
child = DirList().create(self, dirname)
self.realize()
return self
diff --git a/Lib/stdwin/HVSplit.py b/Lib/stdwin/HVSplit.py
index c42327d..62e0de7 100755
--- a/Lib/stdwin/HVSplit.py
+++ b/Lib/stdwin/HVSplit.py
@@ -55,8 +55,8 @@ class HVSplit(Split):
class HSplit(HVSplit):
def create(self, parent):
- return HVSplit.create(self, (parent, 0))
+ return HVSplit.create(self, parent, 0)
class VSplit(HVSplit):
def create(self, parent):
- return HVSplit.create(self, (parent, 1))
+ return HVSplit.create(self, parent, 1)
diff --git a/Lib/stdwin/Split.py b/Lib/stdwin/Split.py
index 8eb0254..5ff9808 100755
--- a/Lib/stdwin/Split.py
+++ b/Lib/stdwin/Split.py
@@ -50,10 +50,10 @@ class Split:
for child in self.children:
child.realize()
#
- def draw(self, d_detail):
+ def draw(self, d, detail):
# (Could avoid calls to children outside the area)
for child in self.children:
- child.draw(d_detail)
+ child.draw(d, detail)
#
def altdraw(self, detail):
for child in self.altdraw_interest:
@@ -112,15 +112,14 @@ class Split:
if self.keybd_focus:
self.keybd_focus.deactivate()
#
- def keybd(self, type_detail):
+ def keybd(self, type, detail):
if not self.keybd_focus:
self.set_keybd_focus(self.keybd_interest[0])
- type, detail = type_detail
if type == WE_COMMAND and detail == WC_TAB and \
len(self.keybd_interest) > 1:
self.next_keybd_focus()
return
- self.keybd_focus.keybd(type_detail)
+ self.keybd_focus.keybd(type, detail)
#
def timer(self):
for child in self.timer_interest:
@@ -206,7 +205,7 @@ class Split:
#
def change(self, area):
self.parent.change(area)
- def scroll(self, area_vector):
- self.parent.scroll(area_vector)
+ def scroll(self, area, vector):
+ self.parent.scroll(area, vector)
def settimer(self, itimer):
self.parent.settimer(itimer)
diff --git a/Lib/stdwin/TransParent.py b/Lib/stdwin/TransParent.py
index 27e9bbd..49dcd3d 100755
--- a/Lib/stdwin/TransParent.py
+++ b/Lib/stdwin/TransParent.py
@@ -60,12 +60,12 @@ class TransParent(ManageOneChild):
def realize(self):
if self.child:
self.child.realize()
- def draw(self, args):
+ def draw(self, d, area):
if self.child:
- self.child.draw(args)
- def altdraw(self, args):
+ self.child.draw(d, area)
+ def altdraw(self, area):
if self.child:
- self.child.altdraw(args)
+ self.child.altdraw(area)
#
# Downcalls only made after certain upcalls
#
@@ -117,7 +117,7 @@ class TransParent(ManageOneChild):
#
def change(self, area):
self.parent.change(area)
- def scroll(self, args):
- self.parent.scroll(args)
+ def scroll(self, area, vector):
+ self.parent.scroll(area, vector)
def settimer(self, itimer):
self.parent.settimer(itimer)
diff --git a/Lib/stdwin/WindowParent.py b/Lib/stdwin/WindowParent.py
index 1964d38..cdec10b 100755
--- a/Lib/stdwin/WindowParent.py
+++ b/Lib/stdwin/WindowParent.py
@@ -136,9 +136,9 @@ class WindowParent(ManageOneChild):
if self.win:
self.win.change(area)
#
- def scroll(self, args):
+ def scroll(self, area, vector):
if self.win:
- self.win.scroll(args)
+ self.win.scroll(area, vector)
#
def settimer(self, itimer):
if self.win:
diff --git a/Lib/stdwin/mainloop.py b/Lib/stdwin/mainloop.py
index f1fe617..6b574cf 100755
--- a/Lib/stdwin/mainloop.py
+++ b/Lib/stdwin/mainloop.py
@@ -4,6 +4,9 @@
# - have a 'dispatch' function as a window member
+# XXX This is UNIX specific! For the Mac we need to use a simpler version!
+
+
import stdwin, stdwinq
from stdwinevents import *
@@ -123,23 +126,38 @@ def do_select():
# Python's stdwin.getevent() turns WE_COMMAND/WC_CANCEL events
# into KeyboardInterrupt exceptions; these are turned back in events.
#
+recursion_level = 0 # Hack to make it reentrant
def mainloop():
- stdwin_select_handler() # Process events already in stdwin queue
- fd = stdwin.fileno()
- while 1:
- if windows:
- registerfd(fd, 'r', stdwin_select_handler)
- try:
- while windows:
+ global recursion_level
+ recursion_level = recursion_level + 1
+ try:
+ stdwin_select_handler() # Process events already in queue
+ fd = stdwin.fileno()
+ while 1:
+ if windows:
+ if recursion_level == 1:
+ registerfd(fd, 'r', stdwin_select_handler)
+ try:
+ while windows:
+ do_select()
+ stdwin_select_handler()
+ finally:
+ if recursion_level == 1:
+ unregisterfd(fd)
+ elif fdlist:
+ while fdlist and not windows:
do_select()
- stdwin_select_handler()
- finally:
- unregisterfd(fd)
- elif fdlist:
- while fdlist and not windows:
- do_select()
- else:
- break
+ else:
+ break
+ finally:
+ recursion_level = recursion_level - 1
+
+
+# Check for events without ever blocking
+#
+def check():
+ stdwin_select_handler()
+ # XXX Should check for socket stuff as well
# Handle stdwin events until none are left
diff --git a/Lib/whrandom.py b/Lib/whrandom.py
index 6623904..0a34690 100644
--- a/Lib/whrandom.py
+++ b/Lib/whrandom.py
@@ -39,7 +39,7 @@ class whrandom:
if not xyz:
# Initialize from current time
import time
- t = time.time()
+ t = int(time.time())
t, x = divmod(t, 256)
t, y = divmod(t, 256)
t, z = divmod(t, 256)