nncli

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

commit 9037c8f5e68459fb4bdbc48bc6970ba9cbfa68e5
parent 5e8fbb3a98a752fad0620ce31ca338d3c2fd96b4
Author: Shawn Axsom <axs221@gmail.com>
Date:   Sat,  7 Mar 2015 21:39:27 -0500

Have basic note searching working

Diffstat:
Msimplenote_cli/sncli.py | 2+-
Msimplenote_cli/view_note.py | 13+++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/simplenote_cli/sncli.py b/simplenote_cli/sncli.py @@ -320,7 +320,7 @@ def gui_search_input(self, args, search_string): self.master_frame.keypress = self.gui_frame_keypress if search_string: if (self.gui_body_get() == self.view_note): - self.view_note.update_note_view() + self.view_note.update_note_view(search_string=search_string, search_mode=args[0]) else: self.view_titles.update_note_list(search_string, args[0]) self.gui_body_set(self.view_titles) diff --git a/simplenote_cli/view_note.py b/simplenote_cli/view_note.py @@ -12,6 +12,7 @@ def __init__(self, config, args): self.ndb = args['ndb'] self.key = args['key'] self.log = args['log'] + self.search_string = '' self.note = self.ndb.get_note(self.key) if self.key else None self.old_note = None self.tabstop = int(self.config.get_config('tabstop')) @@ -37,7 +38,8 @@ def get_note_content_as_list(self): lines.append(urwid.AttrMap(urwid.Divider(u'-'), 'default')) return lines - def update_note_view(self, key=None, version=None): + def update_note_view(self, key=None, version=None, search_string=None, search_mode='gstyle'): + self.search_string = search_string if key: # setting a new note self.key = key self.note = self.ndb.get_note(self.key) @@ -69,7 +71,14 @@ def update_note_view(self, key=None, version=None): self.body[:] = \ urwid.SimpleFocusListWalker(self.get_note_content_as_list()) - # self.focus_position = 0 # TODO -I need to set this on update + if self.search_string: + for line in range(self.focus_position, len(self.body.positions())): + line_content = self.note['content'].split('\n')[line] + if (search_string in line_content): + self.focus_position = line + break + else: + self.focus_position = 0 def get_status_bar(self): if not self.key: