X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmodes%2Fthread-index-mode.rb;fp=lib%2Fsup%2Fmodes%2Fthread-index-mode.rb;h=6a6bd581035352a9762d7579b74e59cdd7bc04ad;hb=5c9abec637d9162e2c445e7d8f961b71f02fa820;hp=82f258b689681183614b65d6475829ba10d0563e;hpb=93ed1a68e1b4321b62bfd15600b04d3adb6f7c57;p=sup diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index 82f258b..6a6bd58 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -47,6 +47,7 @@ EOS k.add :tag_matching, "Tag matching threads", 'g' k.add :apply_to_tagged, "Apply next command to all tagged threads", '+', '=' k.add :join_threads, "Force tagged threads to be joined into the same thread", '#' + k.add :toggle_sort, "Toggle newest first/last sort order", 'o' k.add :undo, "Undo the previous action", 'u' end @@ -65,6 +66,8 @@ EOS @hidden_labels = hidden_labels + LabelManager::HIDDEN_RESERVED_LABELS @date_width = DATE_WIDTH + @newest_first = true + @interrupt_search = false initialize_threads # defines @ts and @ts_mutex @@ -219,10 +222,18 @@ EOS UndoManager.undo end + def toggle_sort + @newest_first = !@newest_first + update + end + def update @mutex.synchronize do ## let's see you do THIS in python - @threads = @ts.threads.select { |t| !@hidden_threads[t] }.sort_by { |t| [t.date, t.first.id] }.reverse + @threads = @ts.threads.select { |t| !@hidden_threads[t] }.sort_by { |t| [t.date, t.first.id] } + if @newest_first + @threads = @threads.reverse + end @size_widgets = @threads.map { |t| size_widget_for_thread t } @size_widget_width = @size_widgets.max_of { |w| w.display_length } end @@ -664,6 +675,9 @@ EOS else n = opts[:num] end + if !@newest_first + n = -1 + end myopts = @load_thread_opts.merge({ :when_done => (lambda do |num| opts[:when_done].call(num) if opts[:when_done]