Skip to content

Loading…

Add pdb prints to Debugging Tricks (issue 889) #897

Merged
merged 1 commit into from

2 participants

@beuno

Add pdb.set_trace() to debugging tricks.

@diegosarmentero
ninja-ide member

Thanks

@diegosarmentero diegosarmentero merged commit 743b9da into ninja-ide:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2012
  1. @beuno
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 1 deletion.
  1. +6 −0 ninja_ide/gui/actions.py
  2. +9 −1 ninja_ide/gui/editor/helpers.py
  3. +4 −0 ninja_ide/gui/menus/menu_source.py
View
6 ninja_ide/gui/actions.py
@@ -636,6 +636,12 @@ def editor_insert_debugging_prints(self):
if editorWidget:
helpers.insert_debugging_prints(editorWidget)
+ def editor_insert_pdb(self):
+ """Insert a pdb.set_trace() statement in tjhe current line."""
+ editorWidget = self.ide.mainContainer.get_actual_editor()
+ if editorWidget:
+ helpers.insert_pdb(editorWidget)
+
def editor_comment(self):
"""Mark the current line or selection as a comment."""
editorWidget = self.ide.mainContainer.get_actual_editor()
View
10 ninja_ide/gui/editor/helpers.py
@@ -192,6 +192,13 @@ def insert_debugging_prints(editorWidget):
cursor.endEditBlock()
+def insert_pdb(editorWidget):
+ """Insert a pdb statement into the current line to debug code."""
+ cursor = editorWidget.textCursor()
+ indentation = get_indentation(cursor.block().text())
+ cursor.insertText("\n%simport pdb; pdb.set_trace()" % indentation)
+
+
def move_up(editorWidget):
cursor = editorWidget.textCursor()
block_actual = cursor.block()
@@ -518,7 +525,8 @@ def check_for_assistance_completion(editorWidget, line):
if init.startswith('__init__')]:
return
editorWidget.textCursor().insertText('\n')
- indent = get_indentation(line, editorWidget.indent, editorWidget.useTabs)
+ indent = get_indentation(
+ line, editorWidget.indent, editorWidget.useTabs)
editorWidget.textCursor().insertText(indent + 'def __init__(self):\n')
if editorWidget.useTabs:
indent += '\t'
View
4 ninja_ide/gui/menus/menu_source.py
@@ -80,6 +80,8 @@ def __init__(self, menuSource):
menu_debugging = menuSource.addMenu(self.tr("Debugging Tricks"))
insertPrints = menu_debugging.addAction(
self.tr("Insert Prints per selected line."))
+ insertPdb = menu_debugging.addAction(
+ self.tr("Insert pdb.set_trace()"))
# organizeImportsAction = menuSource.addAction(
# self.tr("&Organize Imports"))
# removeUnusedImportsAction = menuSource.addAction(
@@ -154,3 +156,5 @@ def __init__(self, menuSource):
actions.Actions().editor_remove_line)
self.connect(insertPrints, SIGNAL("triggered()"),
actions.Actions().editor_insert_debugging_prints)
+ self.connect(insertPdb, SIGNAL("triggered()"),
+ actions.Actions().editor_insert_pdb)
Something went wrong with that request. Please try again.