Skip to content
This repository
Browse code

* helm-buffers.el (helm-c-highlight-buffers): Issue #170 Revert again.

Keep using only `helm-substring-by-width' for all.
This is not working with european fonts AND using multibyte strings as
buffer names, but works fine with common Japonese/chinese fonts, so keep
it like this for now.
* helm-utils.el (helm-substring-by-width): Revert.
  • Loading branch information...
commit c0c3b998a5a0dd1e3b1121f98144b24a34e61b46 1 parent bc8bc49
Thierry Volpiatto authored December 14, 2012
7  helm-buffers.el
@@ -205,10 +205,9 @@ Should be called after others transformers i.e (boring buffers)."
205 205
                                   (make-string it ? ) "")
206 206
         do (setq old-len-size (+ len-size (length str-before-size)))
207 207
         for truncbuf = (if (> (string-width i) helm-buffer-max-length)
208  
-                           (if (helm-string-multibyte-p i)
209  
-                               (helm-substring-by-width i helm-buffer-max-length)
210  
-                               (concat (substring i 0 helm-buffer-max-length)
211  
-                                   "..."))
  208
+                           ;; Issue #170, FIXME, this works only with
  209
+                           ;; some fonts.
  210
+                           (helm-substring-by-width i helm-buffer-max-length)
212 211
                            (concat i (make-string
213 212
                                       (- (+ helm-buffer-max-length 3)
214 213
                                          (string-width i)) ? )))
12  helm-utils.el
@@ -225,13 +225,15 @@ Handle multibyte characters by moving by columns."
225 225
 
226 226
 (defun helm-substring-by-width (str width)
227 227
   "Truncate string STR to end at column WIDTH.
228  
-Like using `substring' from 0 to end, but handle multibyte characters."
  228
+Similar to `truncate-string-to-width'.
  229
+Add \"...\" at end of truncated STR.
  230
+Add spaces at end if needed to reach WIDTH."
229 231
   (loop for ini-str = str
230  
-        then (helm-substring ini-str (1- (length ini-str)))
231  
-        for sw = (1- (string-width ini-str))
  232
+        then (substring ini-str 0 (1- (length ini-str)))
  233
+        for sw = (string-width ini-str)
232 234
         when (<= sw width) return
233  
-        (concat ini-str "..." (make-string (1+ (- width sw)) ? ))))
234  
-      
  235
+        (concat ini-str "..." (make-string (- width sw) ? ))))
  236
+
235 237
 (defun helm-string-multibyte-p (str)
236 238
   "Check if string STR contains multibyte characters."
237 239
   (loop for c across str

0 notes on commit c0c3b99

Please sign in to comment.
Something went wrong with that request. Please try again.