89659d035628a9fe7a450bffc9e603ff905eceb7
15 import ClientIOTerminal
19 class DbgTerminal (vte
.Terminal
):
26 def __init__(self
, clientCmd
):
28 vte
.Terminal
.__init
__(self
)
31 self
.clientCmd
= clientCmd
32 #Open pseudo-terminal where to-be-debugged process reads/writes to
33 self
.client_ptymaster
, self
.client_ptyslave
= pty
.openpty()
35 #Set up terminal window and initialize debugger
36 self
.connect("cursor-moved", self
.contents_changed
)
37 self
.connect("child-exited", lambda *w
: gtk
.main_quit())
40 fontdesc
= pango
.FontDescription("monospace 9")
41 self
.set_font(fontdesc
)
45 self
.fork_command( self
.getCommand(), self
.getArgv())
46 self
.setPty(self
.client_ptyslave
)
47 self
.waitForActivation()
50 def contents_changed(self
, term
):
51 c
,r
= term
.get_cursor_position()
54 text
= self
.get_text_range(self
.lastrow
,0,r
,-1,lambda *w
:True)
56 #Remove the incomplete line
57 if self
.getHistoryLen()>0 and (len(self
.history
[-1])==0 or self
.history
[-1]!='\n') :
60 #Get the lines and remove empty lines
61 lines
= string
.split(text
, "\n")
63 #Remove last empty line...
68 self
.history
+= [l
+"\n" for l
in lines
[:-1]]
69 self
.history
+= [lines
[-1]]
73 def waitForNewline(self
):
75 while not self
.lastrow
> r
:
78 def getHistoryLen(self
):
79 return len(self
.history
)
81 def waitForRx(self
, rx
, start
=None):
84 start
= self
.getHistoryLen()
89 for no
in range(start
, self
.getHistoryLen()):
90 line
= self
.history
[no
]
94 start
= self
.getHistoryLen()
99 return self
.getArgv()[0];
102 raise NotImplementedError()
104 def setPty(self
, pty
):
105 raise NotImplementedError()
108 raise NotImplementedError()
110 def setContinue(self
):
111 raise NotImplementedError()
113 def setStepover(self
):
114 raise NotImplementedError()
117 raise NotImplementedError()
120 raise NotImplementedError()
122 def setBreakpoint(self
, file, lineno
, condition
=False):
123 raise NotImplementedError()
125 def delBreakpoint(self
, breakpoint
):
126 raise NotImplementedError()
128 def getExpression(self
, expr
):
129 raise NotImplementedError()
131 def waitForActivation(self
, his
):
132 raise NotImplementedError()
134 def setActive(self
, isactive
):
135 self
.isactive
= isactive
145 class DbgWindow (gtk
.Window
):
150 def __init__(self
, terminal
):
153 self
.terminal
= terminal
156 gtk
.Window
.__init
__(self
)
157 self
.connect("destroy", lambda *w
: gtk
.main_quit())
159 #Set title and add terminal
160 self
.set_title("Debugger I/O")
161 self
.terminal
.history
= []
162 self
.terminal
.history_length
= 5
163 self
.add(self
.terminal
)
168 def toggleClientIOWindow(self
):
169 if not self
.clientIOWnd
:
170 self
.clientIOWnd
= ClientIOTerminal
.ClientIOWindow(self
, \
171 self
.terminal
.client_ptymaster
)
173 self
.clientIOWnd
.destroy()
174 self
.clientIOWnd
= None
176 def isClientIOWindowExisting(self
):
177 return self
.clientIOWnd
!= None