X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=patches%2Fterminal_velocity_sort_found_notes.patch;fp=patches%2Fterminal_velocity_sort_found_notes.patch;h=0000000000000000000000000000000000000000;hb=8c4f6e37479002818bcfe7381cd4e4b47fd2d1fb;hp=2bc563c6b942996071d0e110a818f04190c87ef0;hpb=c79bb68270abd6e5a59e36bf09d64b2eb0d23fb8;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/patches/terminal_velocity_sort_found_notes.patch b/patches/terminal_velocity_sort_found_notes.patch deleted file mode 100644 index 2bc563c..0000000 --- a/patches/terminal_velocity_sort_found_notes.patch +++ /dev/null @@ -1,73 +0,0 @@ -commit 0f9df37046e58c8963aff93c649e5d3dbf2202bd -Author: Ismaël Bouya -Date: Sat Mar 9 20:11:46 2019 +0100 - - Add sorting option - -diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py -index a53eda3..5f0e213 100755 ---- a/terminal_velocity/terminal_velocity.py -+++ b/terminal_velocity/terminal_velocity.py -@@ -90,6 +90,10 @@ the default default will be used""" - default=defaults.get("log_file", "~/.tvlog"), - help="the file to log to (default: %(default)s)") - -+ parser.add_argument("-s", "--sort", dest="sort", action="store", -+ default=defaults.get("sort", "date"), -+ help="the note sorting rules. Possible values: date, title (default: %(default)s)") -+ - parser.add_argument("-p", "--print-config", dest="print_config", - action="store_true", default=False, - help="print your configuration settings then exit") -@@ -138,7 +142,7 @@ the default default will be used""" - try: - urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor, - extension=args.extension, extensions=args.extensions, -- exclude=args.exclude) -+ exclude=args.exclude, sort=args.sort) - except KeyboardInterrupt: - # Run the shutdown hook - shutdown() -diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py -index 34cf4f6..caebcb9 100644 ---- a/terminal_velocity/urwid_ui.py -+++ b/terminal_velocity/urwid_ui.py -@@ -237,11 +237,12 @@ class NoteFilterListBox(urwid.ListBox): - class MainFrame(urwid.Frame): - """The topmost urwid widget.""" - -- def __init__(self, notes_dir, editor, extension, extensions, exclude=None): -+ def __init__(self, notes_dir, editor, extension, extensions, exclude=None, sort="date"): - - self.editor = editor - self.notebook = notebook.PlainTextNoteBook(notes_dir, extension, - extensions, exclude=exclude) -+ self.sort = sort - - # Don't filter the note list when the text in the search box changes. - self.suppress_filter = False -@@ -408,7 +409,10 @@ class MainFrame(urwid.Frame): - - # Sort the notes. - # TODO: Support different sort orderings. -- matching_notes.sort(key=lambda x: x.mtime, reverse=True) -+ if self.sort == "title": -+ matching_notes.sort(key=lambda x: x.title) -+ else: -+ matching_notes.sort(key=lambda x: x.mtime, reverse=True) - - # Tell the list box to show only the matching notes. - self.list_box.filter(matching_notes) -@@ -433,10 +437,10 @@ class MainFrame(urwid.Frame): - self.selected_note = note - - --def launch(notes_dir, editor, extension, extensions, exclude=None): -+def launch(notes_dir, editor, extension, extensions, exclude=None, sort="date"): - """Launch the user interface.""" - -- frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude) -+ frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude, sort=sort) - loop = urwid.MainLoop(frame, palette) - frame.loop = loop - loop.run()