summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1997-04-03 14:45:28 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1997-04-03 14:45:28 (GMT)
commitcb2554effaf91d357ebbd7e3980b6f53ae66832e (patch)
tree432b6f97d4d786dde5c2f4f86fa775bb2302e48b /Mac/Lib
parent1801aad5dc790a920fcf889a1c1663b92fd5e7a9 (diff)
downloadcpython-cb2554effaf91d357ebbd7e3980b6f53ae66832e.zip
cpython-cb2554effaf91d357ebbd7e3980b6f53ae66832e.tar.gz
cpython-cb2554effaf91d357ebbd7e3980b6f53ae66832e.tar.bz2
Still not a real test, but at least it runs again
Diffstat (limited to 'Mac/Lib')
-rw-r--r--Mac/Lib/test/ctbtest.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/Mac/Lib/test/ctbtest.py b/Mac/Lib/test/ctbtest.py
index 5364c44..0f3cd90 100644
--- a/Mac/Lib/test/ctbtest.py
+++ b/Mac/Lib/test/ctbtest.py
@@ -1,8 +1,11 @@
#
# Simple test program for ctb module: emulate a terminal.
+# To simplify matters use the python console window for output.
#
import ctb
-import macconsole
+import Evt
+import Events
+import MacOS
import sys
def cb(err):
@@ -12,29 +15,35 @@ def main():
if not ctb.available():
print 'Communications Toolbox not available'
sys.exit(1)
-# c = macconsole.copen('Terminal window')
+ # Disable Python's event processing (we do that)
+ MacOS.EnableAppswitch(0)
print 'Minimal terminal emulator V1.0'
- print '(type @ to exit)'
+ print '(type command-Q to exit)'
print
- c = macconsole.fopen(sys.stdin)
- f = sys.stdin
- c.setmode(macconsole.C_RAW)
l = ctb.CMNew('Serial Tool', None)
- l.Open(0)
+ l.Open(10)
+ l.SetConfig(l.GetConfig() + ' baud 4800')
while 1:
- l.Idle()
- d = f.read(1)
- if d == '@':
- break
- if d:
- l.Write(d, ctb.cmData, -1, 0)
- l.Idle()
- d, dummy = l.Read(1000, ctb.cmData, 0)
+ l.Idle() # Give time to ctb
+
+ ok, evt = Evt.WaitNextEvent(0xffff, 0)
+ if ok:
+ what, message, when, where, modifiers = evt
+
+ if what == Events.keyDown:
+ # It is ours. Check for command-. to terminate
+ ch = chr(message & Events.charCodeMask)
+ if ch == 'q' and (modifiers & Events.cmdKey):
+ break
+ l.Write(ch, ctb.cmData, -1, 0)
+ d, dummy = l.Read(1000, ctb.cmData, 1)
if d:
- f.write(d)
- f.flush()
+ for ch in d:
+ if ch != '\r':
+ sys.stdout.write(ch)
+ sys.stdout.flush()
l.Close(-1, 1)
del l