]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/scroll-mode.rb
Merge branch 'xapian-updates'
[sup] / lib / sup / modes / scroll-mode.rb
index 2d70fef04db91f1337e7261366695f4661c67264..c13142599e9aed1aaad9bde0c1a029b2331fa72e 100644 (file)
@@ -3,7 +3,7 @@ module Redwood
 class ScrollMode < Mode
   ## we define topline and botline as the top and bottom lines of any
   ## content in the currentview.
-  
+
   ## we left leftcol and rightcol as the left and right columns of any
   ## content in the current view. but since we're operating in a
   ## line-centric fashion, rightcol is always leftcol + the buffer
@@ -73,7 +73,7 @@ class ScrollMode < Mode
     end
     if line
       @search_line = line + 1
-      search_goto_pos line, col, col + @search_query.length
+      search_goto_pos line, col, col + @search_query.display_length
       buffer.mark_dirty
     else
       BufferManager.flash "Not found!"
@@ -87,15 +87,16 @@ class ScrollMode < Mode
     continue_search_in_buffer
   end
 
-  ## subclasses can override these two!
+  ## subclasses can override these three!
   def search_goto_pos line, leftcol, rightcol
-    jump_to_line line
+    search_goto_line line
 
     if rightcol > self.rightcol # if it's occluded...
       jump_to_col [rightcol - buffer.content_width + 1, 0].max # move right
     end
   end
   def search_start_line; @topline end
+  def search_goto_line line; jump_to_line line end
 
   def col_left
     return unless @leftcol > 0
@@ -163,7 +164,7 @@ protected
           if match
             return [i, offset + match]
           else
-            offset += string.length
+            offset += string.display_length
           end
         end
       end
@@ -218,24 +219,25 @@ protected
 
   def draw_line_from_array ln, a, opts
     xpos = 0
-    a.each do |color, text|
+    a.each_with_index do |(color, text), i|
       raise "nil text for color '#{color}'" if text.nil? # good for debugging
-      
-      if xpos + text.length < @leftcol
+      l = text.display_length
+      no_fill = i != a.size - 1
+
+      if xpos + l < @leftcol
         buffer.write ln - @topline, 0, "", :color => color,
                      :highlight => opts[:highlight]
-        xpos += text.length
       elsif xpos < @leftcol
         ## partial
         buffer.write ln - @topline, 0, text[(@leftcol - xpos) .. -1],
                      :color => color,
-                     :highlight => opts[:highlight]
-        xpos += text.length
+                     :highlight => opts[:highlight], :no_fill => no_fill
       else
         buffer.write ln - @topline, xpos - @leftcol, text,
-                     :color => color, :highlight => opts[:highlight]
-        xpos += text.length
+                     :color => color, :highlight => opts[:highlight],
+                     :no_fill => no_fill
       end
+      xpos += l
     end
   end