nncli

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

commit 7f2d0e1f5d0a0e19180c414dc1d9f810387b31f9
parent 48c6bb14144b53694a3772eaf0299045e42c1551
Author: Eric Davis <edavis@insanum.com>
Date:   Sun, 29 Jun 2014 15:06:39 -0700

new interface for displaying status messages

Diffstat:
Mconfig.py | 4++++
Msncli.py | 22++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/config.py b/config.py @@ -44,6 +44,8 @@ def __init__(self): 'clr_default_bg' : 'default', 'clr_status_bar_fg' : 'dark gray', 'clr_status_bar_bg' : 'light gray', + 'clr_status_message_fg' : 'dark gray', + 'clr_status_message_bg' : 'light gray', 'clr_search_bar_fg' : 'white', 'clr_search_bar_bg' : 'light red', 'clr_note_focus_fg' : 'white', @@ -133,6 +135,8 @@ def __init__(self): 'default_bg' : [ cp.get(cfg_sec, 'clr_default_bg'), 'Default bg' ], 'status_bar_fg' : [ cp.get(cfg_sec, 'clr_status_bar_fg'), 'Status bar fg' ], 'status_bar_bg' : [ cp.get(cfg_sec, 'clr_status_bar_bg'), 'Status bar bg' ], + 'status_message_fg' : [ cp.get(cfg_sec, 'clr_status_message_fg'), 'Status message fg' ], + 'status_message_bg' : [ cp.get(cfg_sec, 'clr_status_message_bg'), 'Status message bg' ], 'search_bar_fg' : [ cp.get(cfg_sec, 'clr_search_bar_fg'), 'Search bar fg' ], 'search_bar_bg' : [ cp.get(cfg_sec, 'clr_search_bar_bg'), 'Search bar bg' ], 'note_focus_fg' : [ cp.get(cfg_sec, 'clr_note_focus_fg'), 'Note title focus fg' ], diff --git a/sncli.py b/sncli.py @@ -244,6 +244,22 @@ def push_last_view(view): def pop_last_view(): return self.last_view.pop() + def remove_status_message(loop, frame): + frame.contents['footer'] = ( None, None ) + + def cancel_status_message(frame): + if frame.alarm: + sncli_loop.remove_alarm(frame.alarm) + frame.contents['footer'] = ( None, None ) + + def set_status_message(frame, msg): + t = urwid.AttrMap(urwid.Text(msg, wrap='clip'), + 'status_message') + frame.contents['footer'] = ( t, None ) + frame.alarm = sncli_loop.set_alarm_at(time.time() + 5, + remove_status_message, + frame); + def tempfile_name(): if self.tempfile: return self.tempfile.name @@ -373,6 +389,7 @@ def keypress(self, size, key): class NoteTitles(urwid.Frame): def __init__(self): self.config = get_config() + self.alarm = None self.status_bar = self.config.get_config('status_bar') super(NoteTitles, self).__init__(body=None, header=None, @@ -393,6 +410,8 @@ def update_note_titles(self, search_string): self.contents['body'] = ( self.listbox, None ); self.contents['footer'] = ( None, None ); self.update_status() + if len(self.listbox.body.positions()) == 0: + set_status_message(self, 'No notes found!') def update_status(self): if self.status_bar != 'yes': @@ -802,6 +821,9 @@ def help_listbox_keypress(self, size, key): ('status_bar', self.config.get_color('status_bar_fg'), self.config.get_color('status_bar_bg') ), + ('status_message', + self.config.get_color('status_message_fg'), + self.config.get_color('status_message_bg') ), ('search_bar', self.config.get_color('search_bar_fg'), self.config.get_color('search_bar_bg') ),