electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9ae12c43e410abada7deeb6d4cdd1587243c8030
parent 166db1e16f386f16b773f32863d13a87465e31df
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 23 Feb 2013 20:48:22 +0100

word per word completions

Diffstat:
Mlib/gui_qt.py | 2++
Mlib/qt_console.py | 15+++++++++------
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/gui_qt.py b/lib/gui_qt.py @@ -1263,8 +1263,10 @@ class ElectrumWindow(QMainWindow): def create_wall_tab(self): from qt_console import Console + import util, bitcoin self.console = console = Console() console.updateNamespace({'wallet' : self.wallet, 'interface' : self.wallet.interface, 'gui':self}) + console.updateNamespace({'util' : util, 'bitcoin':bitcoin}) return console diff --git a/lib/qt_console.py b/lib/qt_console.py @@ -1,6 +1,6 @@ # source: http://stackoverflow.com/questions/2758159/how-to-embed-a-python-interpreter-in-a-pyqt-widget -import sys, os +import sys, os, re import traceback from PyQt4 import QtCore from PyQt4 import QtGui @@ -221,7 +221,10 @@ class Console(QtGui.QPlainTextEdit): def completions(self): cmd = self.getCommand() - path = cmd.split('.') + lastword = re.split(' |\(|\)',cmd)[-1] + beginning = cmd[0:-len(lastword)] + + path = lastword.split('.') ns = self.namespace.keys() if len(path) == 1: @@ -237,20 +240,20 @@ class Console(QtGui.QPlainTextEdit): for x in ns: if x[0] == '_':continue xx = prefix + x - if xx.startswith(cmd): + if xx.startswith(lastword): completions.append(xx) if not completions: self.hide_completions() elif len(completions) == 1: self.hide_completions() - self.setCommand(completions[0]) + self.setCommand(beginning + completions[0]) else: # find common prefix p = os.path.commonprefix(completions) - if len(p)>len(self.getCommand()): + if len(p)>len(lastword): self.hide_completions() - self.setCommand(p) + self.setCommand(beginning + p) else: self.show_completions(completions)