Function: window-tool-bar-string

window-tool-bar-string is an autoloaded and byte-compiled function defined in window-tool-bar.el.gz.

Signature

(window-tool-bar-string)

Documentation

Return a (propertized) string for the tool bar.

This is for when you want more customizations than the command window-tool-bar-mode(var)/window-tool-bar-mode(fun) provides. Commonly added to the variable tab-line-format(var)/tab-line-format(fun), header-line-format, or mode-line-format

Source Code

;; Defined in /usr/src/emacs/lisp/window-tool-bar.el.gz
;;;###autoload
(defun window-tool-bar-string ()
  "Return a (propertized) string for the tool bar.

This is for when you want more customizations than the command
`window-tool-bar-mode' provides.  Commonly added to the variable
`tab-line-format', `header-line-format', or `mode-line-format'"
  (if (or (null window-tool-bar-string--cache)
          (window-tool-bar--last-command-triggers-refresh-p))
      (let* ((mem0 (memory-use-counts))
             (toolbar-menu (window-tool-bar--get-keymap))
             (mem1 (memory-use-counts))
             (strs (mapcar #'window-tool-bar--keymap-entry-to-string
                           (cdr toolbar-menu))) ;Skip 'keymap
             (result (mapconcat #'identity
                                (delete nil strs)
                                ;; Without spaces between the text, hovering
                                ;; highlights all adjacent buttons.
                                (if (eq 'text (window-tool-bar--style)) " "
                                  (propertize " " 'invisible t))))
             (mem2 (memory-use-counts)))
        (cl-mapl (lambda (l-init l0 l1)
                   (incf (car l-init) (- (car l1) (car l0))))
                 window-tool-bar--memory-use-delta-step1 mem0 mem1)
        (cl-mapl (lambda (l-init l1 l2)
                   (incf (car l-init) (- (car l2) (car l1))))
                 window-tool-bar--memory-use-delta-step2 mem1 mem2)

        (setf window-tool-bar-string--cache
              (concat
               ;; The tool bar face by default puts boxes around the
               ;; buttons.  However, this box is not displayed if the
               ;; box starts at the leftmost pixel of the tab-line.
               ;; Add a single space in this case so the box displays
               ;; correctly.
               (and (display-supports-face-attributes-p
                     '(:box (line-width 1)))
                    (propertize " " 'display '(space :width (1))))
               result))
        (incf window-tool-bar--refresh-done-count))
    (incf window-tool-bar--refresh-skipped-count))

  window-tool-bar-string--cache)