##// END OF EJS Templates
qtconsole: wrap argument list in tooltip to match width of text body...
y-p -
Show More
@@ -137,7 +137,7 b' class CallTipWidget(QtGui.QLabel):'
137
137
138 if call_line:
138 if call_line:
139 doc = '\n\n'.join([call_line, doc])
139 doc = '\n\n'.join([call_line, doc])
140 return self.show_tip(doc)
140 return self.show_tip(self._format_tooltip(doc))
141
141
142 def show_tip(self, tip):
142 def show_tip(self, tip):
143 """ Attempts to show the specified tip at the current cursor location.
143 """ Attempts to show the specified tip at the current cursor location.
@@ -248,6 +248,17 b' class CallTipWidget(QtGui.QLabel):'
248 QtGui.qApp.topLevelAt(QtGui.QCursor.pos()) != self):
248 QtGui.qApp.topLevelAt(QtGui.QCursor.pos()) != self):
249 self._hide_timer.start(300, self)
249 self._hide_timer.start(300, self)
250
250
251 def _format_tooltip(self,doc):
252 import textwrap
253
254 # make sure a long argument list does not make
255 # the first row overflow the width of the actual tip body
256 rows = doc.split("\n")
257 max_text_width = max(80, max([len(x) for x in rows[1:]]))
258 rows= textwrap.wrap(rows[0],max_text_width) + rows[1:]
259 doc = "\n".join(rows)
260 return doc
261
251 #------ Signal handlers ----------------------------------------------------
262 #------ Signal handlers ----------------------------------------------------
252
263
253 def _cursor_position_changed(self):
264 def _cursor_position_changed(self):
General Comments 0
You need to be logged in to leave comments. Login now