add cancle button
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
"\n")
|
||||
|
||||
(defun my-tool-bar-function-save (event)
|
||||
"Pop up the same menu as displayed by the menu bar.
|
||||
Used by `tab-bar-format-menu-bar'."
|
||||
"Run `save-buffer'."
|
||||
(interactive "e")
|
||||
(let ()
|
||||
;;(message "%s" event)
|
||||
@@ -18,11 +17,10 @@ Used by `tab-bar-format-menu-bar'."
|
||||
))
|
||||
|
||||
(defvar my-tool-bar-button-save "Save "
|
||||
"Button for going back in tab history.")
|
||||
"Button to run `save-buffer'.")
|
||||
|
||||
(defun my-tool-bar-function-open (event)
|
||||
"Pop up the same menu as displayed by the menu bar.
|
||||
Used by `tab-bar-format-menu-bar'."
|
||||
"Run `find-file' or 'counsel-find-file' if available."
|
||||
(interactive "e")
|
||||
(let ()
|
||||
;;(message "%s" event)
|
||||
@@ -33,7 +31,19 @@ Used by `tab-bar-format-menu-bar'."
|
||||
))
|
||||
|
||||
(defvar my-tool-bar-button-open "Open "
|
||||
"Button for going back in tab history.")
|
||||
"Button to run `find-file' or `counsel-find-file' if available.")
|
||||
|
||||
(defun my-tool-bar-function-cancle (event)
|
||||
"Run `keyboard-escape-quit'."
|
||||
;; "Run `keyboard-quit'."
|
||||
(interactive "e")
|
||||
(let ()
|
||||
;; (keyboard-quit)
|
||||
(keyboard-escape-quit)))
|
||||
|
||||
(defvar my-tool-bar-button-cancle "Cancle "
|
||||
"Button to run `keyboard-escape-quit'.")
|
||||
;; "Button to run `keyboard-quit'."
|
||||
|
||||
;; (defun my-tool-bar-format-save ()
|
||||
;; "Produce the Menu button for the tool bar that shows the menu bar."
|
||||
@@ -54,15 +64,17 @@ You can hide these buttons by customizing `tab-bar-format' and removing
|
||||
(open
|
||||
menu-item ,my-tool-bar-button-open my-tool-bar-function-open
|
||||
:help "Open File...")
|
||||
(sep-tool-bar menu-item ,(my-tool-bar-newline) ignore)
|
||||
)))
|
||||
(cancle
|
||||
menu-item ,my-tool-bar-button-cancle my-tool-bar-function-cancle
|
||||
:help "Cancle")
|
||||
(sep-tool-bar menu-item ,(my-tool-bar-newline) ignore))))
|
||||
|
||||
(defun my-tool-bar--load-buttons ()
|
||||
"Load the icons for the tool bar buttons."
|
||||
;; (emoji "<empji>") see e.g. https://emojipedia.org/hamburger
|
||||
;; (symbol "<unicode>") see e.g. https://www.compart.com/en/unicode/U+2630
|
||||
(require 'icons)
|
||||
|
||||
|
||||
(unless (iconp 'my-tool-bar-icon-save)
|
||||
(define-icon my-tool-bar-icon-save nil
|
||||
`((image "save.xpm"
|
||||
@@ -74,10 +86,10 @@ You can hide these buttons by customizing `tab-bar-format' and removing
|
||||
(text "Save"
|
||||
;; :face tab-bar-tab-inactive
|
||||
))
|
||||
"Icon for the menu bar."
|
||||
"Icon for save."
|
||||
:version "29.1"))
|
||||
(setq my-tool-bar-button-save (icon-string 'my-tool-bar-icon-save))
|
||||
|
||||
|
||||
(unless (iconp 'my-tool-bar-icon-open)
|
||||
(define-icon my-tool-bar-icon-open nil
|
||||
`((image "open.xpm"
|
||||
@@ -89,28 +101,41 @@ You can hide these buttons by customizing `tab-bar-format' and removing
|
||||
(text "Open"
|
||||
;; :face tab-bar-tab-inactive
|
||||
))
|
||||
"Icon for the menu bar."
|
||||
"Icon for open file."
|
||||
:version "29.1"))
|
||||
(setq my-tool-bar-button-open (icon-string 'my-tool-bar-icon-open))
|
||||
|
||||
)
|
||||
(unless (iconp 'my-tool-bar-icon-cancle)
|
||||
(define-icon my-tool-bar-icon-cancle nil
|
||||
`((image "cancel.xpm"
|
||||
:height (1.5 . em)
|
||||
:margin ,tab-bar-button-margin
|
||||
:ascent center)
|
||||
(text "Quit"
|
||||
;; :face tab-bar-tab-inactive
|
||||
))
|
||||
"Icon for quit."
|
||||
:version "29.1"))
|
||||
(setq my-tool-bar-button-cancle (icon-string 'my-tool-bar-icon-cancle))
|
||||
|
||||
)
|
||||
|
||||
(define-minor-mode my-tool-bar-mode
|
||||
"Toggle tab history mode for the tab bar.
|
||||
Tab history mode remembers window configurations used in every tab,
|
||||
and can restore them."
|
||||
"Toggle tool bar mode for the tab bar.
|
||||
Tool bar mode displays action buttons.
|
||||
It will enable `tab-bar-mode' if not already."
|
||||
:global t :group 'tab-bar
|
||||
(if my-tool-bar-mode
|
||||
(progn
|
||||
(my-tool-bar--load-buttons)
|
||||
|
||||
(unless tab-bar-mode
|
||||
(tab-bar-mode 1))
|
||||
;;(add-hook 'pre-command-hook #'tab-bar--history-pre-change)
|
||||
;;(add-hook 'window-configuration-change-hook #'tab-bar--history-change)
|
||||
)
|
||||
;;(remove-hook 'pre-command-hook #'tab-bar--history-pre-change)
|
||||
;;(remove-hook 'window-configuration-change-hook #'tab-bar--history-change)
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
(provide 'my-tool-bar)
|
||||
|
||||
Reference in New Issue
Block a user