Merge pull request #130 from FoxLisk/master

Adding some more emacs bindings to the REPL
This commit is contained in:
Andreas Klöckner 2015-01-26 09:10:41 -06:00
commit 100522f638

View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import division
import re
import urwid
import bdb
import sys
@ -1476,6 +1477,27 @@ class DebuggerUI(FrameVarInfoKeeper):
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:
@ -1491,6 +1513,9 @@ class DebuggerUI(FrameVarInfoKeeper):
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)