Skip to content

Commit

Permalink
Make the Enter key proceed with password generation
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Aug 28, 2018
1 parent 0f5ac32 commit b52f11d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion upass/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ def mouse_event(self, size, event, button, col, row, focus):
size, event, button, col, row, focus)


class EditWithEnter(urwid.Edit):
kw_enter_handler = None

def __init__(self, *args, **kwargs):
if 'enter_handler' in kwargs:
self.enter_handler = kwargs.pop('enter_handler')
super(EditWithEnter, self).__init__(*args, **kwargs)

def keypress(self, size, key):
if key == 'enter' and self.enter_handler:
self.enter_handler(self)
return super(EditWithEnter, self).keypress(size, key)


class App(object):

"""The upass app object."""
Expand Down Expand Up @@ -287,7 +301,9 @@ def generate_password(self, originator, args=None):
path = self.current + '/'
self.set_header('GENERATE PASSWORD')
self._clear_box()
self.generate_password_path = urwid.Edit(("highlight", "Password Name: "), path)
self.generate_password_path = EditWithEnter(
("highlight", "Password Name: "), path, multiline=False,
enter_handler=self.call_generate)
self.generate_password_length = urwid.IntEdit("Length: ", default=length)
self.generate_password_symbols = urwid.CheckBox("Symbols", state=symbols)
self.generate_password_force = urwid.CheckBox("Overwrite existing passwords with that name", state=force)
Expand Down

0 comments on commit b52f11d

Please sign in to comment.