nncli

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

commit bed564893212755687fe278b87af2126f5661d0b
parent b29c466b5daf80f3cfc7d6aaea7014ce51e42f95
Author: Eric Davis <edavis@insanum.com>
Date:   Thu,  3 Jul 2014 13:03:01 -0700

added new keybind commands for flagging a note as markdown or not

Diffstat:
Mconfig.py | 100+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mnotes_db.py | 2+-
Msncli.py | 14++++++++++++++
Mview_help.py | 2++
4 files changed, 69 insertions(+), 49 deletions(-)

diff --git a/config.py b/config.py @@ -21,30 +21,32 @@ def __init__(self): 'cfg_pager' : 'less -c', 'cfg_log_reversed' : 'yes', - 'kb_help' : 'h', - 'kb_quit' : 'q', - 'kb_down' : 'j', - 'kb_up' : 'k', - 'kb_page_down' : ' ', - 'kb_page_up' : 'b', - 'kb_half_page_down' : 'ctrl d', - 'kb_half_page_up' : 'ctrl u', - 'kb_bottom' : 'G', - 'kb_top' : 'g', - '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', - 'kb_tabstop8' : '8', - 'kb_search' : '/', - 'kb_clear_search' : 'a', - 'kb_note_pin' : 'p', - 'kb_note_unpin' : 'u', - 'kb_note_tags' : 't', + 'kb_help' : 'h', + 'kb_quit' : 'q', + 'kb_down' : 'j', + 'kb_up' : 'k', + 'kb_page_down' : ' ', + 'kb_page_up' : 'b', + 'kb_half_page_down' : 'ctrl d', + 'kb_half_page_up' : 'ctrl u', + 'kb_bottom' : 'G', + 'kb_top' : 'g', + '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', + 'kb_tabstop8' : '8', + 'kb_search' : '/', + 'kb_clear_search' : 'a', + 'kb_note_pin' : 'p', + 'kb_note_unpin' : 'P', + 'kb_note_markdown' : 'm', + 'kb_note_unmarkdown' : 'M', + 'kb_note_tags' : 't', 'clr_default_fg' : 'default', 'clr_default_bg' : 'default', @@ -115,30 +117,32 @@ def __init__(self): self.keybinds = \ { - 'help' : [ cp.get(cfg_sec, 'kb_help'), 'Help' ], - 'quit' : [ cp.get(cfg_sec, 'kb_quit'), 'Quit' ], - 'down' : [ cp.get(cfg_sec, 'kb_down'), 'Scroll down one line' ], - 'up' : [ cp.get(cfg_sec, 'kb_up'), 'Scroll up one line' ], - 'page_down' : [ cp.get(cfg_sec, 'kb_page_down'), 'Page down' ], - 'page_up' : [ cp.get(cfg_sec, 'kb_page_up'), 'Page up' ], - 'half_page_down' : [ cp.get(cfg_sec, 'kb_half_page_down'), 'Half page down' ], - 'half_page_up' : [ cp.get(cfg_sec, 'kb_half_page_up'), 'Half page up' ], - 'bottom' : [ cp.get(cfg_sec, 'kb_bottom'), 'Goto bottom' ], - 'top' : [ cp.get(cfg_sec, 'kb_top'), 'Goto top' ], - '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' ], - 'tabstop8' : [ cp.get(cfg_sec, 'kb_tabstop8'), 'View with tabstop=8' ], - 'search' : [ cp.get(cfg_sec, 'kb_search'), 'Search notes' ], - 'clear_search' : [ cp.get(cfg_sec, 'kb_clear_search'), 'Show all notes' ], - 'note_pin' : [ cp.get(cfg_sec, 'kb_note_pin'), 'Pin note' ], - 'note_unpin' : [ cp.get(cfg_sec, 'kb_note_unpin'), 'Unpin note' ], - 'note_tags' : [ cp.get(cfg_sec, 'kb_note_tags'), 'Edit note tags' ] + 'help' : [ cp.get(cfg_sec, 'kb_help'), 'Help' ], + 'quit' : [ cp.get(cfg_sec, 'kb_quit'), 'Quit' ], + 'down' : [ cp.get(cfg_sec, 'kb_down'), 'Scroll down one line' ], + 'up' : [ cp.get(cfg_sec, 'kb_up'), 'Scroll up one line' ], + 'page_down' : [ cp.get(cfg_sec, 'kb_page_down'), 'Page down' ], + 'page_up' : [ cp.get(cfg_sec, 'kb_page_up'), 'Page up' ], + 'half_page_down' : [ cp.get(cfg_sec, 'kb_half_page_down'), 'Half page down' ], + 'half_page_up' : [ cp.get(cfg_sec, 'kb_half_page_up'), 'Half page up' ], + 'bottom' : [ cp.get(cfg_sec, 'kb_bottom'), 'Goto bottom' ], + 'top' : [ cp.get(cfg_sec, 'kb_top'), 'Goto top' ], + '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' ], + 'tabstop8' : [ cp.get(cfg_sec, 'kb_tabstop8'), 'View with tabstop=8' ], + 'search' : [ cp.get(cfg_sec, 'kb_search'), 'Search notes' ], + 'clear_search' : [ cp.get(cfg_sec, 'kb_clear_search'), 'Show all notes' ], + 'note_pin' : [ cp.get(cfg_sec, 'kb_note_pin'), 'Pin note' ], + 'note_unpin' : [ cp.get(cfg_sec, 'kb_note_unpin'), 'Unpin note' ], + 'note_markdown' : [ cp.get(cfg_sec, 'kb_note_markdown'), 'Flag note as markdown' ], + 'note_unmarkdown' : [ cp.get(cfg_sec, 'kb_note_unmarkdown'), 'Unflag note as markdown' ], + 'note_tags' : [ cp.get(cfg_sec, 'kb_note_tags'), 'Edit note tags' ] } self.colors = \ diff --git a/notes_db.py b/notes_db.py @@ -403,7 +403,7 @@ def set_note_markdown(self, key, markdown): self.notify_observers('change:note-status', utils.KeyValueObject(what='modifydate', key=key, - msg='Note markdown flagged.' if pinned else 'Note markdown unflagged.')) + msg='Note markdown flagged.' if markdown else 'Note markdown unflagged.')) self.flag_what_changed(n, 'systemtags') def helper_key_to_fname(self, k): diff --git a/sncli.py b/sncli.py @@ -400,6 +400,20 @@ def frame_keypress(self, size, key): lb.note_list[lb.focus_position].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) + 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) + 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: diff --git a/view_help.py b/view_help.py @@ -26,6 +26,8 @@ def __init__(self, config): # NoteTitles keybinds keys = [ 'note_pin', 'note_unpin', + 'note_markdown', + 'note_unmarkdown', 'note_tags', 'search', 'clear_search',