about summary refs log tree commit diff
path: root/emacs/wc-doom-functions.el
blob: 4c35a24b5bc0c9df41949e6274075c0f3bc6574e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(defun make-xpm-bar (color height width)
  "Create an XPM bitmap of a bar."
  (propertize
   " " 'display
   (let ((data (make-list height (make-list width 1)))
         (color (or color "None")))
     (create-image
      (concat
       (format "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 1\",\n\". c %s\",\n\"  c %s\","
               (length (car data))
               (length data)
               color
               color)
       (apply #'concat
              (cl-loop with idx = 0
                       with len = (length data)
                       for dl in data
                       do (cl-incf idx)
                       collect
                       (concat "\""
                               (cl-loop for d in dl
                                        if (= d 0) collect (string-to-char " ")
                                        else collect (string-to-char "."))
                               (if (eq idx len) "\"};" "\",\n")))))
      'xpm t :ascent 'center))))

(defun my-tabbar-display-tab (tab)
    (let ((label (if tabbar--buffer-show-groups
                     (format "[%s]" (tabbar-tab-tabset tab))
                   (format "%s" (tabbar-tab-value tab))))
          (bar-color "#51afef")
          (bar-height 25)
          (bar-width 3)
          (selected-p (eq tab (tabbar-selected-tab (tabbar-current-tabset)))))
      (concat (when (and (display-graphic-p) selected-p)
                (make-xpm-bar bar-color bar-height bar-width))
              " "
              (if tabbar-auto-scroll-flag
                  label
                (tabbar-shorten
                 label (max 1 (/ (window-width)
                                 (length (tabbar-view
                                          (tabbar-current-tabset)))))))
              " ")))

(setq tabbar-tab-label-function #'my-tabbar-display-tab)