Kaydet (Commit) 4892ab7f authored tarafından Jack Jansen's avatar Jack Jansen

The Window Independent Tracer (which will probably move elsewhere once

it is truly window-independent:-)
üst f5b31c94
This diff is collapsed.
from FrameWork import *
import Win
import Qd
import Controls
import Ctl
import TE
import List
import os
import string
import macfs
SCROLLBAR=16
MARGIN=2
ICONSIZE=16
TEXTWIDTH=4096 # More-or-less random value
PIC_CURRENT=512
PIC_BREAK=513
picture_cache={}
class MT_TextWidget:
def __init__(self, wid, r):
self.wid = wid
self.rect = r
left, top, right, bottom = r
self.terect = left+MARGIN+ICONSIZE, top+MARGIN, \
right-(MARGIN+SCROLLBAR), bottom-(MARGIN+SCROLLBAR)
dr = self.terect[0], self.terect[1], TEXTWIDTH, self.terect[3]
Qd.SetPort(wid)
Qd.TextFont(4)
Qd.TextSize(9)
self.ted = TE.TENew(dr, self.terect)
self.ted.TEAutoView(1)
self.activate(1)
rect = right-SCROLLBAR, top, right, bottom-SCROLLBAR+1
self.bary = Ctl.NewControl(self.wid, rect, "", 1, 0, 0, 0, 16, 0)
rect = left, bottom-SCROLLBAR, right-SCROLLBAR+1, bottom
self.barx = Ctl.NewControl(self.wid, rect, "", 1, 0, 0, 0, 16, 0)
self.have_data = 0
self.line_index = []
def close(self):
del self.barx
del self.bary
del self.ted
def scrollbars(self):
pass
def setcontent(self, file):
self.line_index = []
if file == None:
data = ''
self.have_data = 0
else:
try:
fp = open(file, 'rb') # NOTE the binary
data = fp.read()
self.have_data = 1
except IOError, arg:
data = 'Cannot open file:\r'+`arg`
self.have_data = 0
if len(data) > 32767:
self.have_data = 0
data = 'File too big'
self.ted.TESetText(data)
if self.have_data:
cur = 0
while 1:
self.line_index.append(cur)
try:
cur = string.index(data, '\r', cur+1)
except ValueError:
break
self.line_index.append(len(data))
Win.InvalRect(self.rect)
self.ted.TESetSelect(0,0)
self.ted.TECalText()
self.ted.TESelView()
self.setscrollbars()
def setscrollbars(self):
docleft, doctop, docright, docbot = self.ted.destRect
winleft, wintop, winright, winbot = self.ted.viewRect
docbot = self.ted.nLines*self.ted.lineHeight + doctop
self.setbar(self.barx, docleft, docright, winleft, winright)
self.setbar(self.bary, doctop, docbot, wintop, winbot)
def setbar(self, bar, minmin, maxmax, curmin, curmax):
if maxmax-minmin > 32767 or (curmin <= minmin and curmax >= maxmax):
bar.SetControlMinimum(0)
bar.SetControlMaximum(0)
bar.SetControlValue(0)
return
bar.SetControlMinimum(minmin)
bar.SetControlMaximum(maxmax-(curmax-curmin))
bar.SetControlValue(curmin)
def update(self, rgn):
Qd.EraseRect(self.terect)
Qd.FrameRect(self.rect)
self.ted.TEUpdate(self.terect)
def activate(self, onoff):
if onoff:
self.ted.TEActivate()
else:
self.ted.TEDeactivate()
def select(self, line):
if line == None or line <= 0 or not self.have_data:
self.ted.TESetSelect(0,0)
else:
line = line - 1
if line > len(self.line_index)-1: line = len(self.line_index)-1
if line == 1:
self.ted.TESetSelect(0, self.line_index[1])
else:
self.ted.TESetSelect(self.line_index[line]+1, self.line_index[line+1])
self.setscrollbars()
def click(self, where, modifiers):
# First check scrollbars
ctltype, control = Ctl.FindControl(where, self.wid)
if ctltype and control:
partcode = control.TrackControl(where)
if partcode:
self.controlhit(control, partcode)
return None, 0
off = self.ted.TEGetOffset(where)
inborder = where[0] < self.terect[0]
return self.offsettoline(off), inborder
def offsettoline(self, offset):
for i in range(len(self.line_index)):
if offset < self.line_index[i]:
return i # Not i-1: 1-based line numbers in files
return None
def controlhit(self, control, partcode):
if partcode <> Controls.inThumb:
if control == self.barx:
if partcode == Controls.inUpButton:
delta = -10
if partcode == Controls.inDownButton:
delta = 10
if partcode == Controls.inPageUp:
delta = 10-(self.terect[2]-self.terect[0])
if partcode == Controls.inPageDown:
delta = (self.terect[2]-self.terect[0])-10
old = control.GetControlValue()
control.SetControlValue(old+delta)
if control == self.bary:
if partcode == Controls.inUpButton:
delta = -self.ted.lineHeight
if partcode == Controls.inDownButton:
delta = self.ted.lineHeight
if partcode == Controls.inPageUp:
delta = self.ted.lineHeight-(self.terect[3]-self.terect[1])
if partcode == Controls.inPageDown:
delta = (self.terect[3]-self.terect[1])-self.ted.lineHeight
old = control.GetControlValue()
control.SetControlValue(old+delta)
newx = self.barx.GetControlValue()
newy = self.bary.GetControlValue()
oldx = self.ted.viewRect[0]
oldy = self.ted.viewRect[1]
self.ted.TEPinScroll(oldx-newx, oldy-newy)
self.setscrollbars() # XXXX Bibbert, maar hoe anders?
class MT_IconTextWidget(MT_TextWidget):
def __init__(self, wid, r):
MT_TextWidget.__init__(self, wid, r)
self.breakpointlist = []
self.curline = None
self.iconrect = (self.rect[0]+1, self.rect[1]+1,
self.terect[0]-1, self.terect[3]-1)
self.curlinerange = (self.terect[1]+self.ted.lineHeight,
self.terect[3]-2*self.ted.lineHeight)
def setbreaks(self, list):
self.breakpointlist = list[:]
Qd.SetPort(self.wid)
Win.InvalRect(self.iconrect)
def setcurline(self, line):
self.curline = line
Qd.SetPort(self.wid)
self.showline(line)
def showline(self, line):
if line <= 0: line = 1
if line >= len(self.line_index): line = len(self.line_index)-1
if line < 0: return
off = self.line_index[line]
x, y = self.ted.TEGetPoint(off)
if self.curlinerange[0] <= y <= self.curlinerange[1]:
return # It is in view
middle = (self.curlinerange[0]+self.curlinerange[1])/2
self.ted.TEPinScroll(0, middle-y) # Of andersom?
self.setscrollbars()
def setscrollbars(self):
MT_TextWidget.setscrollbars(self)
Win.InvalRect(self.iconrect)
def update(self, rgn):
MT_TextWidget.update(self, rgn)
self.drawallicons()
def drawallicons(self):
Qd.EraseRect(self.iconrect)
Qd.MoveTo(self.iconrect[2], self.iconrect[1])
Qd.LineTo(self.iconrect[2], self.iconrect[3])
topoffset = self.ted.TEGetOffset((self.terect[0], self.terect[1]))
botoffset = self.ted.TEGetOffset((self.terect[0], self.terect[3]))
topline = self.offsettoline(topoffset)
botline = self.offsettoline(botoffset)
if topline == None: topline = 1 # ???
if botline == None: botline = len(self.line_index)
for i in self.breakpointlist:
if topline <= i <= botline:
self.draw1icon(i, PIC_BREAK)
if self.curline <> None and topline <= self.curline <= botline:
self.draw1icon(self.curline, PIC_CURRENT)
def draw1icon(self, line, which):
offset = self.line_index[line]
botx, boty = self.ted.TEGetPoint(offset)
rect = self.rect[0]+2, boty-self.ted.lineHeight, \
self.rect[0]+ICONSIZE-2, boty
if not picture_cache.has_key(which):
print 'Get picture', which
picture_cache[which] = Qd.GetPicture(which)
self.drawicon(rect, picture_cache[which])
def drawicon(self, rect, which):
Qd.DrawPicture(which, rect)
class MT_IndexList:
def __init__(self, wid, rect, width):
# wid is the window (dialog) where our list is going to be in
# rect is it's item rectangle (as in dialog item)
self.rect = rect
rect2 = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1
self.list = List.LNew(rect2, (0, 0, width, 0), (0,0), 0, wid,
0, 1, 0, 1)
self.wid = wid
self.width = width
def setcontent(self, *content):
self.list.LDelRow(0, 1)
self.list.LSetDrawingMode(0)
self.list.LAddRow(len(content[0]), 0)
for x in range(len(content)):
column = content[x]
for y in range(len(column)):
self.list.LSetCell(column[y], (x, y))
self.list.LSetDrawingMode(1)
Win.InvalRect(self.rect)
def deselectall(self):
while 1:
ok, pt = self.list.LGetSelect(1, (0,0))
if not ok: return
self.list.LSetSelect(0, pt)
def select(self, num):
self.deselectall()
if num < 0:
return
for i in range(self.width):
self.list.LSetSelect(1, (i, num))
def click(self, where, modifiers):
is_double = self.list.LClick(where, modifiers)
ok, (x, y) = self.list.LGetSelect(1, (0, 0))
if ok:
return y, is_double
else:
return None, is_double
# draw a frame around the list, List Manager doesn't do that
def drawframe(self):
Qd.SetPort(self.wid)
Qd.FrameRect(self.rect)
def update(self, rgn):
self.drawframe()
self.list.LUpdate(rgn)
def activate(self, onoff):
self.list.LActivate(onoff)
class MT_AnyList(MT_IndexList):
def click(self, where, modifiers):
is_double = self.list.LClick(where, modifiers)
ok, (x, y) = self.list.LGetSelect(1, (0, 0))
if ok:
self.select(y)
field0 = self.list.LGetCell(1000,(0,y))
else:
field0 = None
return field0, is_double
import FrameWork
import EasyDialogs
import Res
import sys
import Qd
import Evt
import Events
import Dlg
import Win
# Resource-id (for checking existence)
ID_MODULES=512
ID_ABOUT=515
_arrow = Qd.qd.arrow
_watch = Qd.GetCursor(4).data
# Made available to TwitCore:
AskString = EasyDialogs.AskString
def SetCursor():
Qd.SetCursor(_arrow)
def SetWatch():
Qd.SetCursor(_watch)
# Exception for temporarily exiting the loop and program
ExitMainloop = 'ExitMainloop'
ExitFully = 'ExitFully'
class Application(FrameWork.Application):
"""The twit main class - mac-dependent part"""
def __init__(self, run_args, pm_args):
# First init menus, etc.
FrameWork.Application.__init__(self)
self._quitting = 0
self.real_quit = 0
# Next create our dialogs
self.mi_init(run_args, pm_args)
if self.real_quit:
return
if not run_args:
# Go into mainloop once
self.one_mainloop()
if self.real_quit:
return
if not pm_args:
# And give the debugger control.
self.to_debugger()
def makeusermenus(self):
self.filemenu = m = FrameWork.Menu(self.menubar, "File")
self._quititem = FrameWork.MenuItem(m, "Quit", "Q", self.do_quit)
def do_about(self, id, item, window, event):
import time
d = Dlg.GetNewDialog(ID_ABOUT, -1)
if not d:
return
w = d.GetDialogWindow()
port = w.GetWindowPort()
l, t, r, b = port.portRect
sl, st, sr, sb = Qd.qd.screenBits.bounds
x = ((sr-sl) - (r-l)) / 2
y = ((sb-st-16) - (b-t)) / 5
w.MoveWindow(x, y, 0)
w.ShowWindow()
d.DrawDialog()
tp, h, rect = d.GetDialogItem(2)
x0, y0, x1, y1 = rect
ybot = y0 + 32
rgn = Qd.NewRgn()
Qd.SetPort(d)
ok, evt = self.getevent(Events.mDownMask|Events.keyDownMask, 1)
if ok: return
(what, message, when, where, modifiers) = event
delta_t = 128
nexttime = when+delta_t
while ybot < y1:
# Do the animation, if it is time
if when > nexttime:
Qd.ScrollRect((x0, y0, x1, ybot), 0, 1, rgn)
y0 = y0 + 1
ybot = ybot + 1
# And update next time
delta_t = int(delta_t*0.6)-1
if delta_t < 0:
delta_t = 0
nexttime = when + delta_t
# Check for an event.
ok, evt = self.getevent(Events.mDownMask|Events.keyDownMask, 0)
if ok: return
(what, message, when, where, modifiers) = evt
while 1:
ok, evt = self.getevent(Events.mDownMask|Events.keyDownMask, -1)
if ok: return
def do_quit(self, *args):
self._quit() # Signal FrameWork.Application to stop
self.real_quit = 1
self.quit_bdb() # Tell debugger to quit.
def exit_mainloop(self):
self._quit() # Signal FrameWork.Application to stop
self.real_quit = 0
def one_mainloop(self):
self.quitting = 0
self.mainloop()
def Initialize():
try:
# if this doesn't raise an error, we are an applet containing the
# necessary resources or we have been initialized already
# so we don't have to bother opening the resource file
dummy = Res.GetResource('DLOG', ID_MODULES)
except Res.Error:
try:
Res.OpenResFile("Twit.rsrc")
except Res.Error, arg:
EasyDialogs.Message("Cannot open Twit.rsrc: "+arg[1])
sys.exit(1)
This diff is collapsed.
"""Edit a file using the MetroWerks editor. Modify to suit your needs"""
import MacOS
import aetools
import Metrowerks_Shell_Suite
import Required_Suite
_talker = None
class MWShell(aetools.TalkTo,
Metrowerks_Shell_Suite.Metrowerks_Shell_Suite,
Required_Suite.Required_Suite):
pass
def edit(file, line):
global _talker
if _talker == None:
_talker = MWShell('CWIE', start=1)
try:
_talker.open(file)
_talker.Goto_Line(line)
except "(MacOS.Error, aetools.Error)":
pass
# A stab at a python debugger
import Res
import Qd
import Dlg
import Win
import FrameWork
import EasyDialogs
import sys
from mac_widgets import MT_AnyList, MT_IconTextWidget
# Our dialogs
ID_MODULES=512
I_MODULES_TITLE=1
I_MODULES=2
I_VARS_TITLE=3
I_VARS=4
I_SOURCE_TITLE=5
I_SOURCE=6
I_RULER=7
I_EDIT=8
class ModuleBrowser(FrameWork.DialogWindow):
"""The module-browser dialog - mac-dependent part"""
def open(self, module):
FrameWork.DialogWindow.open(self, ID_MODULES)
self.SetPort()
Qd.TextFont(3)
Qd.TextSize(9)
self.mi_open(module)
def create_items(self):
"""Create the lists we need"""
tp, h, rect = self.wid.GetDialogItem(I_MODULES)
self.modules = MT_AnyList(self.wid, rect, 1)
tp, h, rect = self.wid.GetDialogItem(I_VARS)
self.vars = MT_AnyList(self.wid, rect, 2)
tp, h, rect = self.wid.GetDialogItem(I_SOURCE)
self.source = MT_IconTextWidget(self.wid, rect)
def setsource(self, msg):
tp, h, rect = self.wid.GetDialogItem(I_SOURCE_TITLE)
if self.cur_source:
Dlg.SetDialogItemText(h, self.cur_source)
else:
Dlg.SetDialogItemText(h, msg)
self.source.setcontent(self.cur_source)
def do_itemhit(self, item, event):
(what, message, when, where, modifiers) = event
Qd.SetPort(self.wid)
where = Qd.GlobalToLocal(where)
if item == I_MODULES:
new_module, double = self.modules.click(where, 0)
self.click_module(new_module)
elif item == I_VARS:
new_var, double = self.vars.click(where, 0)
if double:
self.click_var(new_var)
elif item == I_SOURCE:
lineno, inborder = self.source.click(where, 0)
if lineno <> None and lineno >= 0:
self.click_source(lineno, inborder)
elif item == I_EDIT:
self.click_edit()
def do_rawupdate(self, window, event):
Qd.SetPort(self.wid)
rgn = self.wid.GetWindowPort().visRgn
tp, h, rect = self.wid.GetDialogItem(I_RULER)
Qd.MoveTo(rect[0], rect[1])
Qd.LineTo(rect[2], rect[1])
self.modules.update(rgn)
self.vars.update(rgn)
self.source.update(rgn)
def do_activate(self, activate, event):
self.modules.activate(activate)
self.vars.activate(activate)
self.source.activate(activate)
def close(self):
self.parent.module_dialog = None
self.source.close()
del self.modules
del self.vars
del self.source
self.do_postclose()
if __name__ == '__main__':
main()
# A stab at a python debugger
import Res
import Qd
import Dlg
import Win
import FrameWork
import EasyDialogs
import sys
from mac_widgets import MT_AnyList, MT_IndexList, MT_IconTextWidget
# Our dialogs
ID_STACK=513
I_STACK_TITLE=1
I_STACK=2
I_VARS_TITLE=3
I_VARS=4
I_SOURCE_TITLE=5
I_SOURCE=6
I_EXC_TITLE=7
I_EXC=8
I_EXCVALUE_TITLE=9
I_EXCVALUE=10
I_QUIT=11
I_CONTINUE=12
I_STEP=13
I_BROWSE=14
I_RULER1=15
I_RULER2=16
I_STATE_TITLE=17
I_STATE=18
I_STEP_IN=19
I_STEP_OUT=20
I_RUN=21
I_SHOW_COMPLEX=22
I_SHOW_SYSTEM=23
I_EDIT=24
class StackBrowser(FrameWork.DialogWindow):
"""The stack-browser dialog - mac-dependent part"""
def open(self):
FrameWork.DialogWindow.open(self, ID_STACK)
self.SetPort()
Qd.TextFont(3)
Qd.TextSize(9)
self.mi_open()
def create_items(self):
"""Create the lists we need"""
tp, h, rect = self.wid.GetDialogItem(I_STACK)
self.stack = MT_IndexList(self.wid, rect, 2)
tp, h, rect = self.wid.GetDialogItem(I_VARS)
self.vars = MT_AnyList(self.wid, rect, 2)
tp, h, rect = self.wid.GetDialogItem(I_SOURCE)
self.source = MT_IconTextWidget(self.wid, rect)
def setsource(self, msg):
tp, h, rect = self.wid.GetDialogItem(I_SOURCE_TITLE)
if self.cur_source:
Dlg.SetDialogItemText(h, self.cur_source)
else:
Dlg.SetDialogItemText(h, msg)
self.source.setcontent(self.cur_source)
def setexception(self, name, value):
print 'SETEXC', (name, value)
if name == None:
self.wid.HideDialogItem(I_EXC)
self.wid.HideDialogItem(I_EXC_TITLE)
value = None
else:
self.wid.ShowDialogItem(I_EXC)
self.wid.ShowDialogItem(I_EXC_TITLE)
tp, h, rect = self.wid.GetDialogItem(I_EXC)
Dlg.SetDialogItemText(h, name)
if value == None:
self.wid.HideDialogItem(I_EXCVALUE)
self.wid.HideDialogItem(I_EXCVALUE_TITLE)
else:
self.wid.ShowDialogItem(I_EXCVALUE)
self.wid.ShowDialogItem(I_EXCVALUE_TITLE)
tp, h, rect = self.wid.GetDialogItem(I_EXCVALUE)
Dlg.SetDialogItemText(h, value)
def setprogramstate(self, msg):
tp, h, rect = self.wid.GetDialogItem(I_STATE)
Dlg.SetDialogItemText(h, msg)
def setsession_none(self):
"""Nothing running, no stack trace"""
self.wid.HideDialogItem(I_CONTINUE)
self.wid.HideDialogItem(I_STEP)
self.wid.HideDialogItem(I_STEP_IN)
self.wid.HideDialogItem(I_STEP_OUT)
self.wid.ShowDialogItem(I_RUN)
def setsession_run(self):
"""Running"""
self.wid.HideDialogItem(I_RUN)
self.wid.ShowDialogItem(I_CONTINUE)
self.wid.ShowDialogItem(I_STEP)
self.wid.ShowDialogItem(I_STEP_IN)
self.wid.ShowDialogItem(I_STEP_OUT)
def setsession_pm(self):
"""Post-mortem debugging"""
self.wid.HideDialogItem(I_CONTINUE)
self.wid.HideDialogItem(I_STEP)
self.wid.HideDialogItem(I_STEP_IN)
self.wid.HideDialogItem(I_STEP_OUT)
self.wid.HideDialogItem(I_RUN)
def setsession_none(self):
"""Nothing running, no stack trace"""
self.wid.HideDialogItem(I_CONTINUE)
self.wid.HideDialogItem(I_STEP)
self.wid.HideDialogItem(I_STEP_IN)
self.wid.HideDialogItem(I_STEP_OUT)
self.wid.ShowDialogItem(I_RUN)
def do_itemhit(self, item, event):
(what, message, when, where, modifiers) = event
Qd.SetPort(self.wid)
where = Qd.GlobalToLocal(where)
print 'STACKHIT', item
if item == I_STACK:
new_stackitem, double = self.stack.click(where, 0)
self.click_stack(new_stackitem)
elif item == I_VARS:
new_var, double = self.vars.click(where, 0)
if double:
self.click_var(new_var)
elif item == I_SOURCE:
lineno, inborder = self.source.click(where, 0)
if lineno <> None and lineno >= 0:
self.click_source(lineno, inborder)
elif item == I_QUIT:
self.click_quit()
elif item == I_CONTINUE:
self.click_continue()
elif item == I_STEP:
self.click_step()
elif item == I_STEP_IN:
self.click_step_in()
elif item == I_STEP_OUT:
self.click_step_out()
elif item == I_BROWSE:
self.click_browse()
elif item == I_RUN:
self.click_run()
elif item == I_SHOW_COMPLEX:
self.show_complex = not self.show_complex
self.setup_frame()
elif item == I_SHOW_SYSTEM:
self.show_system = not self.show_system
self.setup_frame()
elif item == I_EDIT:
self.click_edit()
def set_var_buttons(self):
tp, h, rect = self.wid.GetDialogItem(I_SHOW_COMPLEX)
h.as_Control().SetControlValue(self.show_complex)
tp, h, rect = self.wid.GetDialogItem(I_SHOW_SYSTEM)
h.as_Control().SetControlValue(self.show_system)
def do_rawupdate(self, window, event):
Qd.SetPort(self.wid)
rgn = self.wid.GetWindowPort().visRgn
tp, h, rect = self.wid.GetDialogItem(I_RULER1)
Qd.MoveTo(rect[0], rect[1])
Qd.LineTo(rect[2], rect[1])
tp, h, rect = self.wid.GetDialogItem(I_RULER2)
Qd.MoveTo(rect[0], rect[1])
Qd.LineTo(rect[2], rect[1])
self.stack.update(rgn)
self.vars.update(rgn)
self.source.update(rgn)
def do_activate(self, activate, event):
self.stack.activate(activate)
self.vars.activate(activate)
self.source.activate(activate)
def close(self):
self.source.close()
del self.stack
del self.vars
del self.source
self.do_postclose()
"""twit - The Window-Independent Tracer.
Interface:
twit.main() Enter debugger in inactive interactive state
twit.run(stmt, globals, locals) Enter debugger and start running stmt
twit.post_mortem(traceback) Enter debugger in post-mortem mode on traceback
twit.pm() Enter debugger in pm-mode on sys.last_traceback
main program: nothing but a bit of glue to put it all together.
Jack Jansen, CWI, August 1996."""
import os
if os.name == 'mac':
import MacOS
MacOS.splash(515) # Try to show the splash screen
import mactwit_mod; twit_mod = mactwit_mod
import mactwit_stack; twit_stack = mactwit_stack
import mactwit_app; twit_app = mactwit_app
import mactwit_browser; twit_browser = mactwit_browser
import mactwit_edit; twit_edit = mactwit_edit
else:
try:
import _tkinter
have_tk = 1
except ImportError:
have_tk = 0
if have_tk:
import tktwit_mod; twit_mod = tktwit_mod
import tktwit_stack; twit_stack = tktwit_stack
import tktwit_app; twit_app = tktwit_app
else:
print 'Please implementent twit_mod, twit_stack and twit_app and try again:-)'
sys.exit(1)
import TwitCore
import sys
class Twit(twit_app.Application, TwitCore.Application):
def new_module_browser(self, *args):
return apply(TWIT_ModuleBrowser, args)
def new_stack_browser(self, *args):
return apply(TWIT_StackBrowser, args)
def new_var_browser(self, *args):
return apply(TWIT_VarBrowser, args)
def edit(self, *args):
return apply(twit_edit.edit, args)
class TWIT_ModuleBrowser(twit_mod.ModuleBrowser, TwitCore.ModuleBrowser):
pass
class TWIT_StackBrowser(twit_stack.StackBrowser, TwitCore.StackBrowser):
pass
def TWIT_VarBrowser(parent, var):
return twit_browser.VarBrowser(parent).open(var)
def Initialize():
# Gross...
TwitCore.AskString = twit_app.AskString
TwitCore.SetWatch = twit_app.SetWatch
TwitCore.SetCursor = twit_app.SetCursor
def main():
twit_app.Initialize()
TwitCore.Initialize()
Initialize()
if os.name == 'mac':
MacOS.splash()
Twit(None, None)
def run(statement, globals=None, locals=None):
twit_app.Initialize()
TwitCore.Initialize()
Initialize()
Twit((statement, globals, locals), None)
def post_mortem(t):
twit_app.Initialize()
TwitCore.Initialize()
Initialize()
Twit(None, t)
def pm():
post_mortem(sys.last_traceback)
if __name__ == '__main__':
main()
This diff is collapsed.
# Test program
def foo(arg1, arg2):
bar(arg1+arg2)
bar(arg1-arg2)
foo(arg1+1, arg2-1)
def bar(arg):
rv = 10/arg
print rv
foo(0,10)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment