nncli

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

commit f13c3a7c0207d7dcdd85ebf94b8700c1ff873180
parent f8f7770a8906ec847942aa87dcd30a60ee74b524
Author: Eric Davis <edavis@insanum.com>
Date:   Sun,  6 Jul 2014 16:22:02 -0700

new keybind command for trashing a note

Diffstat:
Mconfig.py | 2++
Msncli.py | 30+++++++++++++++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/config.py b/config.py @@ -33,6 +33,7 @@ def __init__(self): 'kb_bottom' : 'G', 'kb_top' : 'g', 'kb_status' : 's', + 'kb_delete_note' : 'D', 'kb_create_note' : 'C', 'kb_edit_note' : 'e', 'kb_view_note' : 'enter', @@ -133,6 +134,7 @@ def __init__(self): 'top' : [ cp.get(cfg_sec, 'kb_top'), [ 'common' ], 'Goto top' ], 'status' : [ cp.get(cfg_sec, 'kb_status'), [ 'common' ], 'Toggle status bar' ], 'view_log' : [ cp.get(cfg_sec, 'kb_view_log'), [ 'common' ], 'View log' ], + 'delete_note' : [ cp.get(cfg_sec, 'kb_delete_note'), [ 'titles' ], 'Delete a note' ], 'create_note' : [ cp.get(cfg_sec, 'kb_create_note'), [ 'titles' ], 'Create a new note' ], 'edit_note' : [ cp.get(cfg_sec, 'kb_edit_note'), [ 'titles' ], 'Edit note' ], 'view_note' : [ cp.get(cfg_sec, 'kb_view_note'), [ 'titles' ], 'View note' ], diff --git a/sncli.py b/sncli.py @@ -339,6 +339,11 @@ def frame_keypress(self, size, key): else: self.status_bar = self.config.get_config('status_bar') + elif key == self.config.get_keybind('delete_note'): + if self.body_get().__class__ == view_titles.ViewTitles: + note = lb.note_list[lb.focus_position].note + self.ndb.set_note_deleted(note['key']) + elif key == self.config.get_keybind('create_note'): if self.body_get().__class__ == view_titles.ViewTitles: editor = self.get_editor() @@ -374,13 +379,14 @@ def frame_keypress(self, size, key): if md5_old != md5_new: self.status_message_set(u'Note updated') self.ndb.set_note_content(note['key'], new_content) + lb.update_note_title(None) temp.tempfile_delete(tf) 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']) + note = lb.note_list[lb.focus_position].note + self.view_note.update_note(note['key']) self.switch_frame_body(self.view_note) elif key == self.config.get_keybind('view_note_ext'): @@ -402,6 +408,7 @@ def frame_keypress(self, size, key): if md5_old != md5_new: self.status_message_set(u'Note updated') self.ndb.set_note_content(note['key'], new_content) + lb.update_note_title(None) temp.tempfile_delete(tf) elif key == self.config.get_keybind('view_next_note'): @@ -444,40 +451,41 @@ def frame_keypress(self, size, key): elif key == self.config.get_keybind('note_pin'): # pin note when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: - self.ndb.set_note_pinned( - lb.note_list[lb.focus_position].note['key'], 1) + note = lb.note_list[lb.focus_position].note + self.ndb.set_note_pinned(note['key'], 1) lb.update_note_title(None) elif key == self.config.get_keybind('note_unpin'): # unpin note when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: - self.ndb.set_note_pinned( - lb.note_list[lb.focus_position].note['key'], 0) + note = lb.note_list[lb.focus_position].note + self.ndb.set_note_pinned(note['key'], 0) lb.update_note_title(None) elif key == self.config.get_keybind('note_markdown'): # markdown note when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: - self.ndb.set_note_markdown( - lb.note_list[lb.focus_position].note['key'], 1) + note = lb.note_list[lb.focus_position].note + self.ndb.set_note_markdown(note['key'], 1) lb.update_note_title(None) elif key == self.config.get_keybind('note_unmarkdown'): # unmarkdown note when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: - self.ndb.set_note_markdown( - lb.note_list[lb.focus_position].note['key'], 0) + note = lb.note_list[lb.focus_position].note + self.ndb.set_note_markdown(note['key'], 0) lb.update_note_title(None) elif key == self.config.get_keybind('note_tags'): # edit tags when viewing the note list if self.body_get().__class__ == view_titles.ViewTitles: + note = lb.note_list[lb.focus_position].note self.status_message_cancel() self.footer_set( urwid.AttrMap( user_input.UserInput(self.config, 'Tags: ', - '%s' % ','.join(lb.note_list[lb.focus_position].note['tags']), + '%s' % ','.join(note['tags']), self.tags_input), 'search_bar')) self.footer_focus()