Beispiel #1
0
 def toogle_breakpoint(self,
                       line_number=None,
                       condition=None,
                       edit_condition=False):
     """Add/remove breakpoint."""
     if not self.editor.is_python_like():
         return
     if line_number is None:
         block = self.editor.textCursor().block()
     else:
         block = self.editor.document().findBlockByNumber(line_number - 1)
     data = block.userData()
     if not data:
         data = BlockUserData(self.editor)
         data.breakpoint = True
     elif not edit_condition:
         data.breakpoint = not data.breakpoint
         data.breakpoint_condition = None
     if condition is not None:
         data.breakpoint_condition = condition
     if edit_condition:
         condition = data.breakpoint_condition
         condition, valid = QInputDialog.getText(self.editor,
                                                 _('Breakpoint'),
                                                 _("Condition:"),
                                                 QLineEdit.Normal,
                                                 condition)
         if not valid:
             return
         data.breakpoint = True
         data.breakpoint_condition = str(condition) if condition else None
     if data.breakpoint:
         text = to_text_string(block.text()).strip()
         if len(text) == 0 or text.startswith(('#', '"', "'")):
             data.breakpoint = False
         else:
             self._breakpoint_blocks[id(block)] = block
     block.setUserData(data)
     self.editor.sig_flags_changed.emit()
     self.editor.sig_breakpoints_changed.emit()
Beispiel #2
0
 def toogle_breakpoint(self, line_number=None, condition=None,
                       edit_condition=False):
     """Add/remove breakpoint."""
     if not self.editor.is_python_like():
         return
     if line_number is None:
         block = self.editor.textCursor().block()
     else:
         block = self.editor.document().findBlockByNumber(line_number-1)
     data = block.userData()
     if not data:
         data = BlockUserData(self.editor)
         data.breakpoint = True
     elif not edit_condition:
         data.breakpoint = not data.breakpoint
         data.breakpoint_condition = None
     if condition is not None:
         data.breakpoint_condition = condition
     if edit_condition:
         condition = data.breakpoint_condition
         condition, valid = QInputDialog.getText(self.editor,
                                                 _('Breakpoint'),
                                                 _("Condition:"),
                                                 QLineEdit.Normal,
                                                 condition)
         if not valid:
             return
         data.breakpoint = True
         data.breakpoint_condition = str(condition) if condition else None
     if data.breakpoint:
         text = to_text_string(block.text()).strip()
         if len(text) == 0 or text.startswith(('#', '"', "'")):
             data.breakpoint = False
     block.setUserData(data)
     self.editor.sig_flags_changed.emit()
     self.editor.sig_breakpoints_changed.emit()