Christophe Weblog Wiki Code Publications Music
simplify squeeze-mixer-compute-bar a bit
[squeeze-el.git] / squeeze.el
index 406ffac5adaf74040a1da74c9248bb0ba6183111..6e4f4da4c35371d6b677382a768b0fb3f3b83a42 100644 (file)
     (define-key map (kbd "TAB") 'completion-at-point)
     map))
 
+(defun squeeze-unhex-and-decode-utf8-string (string)
+  (decode-coding-string (url-unhex-string string) 'utf-8))
+
 (define-derived-mode squeeze-mode comint-mode "Squeeze"
   "Major mode for interacting with the Squeezebox Server CLI.\\<squeeze-mode-map>"
   (add-to-list 'completion-at-point-functions 'squeeze-complete-command-at-point)
-  (add-hook 'comint-preoutput-filter-functions 'url-unhex-string nil t)
+  (add-hook 'comint-preoutput-filter-functions 'squeeze-unhex-and-decode-utf8-string nil t)
   (add-hook 'comint-preoutput-filter-functions 'squeeze-update-state nil t))
 
 (defvar squeeze-control-mode-map
          (nblank (floor (- width exact))))
     (format "%s%s%s"
             (make-string nfull ?█)
-            (cond ((= width (+ nfull nblank)) "")
-                  ((< frac 0.0625) " ")
-                  ((< frac 0.1875) "▏")
-                  ((< frac 0.3125) "▎")
-                  ((< frac 0.4375) "▍")
-                  ((< frac 0.5625) "▌")
-                  ((< frac 0.6875) "▋")
-                  ((< frac 0.8125) "▊")
-                  ((< frac 0.9375) "▉")
-                  (t "█"))
+            (if (= width (+ nfull nblank))
+                ""
+              (aref " ▏▎▍▌▋▊▉█" (floor (+ frac 0.0625) 0.125)))
             (make-string nblank ? ))))
 
 (defun squeeze-mixer-make-bar (vol width)
     (squeeze-control-listen)
     (squeeze-control-refresh)
     (squeeze-control-display-players)))
+
+(provide 'squeeze)