nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 1d260d29cfcfc9c130ac0cc1f6d578772d33f289
parent 6c68d6869a7a6344e17850a490e11ecdb6db9ca7
Author: Eric Davis <edavis@insanum.com>
Date:   Wed,  2 Jul 2014 14:02:18 -0700

generic user input class

Diffstat:
Dsearch_notes.py | 20--------------------
Auser_input.py | 22++++++++++++++++++++++
2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/search_notes.py b/search_notes.py @@ -1,20 +0,0 @@ - -import urwid - -class SearchNotes(urwid.Edit): - - def __init__(self, config, key, callback_obj): - self.config = config - self.callback_obj = callback_obj - super(SearchNotes, self).__init__(key, wrap='clip') - - def keypress(self, size, key): - size = (size[0],) # if this isn't here then urwid freaks out... - if key == 'esc': - self.callback_obj.search_quit() - elif key == 'enter': - self.callback_obj.search_complete(self.edit_text) - else: - return super(SearchNotes, self).keypress(size, key) - return None - diff --git a/user_input.py b/user_input.py @@ -0,0 +1,22 @@ + +import urwid + +class UserInput(urwid.Edit): + + def __init__(self, config, caption, edit_text, callback_func): + self.config = config + self.callback_func = callback_func + super(UserInput, self).__init__(caption=caption, + edit_text=edit_text, + wrap='clip') + + def keypress(self, size, key): + size = (size[0],) # if this isn't here then urwid freaks out... + if key == 'esc': + self.callback_func(None) + elif key == 'enter': + self.callback_func(self.edit_text) + else: + return super(UserInput, self).keypress(size, key) + return None +