Guest User

Untitled

a guest
Jul 4th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 4.43 KB | None | 0 0
  1. (defvar powerline-color1)
  2. (defvar powerline-color2)
  3.  
  4. (setq powerline-color1 "grey22")
  5. (setq powerline-color2 "grey40")
  6.  
  7. (set-face-attribute 'mode-line nil
  8. ;                    "IndianRed4"
  9.                     :box nil)
  10. (set-face-attribute 'mode-line-inactive nil
  11.                     :box nil)
  12.  
  13. (defun arrow-right-xpm (color1 color2)
  14.   "Return an XPM right arrow string representing."
  15.   (create-image
  16.    (format "/* XPM */
  17. static char * arrow_right[] = {
  18. \"12 18 2 1\",
  19. \". c %s\",
  20. \"  c %s\",
  21. \".           \",
  22. \"..          \",
  23. \"...         \",
  24. \"....        \",
  25. \".....       \",
  26. \"......      \",
  27. \".......     \",
  28. \"........    \",
  29. \".........   \",
  30. \".........   \",
  31. \"........    \",
  32. \".......     \",
  33. \"......      \",
  34. \".....       \",
  35. \"....        \",
  36. \"...         \",
  37. \"..          \",
  38. \".           \"};"
  39.            (if color1 color1 "None")
  40.            (if color2 color2 "None"))
  41.    'xpm t :ascent 'center))
  42.  
  43. (defun arrow-left-xpm (color1 color2)
  44.   "Return an XPM right arrow string representing."
  45.   (create-image
  46.    (format "/* XPM */
  47. static char * arrow_right[] = {
  48. \"12 18 2 1\",
  49. \". c %s\",
  50. \"  c %s\",
  51. \"           .\",
  52. \"          ..\",
  53. \"         ...\",
  54. \"        ....\",
  55. \"       .....\",
  56. \"      ......\",
  57. \"     .......\",
  58. \"    ........\",
  59. \"   .........\",
  60. \"   .........\",
  61. \"    ........\",
  62. \"     .......\",
  63. \"      ......\",
  64. \"       .....\",
  65. \"        ....\",
  66. \"         ...\",
  67. \"          ..\",
  68. \"           .\"};"
  69.            (if color2 color2 "None")
  70.            (if color1 color1 "None"))
  71.    'xpm t :ascent 'center))
  72.  
  73. (defvar powerline-minor-modes nil)
  74.  
  75. (defun powerline-make-face (bg &optional fg)
  76.   (if bg
  77.       (let ((cface (intern (concat "powerline-" bg))))
  78.         (make-face cface)
  79.         (set-face-attribute cface nil
  80.                             :foreground (if fg fg "white")
  81.                             :background bg
  82.                             :box nil)
  83.         cface)
  84.     nil))
  85. (defun powerline-make-left (string color1 color2 &optional localmap)
  86.   (let ((plface (powerline-make-face color1)))
  87.     (concat
  88.      (if localmap
  89.          (propertize string 'face plface 'mouse-face plface 'local-map localmap)
  90.        (propertize string 'face plface))
  91.      (propertize " " 'display (arrow-right-xpm color1 color2)))))
  92. (defun powerline-make-right (string color1 color2 &optional localmap)
  93.   (let ((plface (powerline-make-face color2)))
  94.     (concat
  95.      (propertize " " 'display (arrow-left-xpm color1 color2))
  96.      (if localmap
  97.          (propertize string 'face plface 'mouse-face plface 'local-map localmap)
  98.        (propertize string 'face plface)))))
  99. (defun powerline-make-center (color)
  100.   ;; justify right by filling with spaces to right fringe, 20 should be calculated
  101.   (propertize " " 'display '((space :align-to (- right-fringe 20)))
  102.                   'face (powerline-make-face color)))
  103.  
  104. (defun powerline-make (side color1 color2 string &optional localmap)
  105.   (cond ((eq side 'right) (powerline-make-right string color2 color1 localmap))
  106.         (t                (powerline-make-left  string color1 color2 localmap))))
  107.  
  108. (defun powerline-buffer-info (side color1 color2)
  109.   (powerline-make side color1 color2 " %* %I %b "))
  110. (defun powerline-modelist (side color1 color2)
  111.   (powerline-make side color1 color2
  112.                   (if powerline-minor-modes
  113.                       (concat " %[%m%]" (format-mode-line minor-mode-alist) " ")
  114.                     " %[%m%] ")
  115.                   (make-mode-line-mouse-map
  116.                    'mouse-1 (lambda () (interactive)
  117.                              (setq powerline-minor-modes (not powerline-minor-modes))
  118.                              (redraw-modeline)))))
  119. (defun powerline-scroll (side color1 color2)
  120.   (powerline-make side color1 color2 " %6p "))
  121. (defun powerline-row-column (side color1 color2)
  122.   (powerline-make side color1 color2 "%4l:%2c   "))
  123.  
  124. (setq-default mode-line-format
  125.               (list '(:eval (powerline-buffer-info 'left   nil  powerline-color1                    ))
  126.                     '(:eval (powerline-modelist    'left        powerline-color1  powerline-color2  ))
  127.                     '(:eval (powerline-make-center                                powerline-color2  ))
  128.                     '(:eval (powerline-scroll      'right       powerline-color1  powerline-color2  ))
  129.                     '(:eval (powerline-row-column  'right  nil  powerline-color1                    ))))
  130.  
  131. (provide 'powerline)
Add Comment
Please, Sign In to add comment