nncli

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

commit b7a3a6bff444765174c4838ac909134b6d8f1891
parent 84ab7c29061f8b67bed5d18a518ea5117e06dfdd
Author: Eric Davis <edavis@insanum.com>
Date:   Mon, 14 Jul 2014 22:31:53 -0700

new keybind for user input/selection of a specific note version

Diffstat:
Mconfig.py | 10++++++----
Msncli.py | 59++++++++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/config.py b/config.py @@ -49,6 +49,7 @@ def __init__(self): 'kb_prev_version' : '<', 'kb_next_version' : '>', 'kb_latest_version' : 'L', + 'kb_select_version' : '#', 'kb_search_gstyle' : '/', 'kb_search_regex' : 'meta /', 'kb_clear_search' : 'A', @@ -65,8 +66,8 @@ def __init__(self): 'clr_status_bar_bg' : 'light gray', 'clr_log_fg' : 'dark gray', 'clr_log_bg' : 'light gray', - 'clr_search_bar_fg' : 'white', - 'clr_search_bar_bg' : 'light red', + 'clr_user_input_bar_fg' : 'white', + 'clr_user_input_bar_bg' : 'light red', 'clr_note_focus_fg' : 'white', 'clr_note_focus_bg' : 'light red', 'clr_note_title_day_fg' : 'light red', @@ -159,6 +160,7 @@ def __init__(self): self.keybinds['prev_version'] = [ cp.get(cfg_sec, 'kb_prev_version'), [ 'notes' ], 'View previous version' ] self.keybinds['next_version'] = [ cp.get(cfg_sec, 'kb_next_version'), [ 'notes' ], 'View next version' ] self.keybinds['latest_version'] = [ cp.get(cfg_sec, 'kb_latest_version'), [ 'notes' ], 'View latest version' ] + self.keybinds['select_version'] = [ cp.get(cfg_sec, 'kb_select_version'), [ 'notes' ], 'Select version' ] self.keybinds['search_gstyle'] = [ cp.get(cfg_sec, 'kb_search_gstyle'), [ 'titles' ], 'Search using gstyle' ] self.keybinds['search_regex'] = [ cp.get(cfg_sec, 'kb_search_regex'), [ 'titles' ], 'Search using regex' ] self.keybinds['clear_search'] = [ cp.get(cfg_sec, 'kb_clear_search'), [ 'titles' ], 'Show all notes' ] @@ -176,8 +178,8 @@ def __init__(self): self.colors['status_bar_bg'] = [ cp.get(cfg_sec, 'clr_status_bar_bg'), 'Status bar bg' ] self.colors['log_fg'] = [ cp.get(cfg_sec, 'clr_log_fg'), 'Log message fg' ] self.colors['log_bg'] = [ cp.get(cfg_sec, 'clr_log_bg'), 'Log message bg' ] - self.colors['search_bar_fg'] = [ cp.get(cfg_sec, 'clr_search_bar_fg'), 'Search bar fg' ] - self.colors['search_bar_bg'] = [ cp.get(cfg_sec, 'clr_search_bar_bg'), 'Search bar bg' ] + self.colors['user_input_bar_fg'] = [ cp.get(cfg_sec, 'clr_user_input_bar_fg'), 'User input bar fg' ] + self.colors['user_input_bar_bg'] = [ cp.get(cfg_sec, 'clr_user_input_bar_bg'), 'User input bar bg' ] self.colors['note_focus_fg'] = [ cp.get(cfg_sec, 'clr_note_focus_fg'), 'Note title focus fg' ] self.colors['note_focus_bg'] = [ cp.get(cfg_sec, 'clr_note_focus_bg'), 'Note title focus bg' ] self.colors['note_title_day_fg'] = [ cp.get(cfg_sec, 'clr_note_title_day_fg'), 'Day old note title fg' ] diff --git a/sncli.py b/sncli.py @@ -236,6 +236,20 @@ def gui_search_input(self, args, search_string): self.view_titles.update_note_list(search_string, args[0]) self.gui_body_set(self.view_titles) + def gui_version_input(self, args, next_note_version): + self.gui_footer_input_clear() + self.gui_body_focus() + self.master_frame.keypress = self.gui_frame_keypress + if next_note_version: + # XXX verify version number + self.log(u'Fetching version v{0} of note (key={1})'. + format(next_note_version, self.view_note.key)) + next_note = self.ndb.get_note_version(self.view_note.key, next_note_version) + self.view_note.old_note_version = next_note_version + self.view_note.old_note = next_note + self.view_note.update_note() + self.gui_update_status_bar() + def gui_tags_input(self, args, tags): self.gui_footer_input_clear() self.gui_body_focus() @@ -398,15 +412,6 @@ def gui_frame_keypress(self, size, key): self.view_titles.note_list[self.view_titles.focus_position].note['key']) self.gui_switch_frame_body(self.view_note) - elif key == self.config.get_keybind('latest_version'): - if self.gui_body_get().__class__ != view_note.ViewNote: - return key - - self.view_note.old_note_version = None - self.view_note.old_note = None - - lb.update_note() - elif key == self.config.get_keybind('prev_version') or \ key == self.config.get_keybind('next_version'): if self.gui_body_get().__class__ != view_note.ViewNote: @@ -445,6 +450,30 @@ def gui_frame_keypress(self, size, key): lb.update_note() + elif key == self.config.get_keybind('latest_version'): + if self.gui_body_get().__class__ != view_note.ViewNote: + return key + + self.view_note.old_note_version = None + self.view_note.old_note = None + + lb.update_note() + + elif key == self.config.get_keybind('select_version'): + if self.gui_body_get().__class__ != view_note.ViewNote: + return key + + self.gui_footer_input_set( + urwid.AttrMap( + user_input.UserInput(self.config, + key, + '', + self.gui_version_input, + None), + 'user_input_bar')) + self.gui_footer_focus_input() + self.master_frame.keypress = self.gui_footer_input_get().keypress + elif key == self.config.get_keybind('status'): if self.status_bar == 'yes': self.status_bar = 'no' @@ -526,7 +555,7 @@ def gui_frame_keypress(self, size, key): '', self.gui_pipe_input, None), - 'search_bar')) + 'user_input_bar')) self.gui_footer_focus_input() self.master_frame.keypress = self.gui_footer_input_get().keypress @@ -611,7 +640,7 @@ def gui_frame_keypress(self, size, key): '%s' % ','.join(note['tags']), self.gui_tags_input, None), - 'search_bar')) + 'user_input_bar')) self.gui_footer_focus_input() self.master_frame.keypress = self.gui_footer_input_get().keypress @@ -629,7 +658,7 @@ def gui_frame_keypress(self, size, key): [ 'gstyle' \ if key == self.config.get_keybind('search_gstyle') else 'regex' ]), - 'search_bar')) + 'user_input_bar')) self.gui_footer_focus_input() self.master_frame.keypress = self.gui_footer_input_get().keypress @@ -728,9 +757,9 @@ def gui(self, key): ('log', self.config.get_color('log_fg'), self.config.get_color('log_bg') ), - ('search_bar', - self.config.get_color('search_bar_fg'), - self.config.get_color('search_bar_bg') ), + ('user_input_bar', + self.config.get_color('user_input_bar_fg'), + self.config.get_color('user_input_bar_bg') ), ('note_focus', self.config.get_color('note_focus_fg'), self.config.get_color('note_focus_bg') ),