##// END OF EJS Templates
Capture Xterm title sequence.
Gael Varoquaux -
Show More
@@ -73,6 +73,8 b' class ConsoleWidget(editwindow.EditWindow):'
73 keeping the cursor inside the editing line.
73 keeping the cursor inside the editing line.
74 """
74 """
75
75
76 title = 'Console'
77
76 style = _DEFAULT_STYLE.copy()
78 style = _DEFAULT_STYLE.copy()
77
79
78 # Translation table from ANSI escape sequences to color. Override
80 # Translation table from ANSI escape sequences to color. Override
@@ -158,8 +160,10 b' class ConsoleWidget(editwindow.EditWindow):'
158 self.SetMarginWidth(2, 0)
160 self.SetMarginWidth(2, 0)
159
161
160 self._apply_style()
162 self._apply_style()
161
163
164 # Xterm escape sequences
162 self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
165 self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
166 self.title_pat = re.compile('\x1b]0;(.*?)\x07')
163
167
164 #self.SetEdgeMode(stc.STC_EDGE_LINE)
168 #self.SetEdgeMode(stc.STC_EDGE_LINE)
165 #self.SetEdgeColumn(80)
169 #self.SetEdgeColumn(80)
@@ -191,11 +195,16 b' class ConsoleWidget(editwindow.EditWindow):'
191 """ Write given text to buffer, while translating the ansi escape
195 """ Write given text to buffer, while translating the ansi escape
192 sequences.
196 sequences.
193 """
197 """
198 title = self.title_pat.split(text)
199 if len(title)>0:
200 self.title = title[-1]
201
202 text = self.title_pat.sub('', text)
194 segments = self.color_pat.split(text)
203 segments = self.color_pat.split(text)
195 segment = segments.pop(0)
204 segment = segments.pop(0)
196 self.StartStyling(self.GetLength(), 0xFF)
205 self.StartStyling(self.GetLength(), 0xFF)
197 self.AppendText(segment)
206 self.AppendText(segment)
198
207
199 if segments:
208 if segments:
200 ansi_tags = self.color_pat.findall(text)
209 ansi_tags = self.color_pat.findall(text)
201
210
General Comments 0
You need to be logged in to leave comments. Login now