frontend, primitivus: added input history (mode-wise)

This commit is contained in:
souliane 2013-11-07 16:58:20 +01:00
commit 7b4fa64df8

View file

@ -31,6 +31,7 @@ from sat_frontends.primitivus.gateways import GatewaysManager
from sat_frontends.primitivus.xmlui import XMLUI
from sat_frontends.primitivus.progress import Progress
from sat_frontends.primitivus.notify import Notify
from sat.tools.frontend.misc import InputHistory
import sat_frontends.primitivus.constants
import logging
from logging import debug, info, error
@ -120,15 +121,30 @@ class EditBar(sat_widgets.ModalEdit):
raise urwid.ExitMainLoop()
def keypress(self, size, key):
"""Callback when a key is pressed. Send "composing" states."""
if key != "enter":
"""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 == "esc":
self.app._updateInputHistory(mode='NORMAL')
if self._mode == 'NORMAL' and key in self._modes:
self.app._updateInputHistory(mode=self._modes[key][0])
if key == "up":
self.app._updateInputHistory(self.get_edit_text(), -1, history_cb, self.mode)
elif key == "down":
self.app._updateInputHistory(self.get_edit_text(), +1, history_cb, self.mode)
elif key == "enter":
self.app._updateInputHistory(self.get_edit_text(), mode=self.mode)
else:
contact = self.app.contact_list.getContact()
if contact:
self.app.bridge.chatStateComposing(unescapePrivate(contact), self.app.profile)
return super(EditBar, self).keypress(size, key)
return super(EditBar, self).keypress(size, key)
class PrimitivusApp(QuickApp):
class PrimitivusApp(QuickApp, InputHistory):
def __init__(self):
QuickApp.__init__(self)