changeset 1160:2ff15a6c5791

primitivus: moved history method definition out of keypress
author Goffi <goffi@goffi.org>
date Thu, 04 Sep 2014 19:05:57 +0200
parents 85fd02356dba
children 344bbe6fd1de
files frontends/src/primitivus/primitivus
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Thu Sep 04 19:05:57 2014 +0200
+++ b/frontends/src/primitivus/primitivus	Thu Sep 04 19:05:57 2014 +0200
@@ -148,13 +148,13 @@
             return
         self.set_edit_text('')
 
+    def _historyCb(self, text):
+        self.set_edit_text(text)
+        self.set_edit_pos(len(text))
+
     def keypress(self, size, key):
         """Callback when a key is pressed. Send "composing" states
         and move the index of the temporary history stack."""
-        def history_cb(text):
-            self.set_edit_text(text)
-            self.set_edit_pos(len(text))
-
         if key == a_key['MODAL_ESCAPE']:
             # first save the text to the current mode, then change to NORMAL
             self.app._updateInputHistory(self.get_edit_text(), mode=self.mode)
@@ -162,10 +162,10 @@
         if self._mode == 'NORMAL' and key in self._modes:
             self.app._updateInputHistory(mode=self._modes[key][0])
         if key == a_key['HISTORY_PREV']:
-            self.app._updateInputHistory(self.get_edit_text(), -1, history_cb, self.mode)
+            self.app._updateInputHistory(self.get_edit_text(), -1, self._history_cb, self.mode)
             return
         elif key == a_key['HISTORY_NEXT']:
-            self.app._updateInputHistory(self.get_edit_text(), +1, history_cb, self.mode)
+            self.app._updateInputHistory(self.get_edit_text(), +1, self._history_cb, self.mode)
             return
         elif key == a_key['EDIT_ENTER']:
             self.app._updateInputHistory(self.get_edit_text(), mode=self.mode)