sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 771c7998fa7a8db1d593cbe1978ce1826b0e97f5
parent 8fa7bb5b7da0496f9c0bdc38952aad3502521493
Author: Antoni Kaniowski <a@generativestuff.com>
Date:   Mon, 28 Sep 2015 14:34:29 +0200

INDENT_SPACES are now configurable via config.yaml

Diffstat:
M lib/sup.rb | 1 +
M lib/sup/modes/thread_view_mode.rb | 9 ++++-----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -331,6 +331,7 @@ EOM
       :poll_interval => 300,
       :wrap_width => 0,
       :slip_rows => 0,
+      :indent_spaces => 2,
       :col_jump => 2,
       :stem_language => "english",
       :sync_back_to_maildir => false,
diff --git a/lib/sup/modes/thread_view_mode.rb b/lib/sup/modes/thread_view_mode.rb
@@ -10,8 +10,6 @@ class ThreadViewMode < LineCursorMode
     attr_accessor :state
   end
 
-  INDENT_SPACES = 2 # how many spaces to indent child messages
-
   HookManager.register "detailed-headers", <<EOS
 Add or remove headers from the detailed header display of a message.
 Variables:
@@ -127,6 +125,7 @@ EOS
   ## objects. @person_lines is a map from row #s to Person objects.
 
   def initialize thread, hidden_labels=[], index_mode=nil
+    @indent_spaces = $config[:indent_spaces]
     super :slip_rows => $config[:slip_rows]
     @thread = thread
     @hidden_labels = hidden_labels
@@ -561,7 +560,7 @@ EOS
     l = @layout[m]
 
     ## boundaries of the message
-    message_left = l.depth * INDENT_SPACES
+    message_left = l.depth * @indent_spaces
     message_right = message_left + l.width
 
     ## calculate leftmost colum
@@ -886,7 +885,7 @@ private
           (0 ... text.length).each do |i|
             @chunk_lines[@text.length + i] = c
             @message_lines[@text.length + i] = m
-            lw = text[i].flatten.select { |x| x.is_a? String }.map { |x| x.display_length }.sum - (depth * INDENT_SPACES)
+            lw = text[i].flatten.select { |x| x.is_a? String }.map { |x| x.display_length }.sum - (depth * @indent_spaces)
             l.width = lw if lw > l.width
           end
           @text += text
@@ -991,7 +990,7 @@ private
 
   ## todo: check arguments on this overly complex function
   def chunk_to_lines chunk, state, start, depth, parent=nil, color=nil, star_color=nil
-    prefix = " " * INDENT_SPACES * depth
+    prefix = " " * @indent_spaces * depth
     case chunk
     when :fake_root
       [[[:missing_message_color, "#{prefix}<one or more unreceived messages>"]]]