nncli

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

commit 17b8c753827c3dc8bb98d942220255bd8c11477d
parent ea9051f592ec9a13458e19d65b2d1a98bf34a3ec
Author: Eric Davis <edavis@insanum.com>
Date:   Thu,  3 Jul 2014 02:37:25 -0700

added new view next/previous note keybind commands

Diffstat:
Mconfig.py | 4++++
Msncli.py | 48+++++++++++++++++++++++++++++++++++++-----------
Mview_help.py | 5+++--
3 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/config.py b/config.py @@ -34,6 +34,8 @@ def __init__(self): 'kb_status' : 's', 'kb_view_note' : 'enter', 'kb_view_note_ext' : 'meta enter', + 'kb_view_next_note' : 'J', + 'kb_view_prev_note' : 'K', 'kb_view_log' : 'l', 'kb_tabstop2' : '2', 'kb_tabstop4' : '4', @@ -126,6 +128,8 @@ def __init__(self): 'status' : [ cp.get(cfg_sec, 'kb_status'), 'Toggle status bar' ], 'view_note' : [ cp.get(cfg_sec, 'kb_view_note'), 'View note' ], 'view_note_ext' : [ cp.get(cfg_sec, 'kb_view_note_ext'), 'View note with pager' ], + 'view_next_note' : [ cp.get(cfg_sec, 'kb_view_next_note'), 'View next note' ], + 'view_prev_note' : [ cp.get(cfg_sec, 'kb_view_prev_note'), 'View previous note' ], 'view_log' : [ cp.get(cfg_sec, 'kb_view_log'), 'View log' ], 'tabstop2' : [ cp.get(cfg_sec, 'kb_tabstop2'), 'View with tabstop=2' ], 'tabstop4' : [ cp.get(cfg_sec, 'kb_tabstop4'), 'View with tabstop=4' ], diff --git a/sncli.py b/sncli.py @@ -236,24 +236,24 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('down'): if len(lb.body.positions()) <= 0: - return + return None last = len(lb.body.positions()) if lb.focus_position == (last - 1): - return + return None lb.focus_position += 1 lb.render(size) elif key == self.config.get_keybind('up'): if len(lb.body.positions()) <= 0: - return + return None if lb.focus_position == 0: - return + return None lb.focus_position -= 1 lb.render(size) elif key == self.config.get_keybind('page_down'): if len(lb.body.positions()) <= 0: - return + return None last = len(lb.body.positions()) next_focus = lb.focus_position + size[1] if next_focus >= last: @@ -264,7 +264,7 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('page_up'): if len(lb.body.positions()) <= 0: - return + return None if 'bottom' in lb.ends_visible(size): last = len(lb.body.positions()) next_focus = last - size[1] - size[1] @@ -278,7 +278,7 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('half_page_down'): if len(lb.body.positions()) <= 0: - return + return None last = len(lb.body.positions()) next_focus = lb.focus_position + (size[1] / 2) if next_focus >= last: @@ -289,7 +289,7 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('half_page_up'): if len(lb.body.positions()) <= 0: - return + return None if 'bottom' in lb.ends_visible(size): last = len(lb.body.positions()) next_focus = last - size[1] - (size[1] / 2) @@ -303,14 +303,14 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('bottom'): if len(lb.body.positions()) <= 0: - return + return None lb.change_focus(size, (len(lb.body.positions()) - 1), offset_inset=0, coming_from='above') elif key == self.config.get_keybind('top'): if len(lb.body.positions()) <= 0: - return + return None lb.change_focus(size, 0, offset_inset=0, coming_from='below') @@ -324,7 +324,8 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('view_note'): # only when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: - self.view_note.update_note(lb.note_list[lb.focus_position].note['key']) + self.view_note.update_note( + lb.note_list[lb.focus_position].note['key']) self.switch_frame_body(self.view_note) elif key == self.config.get_keybind('view_note_ext'): @@ -348,6 +349,31 @@ def frame_keypress(self, size, key): # XXX check if modified, if so update it temp.tempfile_delete(tf) + elif key == self.config.get_keybind('view_next_note'): + # only when viewing the note content + if self.body_get().__class__ == view_note.ViewNote: + if len(self.view_titles.body.positions()) <= 0: + return None + last = len(self.view_titles.body.positions()) + if self.view_titles.focus_position == (last - 1): + return None + self.view_titles.focus_position += 1 + lb.update_note( + self.view_titles.note_list[self.view_titles.focus_position].note['key']) + self.switch_frame_body(self.view_note) + + elif key == self.config.get_keybind('view_prev_note'): + # only when viewing the note content + if self.body_get().__class__ == view_note.ViewNote: + if len(self.view_titles.body.positions()) <= 0: + return None + if self.view_titles.focus_position == 0: + return None + self.view_titles.focus_position -= 1 + lb.update_note( + self.view_titles.note_list[self.view_titles.focus_position].note['key']) + self.switch_frame_body(self.view_note) + elif key == self.config.get_keybind('search'): # search when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: diff --git a/view_help.py b/view_help.py @@ -26,6 +26,7 @@ def __init__(self, config): # NoteTitles keybinds keys = [ 'note_pin', 'note_unpin', + 'note_tags', 'search', 'clear_search', 'view_note', @@ -33,8 +34,8 @@ def __init__(self, config): lines.extend(self.create_kb_help_lines(u"Keybinds Note List", keys)) # NoteContent keybinds - keys = [ 'note_pin', - 'note_unpin', + keys = [ 'view_next_note', + 'view_prev_note', 'tabstop2', 'tabstop4', 'tabstop8' ]