nncli

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

commit 5e8fbb3a98a752fad0620ce31ca338d3c2fd96b4
parent 906145b47bd3b079887c535f0f8d540e9990a642
Author: Shawn Axsom <shawn.axsom@rooksecurity.com>
Date:   Sat,  7 Mar 2015 19:10:42 -0500

Started modifications, no progress yet

Diffstat:
A.gitignore | 2++
Msimplenote_cli/config.py | 6++++--
Msimplenote_cli/sncli.py | 17+++++++++++------
Msimplenote_cli/view_note.py | 22+++++++++++-----------
Msimplenote_cli/view_titles.py | 2+-
5 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +.ropeproject diff --git a/simplenote_cli/config.py b/simplenote_cli/config.py @@ -21,7 +21,8 @@ def __init__(self): 'cfg_format_note_title' : '[%D] %F %-N %T', 'cfg_status_bar' : 'yes', 'cfg_editor' : 'vim', - 'cfg_pager' : 'less -c', + # 'cfg_pager' : 'less -c', + 'cfg_pager' : 'vim -R', 'cfg_diff' : 'diff -b -U10', 'cfg_max_logs' : '5', 'cfg_log_timeout' : '5', @@ -41,8 +42,9 @@ def __init__(self): 'kb_status' : 's', 'kb_create_note' : 'C', 'kb_edit_note' : 'e', + # TODO - update this 'kb_view_note' : 'enter', - 'kb_view_note_ext' : 'meta enter', + 'kb_view_note_ext' : 'a', 'kb_view_note_json' : 'O', 'kb_pipe_note' : '|', 'kb_view_next_note' : 'J', diff --git a/simplenote_cli/sncli.py b/simplenote_cli/sncli.py @@ -11,6 +11,7 @@ from simplenote import Simplenote from notes_db import NotesDB, ReadError, WriteError from logging.handlers import RotatingFileHandler +import pdb class sncli: @@ -111,7 +112,7 @@ def exec_diff_on_note(self, note, old_note): out = temp.tempfile_create(None) try: - subprocess.call(diff + u' ' + + subprocess.call(diff + u' ' + temp.tempfile_name(ltf) + u' ' + temp.tempfile_name(otf) + u' > ' + temp.tempfile_name(out), @@ -310,7 +311,7 @@ def gui_yes_no_input(self, args, yes_no): self.gui_body_focus() self.master_frame.keypress = self.gui_frame_keypress args[0](args[1], - True if yes_no in [ 'YES', 'Yes', 'yes', 'Y', 'y' ] + True if yes_no in [ 'YES', 'Yes', 'yes', 'Y', 'y' ] else False) def gui_search_input(self, args, search_string): @@ -318,8 +319,11 @@ def gui_search_input(self, args, search_string): self.gui_body_focus() self.master_frame.keypress = self.gui_frame_keypress if search_string: - self.view_titles.update_note_list(search_string, args[0]) - self.gui_body_set(self.view_titles) + if (self.gui_body_get() == self.view_note): + self.view_note.update_note_view() + else: + self.view_titles.update_note_list(search_string, args[0]) + self.gui_body_set(self.view_titles) def gui_version_input(self, args, version): self.gui_footer_input_clear() @@ -769,7 +773,8 @@ def gui_frame_keypress(self, size, key): elif key == self.config.get_keybind('search_gstyle') or \ key == self.config.get_keybind('search_regex'): - if self.gui_body_get().__class__ != view_titles.ViewTitles: + if self.gui_body_get().__class__ != view_titles.ViewTitles and \ + self.gui_body_get().__class__ != view_note.ViewNote: return key self.gui_footer_input_set( @@ -835,7 +840,7 @@ def gui_stop(self): self.gui_clear() raise urwid.ExitMainLoop() else: - self.log(u'WARNING: Not all notes saved to disk (wait for sync worker)') + self.log(u'WARNING: Not all notes saved to disk (wait for sync worker)') def gui(self, key): diff --git a/simplenote_cli/view_note.py b/simplenote_cli/view_note.py @@ -69,7 +69,7 @@ def update_note_view(self, key=None, version=None): self.body[:] = \ urwid.SimpleFocusListWalker(self.get_note_content_as_list()) - self.focus_position = 0 + # self.focus_position = 0 # TODO -I need to set this on update def get_status_bar(self): if not self.key: @@ -103,8 +103,8 @@ def get_status_bar(self): 'status_bar') status_key_index = \ - ('pack', urwid.AttrMap(urwid.Text(u' [' + - self.key + + ('pack', urwid.AttrMap(urwid.Text(u' [' + + self.key + u'] ' + str(cur + 1) + u'/' + @@ -118,18 +118,18 @@ def get_status_bar(self): if self.old_note: status_tags_flags = \ - ('pack', urwid.AttrMap(urwid.Text(u'[OLD:v' + - str(version) + + ('pack', urwid.AttrMap(urwid.Text(u'[OLD:v' + + str(version) + u']'), 'status_bar')) else: status_tags_flags = \ - ('pack', urwid.AttrMap(urwid.Text(u'[' + - tags + - u'] [v' + - str(version) + - u'] [' + - flags + + ('pack', urwid.AttrMap(urwid.Text(u'[' + + tags + + u'] [v' + + str(version) + + u'] [' + + flags + u']'), 'status_bar')) diff --git a/simplenote_cli/view_titles.py b/simplenote_cli/view_titles.py @@ -26,7 +26,7 @@ def update_note_list(self, search_string, search_mode='gstyle'): if len(self.note_list) == 0: self.log(u'No notes found!') else: - self.focus_position = 0 + self.focus_position = 1 #TESTING def sort_note_list(self, sort_mode): self.ndb.filtered_notes_sort(self.note_list, sort_mode)