1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

Use new SVG icons in tab-bar and tab-line (bug#62562)

* lisp/tab-bar.el (tab-bar--load-buttons):
Add "symbols/plus_16.svg" to tab-bar-new.
Add "symbols/cross_16.svg" to tab-bar-close.
Add "symbols/menu_16.svg" to tab-bar-menu-bar.
(tab-bar-tab-name-format-default): Use 'add-face-text-property'.
(tab-bar-history-mode):
Add "symbols/chevron_left_16.svg" to tab-bar-back.
Add "symbols/chevron_right_16.svg" to tab-bar-forward.

* lisp/tab-line.el (tab-line-new): New icon with "symbols/plus_16.svg".
(tab-line-new-button): Use it with nil rear-nonsticky.
(tab-line-close): New icon with "symbols/cross_16.svg".
(tab-line-close-button): Use it with nil rear-nonsticky.
(tab-line-left): New icon with "symbols/chevron_left_16.svg".
(tab-line-left-button): Use it with nil rear-nonsticky.
(tab-line-right): New icon with "symbols/chevron_right_16.svg".
(tab-line-right-button): Use it with nil rear-nonsticky.
(tab-line-tab-name-format-default): Use 'add-face-text-property'.
(tab-line-auto-hscroll): Append the face in 'add-face-text-property'.
This commit is contained in:
Juri Linkov 2023-08-27 20:27:35 +03:00
parent 332df9a043
commit 9500e7df86
2 changed files with 83 additions and 43 deletions

View File

@ -164,7 +164,8 @@ For easier selection of tabs by their numbers, consider customizing
(declare-function icons--register "icons")
(unless (iconp 'tab-bar-new)
(define-icon tab-bar-new nil
`((image "tabs/new.xpm"
`((image "symbols/plus_16.svg" "tabs/new.xpm"
:face shadow
:margin ,tab-bar-button-margin
:ascent center)
;; (emoji "")
@ -177,7 +178,9 @@ For easier selection of tabs by their numbers, consider customizing
(unless (iconp 'tab-bar-close)
(define-icon tab-bar-close nil
`((image "tabs/close.xpm"
`((image "symbols/cross_16.svg" "tabs/close.xpm"
:face shadow
:height (1.0 . em)
:margin ,tab-bar-button-margin
:ascent center)
;; (emoji " ❌")
@ -191,7 +194,10 @@ For easier selection of tabs by their numbers, consider customizing
(unless (iconp 'tab-bar-menu-bar)
(define-icon tab-bar-menu-bar nil
'(;; (emoji "🍔")
`((image "symbols/menu_16.svg"
:margin ,tab-bar-button-margin
:ascent center)
;; (emoji "🍔")
(symbol "")
(text "Menu" :face tab-bar-tab-inactive))
"Icon for the menu bar."
@ -799,16 +805,17 @@ the formatted tab name to display in the tab bar."
:version "28.1")
(defun tab-bar-tab-name-format-default (tab i)
(let ((current-p (eq (car tab) 'current-tab)))
(propertize
(concat (if tab-bar-tab-hints (format "%d " i) "")
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
(if current-p 'non-selected 'selected)))
tab-bar-close-button)
""))
'face (funcall tab-bar-tab-face-function tab))))
(let* ((current-p (eq (car tab) 'current-tab))
(name (concat (if tab-bar-tab-hints (format "%d " i) "")
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
(if current-p 'non-selected 'selected)))
tab-bar-close-button)
""))))
(add-face-text-property
0 (length name) (funcall tab-bar-tab-face-function tab) t name)
name))
(defcustom tab-bar-format '(tab-bar-format-history
tab-bar-format-tabs
@ -2233,7 +2240,7 @@ and can restore them."
(unless (iconp 'tab-bar-back)
(define-icon tab-bar-back nil
`((image "tabs/left-arrow.xpm"
`((image "symbols/chevron_left_16.svg" "tabs/left-arrow.xpm"
:margin ,tab-bar-button-margin
:ascent center)
(text " < "))
@ -2243,7 +2250,7 @@ and can restore them."
(unless (iconp 'tab-bar-forward)
(define-icon tab-bar-forward nil
`((image "tabs/right-arrow.xpm"
`((image "symbols/chevron_right_16.svg" "tabs/right-arrow.xpm"
:margin ,tab-bar-button-margin
:ascent center)
(text " > "))

View File

@ -190,12 +190,19 @@ If the value is a function, call it with no arguments."
:group 'tab-line
:version "27.1")
(define-icon tab-line-new nil
`((image "symbols/plus_16.svg" "tabs/new.xpm"
:face shadow
:margin (2 . 0)
:ascent center)
(text " + "))
"Icon for creating a new tab."
:version "30.1"
:help-echo "New tab")
(defvar tab-line-new-button
(propertize " + "
'display '(image :type xpm
:file "tabs/new.xpm"
:margin (2 . 0)
:ascent center)
(propertize (icon-string 'tab-line-new)
'rear-nonsticky nil
'keymap tab-line-add-map
'mouse-face 'tab-line-highlight
'help-echo "Click to add tab")
@ -218,34 +225,54 @@ If nil, don't show it at all."
:group 'tab-line
:version "27.1")
(define-icon tab-line-close nil
`((image "symbols/cross_16.svg" "tabs/close.xpm"
:face shadow
:height (1.0 . em)
:margin (2 . 0)
:ascent center)
(text " x"))
"Icon for closing the clicked tab."
:version "30.1"
:help-echo "Click to close tab")
(defvar tab-line-close-button
(propertize " x"
'display '(image :type xpm
:file "tabs/close.xpm"
:margin (2 . 0)
:ascent center)
(propertize (icon-string 'tab-line-close)
'rear-nonsticky nil ;; important to not break auto-scroll
'keymap tab-line-tab-close-map
'mouse-face 'tab-line-close-highlight
'help-echo "Click to close tab")
"Button for closing the clicked tab.")
(define-icon tab-line-left nil
`((image "symbols/chevron_left_16.svg" "tabs/left-arrow.xpm"
:face shadow
:margin (2 . 0)
:ascent center)
(text " <"))
"Icon for scrolling horizontally to the left."
:version "30.1")
(defvar tab-line-left-button
(propertize " <"
'display '(image :type xpm
:file "tabs/left-arrow.xpm"
:margin (2 . 0)
:ascent center)
(propertize (icon-string 'tab-line-left)
'rear-nonsticky nil
'keymap tab-line-left-map
'mouse-face 'tab-line-highlight
'help-echo "Click to scroll left")
"Button for scrolling horizontally to the left.")
(define-icon tab-line-right nil
`((image "symbols/chevron_right_16.svg" "tabs/right-arrow.xpm"
:face shadow
:margin (2 . 0)
:ascent center)
(text "> "))
"Icon for scrolling horizontally to the right."
:version "30.1")
(defvar tab-line-right-button
(propertize "> "
'display '(image :type xpm
:file "tabs/right-arrow.xpm"
:margin (2 . 0)
:ascent center)
(propertize (icon-string 'tab-line-right)
'rear-nonsticky nil
'keymap tab-line-right-map
'mouse-face 'tab-line-highlight
'help-echo "Click to scroll right")
@ -531,21 +558,27 @@ which the tab will represent."
(setf face (funcall fn tab tabs face buffer-p selected-p)))
(apply 'propertize
(concat (propertize (string-replace "%" "%%" name) ;; (bug#57848)
'face face
'keymap tab-line-tab-map
'help-echo (if selected-p "Current tab"
"Click to select tab")
;; Don't turn mouse-1 into mouse-2 (bug#49247)
'follow-link 'ignore)
(or (and (or buffer-p (assq 'buffer tab) (assq 'close tab))
tab-line-close-button-show
(not (eq tab-line-close-button-show
(if selected-p 'non-selected 'selected)))
tab-line-close-button)
""))
(let ((close (or (and (or buffer-p (assq 'buffer tab)
(assq 'close tab))
tab-line-close-button-show
(not (eq tab-line-close-button-show
(if selected-p 'non-selected
'selected)))
tab-line-close-button)
"")))
(setq close (copy-sequence close))
;; Don't overwrite the icon face
(add-face-text-property 0 (length close) face t close)
close))
`(
tab ,tab
,@(if selected-p '(selected t))
face ,face
mouse-face tab-line-highlight))))
(defun tab-line-format-template (tabs)
@ -684,7 +717,7 @@ the selected tab visible."
(erase-buffer)
(apply 'insert strings)
(goto-char (point-min))
(add-face-text-property (point-min) (point-max) 'tab-line)
(add-face-text-property (point-min) (point-max) 'tab-line t)
;; Continuation means tab-line doesn't fit completely,
;; thus scroll arrows are needed for scrolling.
(setq show-arrows (> (vertical-motion 1) 0))