nncli

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

commit 63f407cf649bfa157dce7c5cd9d19a2f47933e0c
parent 817c7a0b0a912313c19cab3a7d42b9e1786e967e
Author: Eric Davis <edavis@insanum.com>
Date:   Thu, 10 Jul 2014 22:02:19 -0700

new keybind command to untrash a note

Diffstat:
Mconfig.py | 2++
Mnotes_db.py | 9+++++----
Msncli.py | 8+++++---
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/config.py b/config.py @@ -35,6 +35,7 @@ def __init__(self): 'kb_top' : 'g', 'kb_status' : 's', 'kb_trash_note' : 'T', + 'kb_untrash_note' : 'U', 'kb_create_note' : 'C', 'kb_edit_note' : 'e', 'kb_view_note' : 'enter', @@ -141,6 +142,7 @@ def __init__(self): self.keybinds['view_log'] = [ cp.get(cfg_sec, 'kb_view_log'), [ 'common' ], 'View log' ] self.keybinds['create_note'] = [ cp.get(cfg_sec, 'kb_create_note'), [ 'titles' ], 'Create a new note' ] self.keybinds['trash_note'] = [ cp.get(cfg_sec, 'kb_trash_note'), [ 'titles', 'notes' ], 'Trash a note' ] + self.keybinds['untrash_note'] = [ cp.get(cfg_sec, 'kb_untrash_note'), [ 'titles', 'notes' ], 'Untrash a note' ] self.keybinds['edit_note'] = [ cp.get(cfg_sec, 'kb_edit_note'), [ 'titles', 'notes' ], 'Edit note' ] self.keybinds['view_note'] = [ cp.get(cfg_sec, 'kb_view_note'), [ 'titles' ], 'View note' ] self.keybinds['view_note_ext'] = [ cp.get(cfg_sec, 'kb_view_note_ext'), [ 'titles', 'notes' ], 'View note with pager' ] diff --git a/notes_db.py b/notes_db.py @@ -300,13 +300,14 @@ def flag_what_changed(self, note, what_changed): if what_changed not in note['what_changed']: note['what_changed'].append(what_changed) - def set_note_deleted(self, key): + def set_note_deleted(self, key, deleted): n = self.notes[key] - if not n['deleted']: - n['deleted'] = 1 + if (not n['deleted'] and deleted) or \ + (n['deleted'] and not deleted): + n['deleted'] = deleted n['modifydate'] = time.time() self.flag_what_changed(n, 'deleted') - self.log('Note trashed (key={0})'.format(key)) + self.log('Note {0} (key={1})'.format('trashed' if deleted else 'untrashed', key)) def set_note_content(self, key, content): n = self.notes[key] diff --git a/sncli.py b/sncli.py @@ -338,9 +338,10 @@ def gui_frame_keypress(self, size, key): else: self.status_bar = self.config.get_config('status_bar') - elif key == self.config.get_keybind('trash_note'): + elif key == self.config.get_keybind('trash_note') or \ + key == self.config.get_keybind('untrash_note'): if self.gui_body_get().__class__ != view_titles.ViewTitles and \ - self.gui_body_get().__class__ != view_note.ViewNotes: + self.gui_body_get().__class__ != view_note.ViewNote: return key if self.gui_body_get().__class__ == view_titles.ViewTitles: @@ -350,7 +351,8 @@ def gui_frame_keypress(self, size, key): else: # self.gui_body_get().__class__ == view_note.ViewNote: note = lb.note - self.ndb.set_note_deleted(note['key']) + self.ndb.set_note_deleted(note['key'], + 1 if key == self.config.get_keybind('trash_note') else 0) elif key == self.config.get_keybind('create_note'): if self.gui_body_get().__class__ != view_titles.ViewTitles: