Skip to content

Commit

Permalink
Merge pull request #130 from FoxLisk/master
Browse files Browse the repository at this point in the history
Adding some more emacs bindings to the REPL
  • Loading branch information
inducer committed Jan 26, 2015
2 parents 2d5ac41 + aca5bb2 commit 100522f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pudb/debugger.py
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

from __future__ import division
import re
import urwid
import bdb
import sys
Expand Down Expand Up @@ -1476,6 +1477,27 @@ def cmdline_history_prev(w, size, key):
def cmdline_history_next(w, size, key):
cmdline_history_browse(1)

def cmdline_start_of_line(w, size, key):
self.cmdline_edit.edit_pos = 0

def cmdline_end_of_line(w, size, key):
self.cmdline_edit.edit_pos = len(self.cmdline_edit.edit_text)

def cmdline_del_word(w, size, key):
pos = self.cmdline_edit.edit_pos
before, after = self.cmdline_edit.edit_text[:pos], self.cmdline_edit.edit_text[pos:]
before = before[::-1]
before = before.lstrip()
i = 0
while i < len(before):
if not before[i].isspace():
i += 1
else:
break
self.cmdline_edit.edit_text = before[i:][::-1] + after
self.cmdline_edit.edit_post = len(before[i:])


def toggle_cmdline_focus(w, size, key):
self.columns.set_focus(self.lhs_col)
if self.lhs_col.get_focus() is self.cmdline_sigwrap:
Expand All @@ -1491,6 +1513,9 @@ def toggle_cmdline_focus(w, size, key):
self.cmdline_edit_sigwrap.listen("ctrl p", cmdline_history_prev)
self.cmdline_edit_sigwrap.listen("esc", toggle_cmdline_focus)
self.cmdline_edit_sigwrap.listen("ctrl d", toggle_cmdline_focus)
self.cmdline_edit_sigwrap.listen("ctrl a", cmdline_start_of_line)
self.cmdline_edit_sigwrap.listen("ctrl e", cmdline_end_of_line)
self.cmdline_edit_sigwrap.listen("ctrl w", cmdline_del_word)

self.top.listen("ctrl x", toggle_cmdline_focus)

Expand Down

0 comments on commit 100522f

Please sign in to comment.