]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a Doc View tool bar
authorPo Lu <luangruo@yahoo.com>
Thu, 13 Jul 2023 11:19:57 +0000 (19:19 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 13 Jul 2023 11:19:57 +0000 (19:19 +0800)
* etc/NEWS: Announce the new tool bar.
* etc/images/last-page.xpm:
* etc/images/last-page.pbm: New images.  Mirrored from
next-page.xpm.
* lisp/doc-view.el (doc-view-menu): Use `doc-view-new-search'
instead of an anonymous function.
(doc-view-tool-bar-map): New keymap.
(doc-view-search): Update the tool bar after initiating a
search.
(doc-view-new-search): New command.
(doc-view-mode): Set the tool bar map appropriately.

etc/NEWS
etc/images/last-page.pbm [new file with mode: 0644]
etc/images/last-page.xpm [new file with mode: 0644]
lisp/doc-view.el

index db4fa9f403efdabba576dd3f8bf04ae8a81478ab..8150c71af11e36d7aecfc50d8cb6b6dee42c95c8 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -360,6 +360,12 @@ this new face when DocView displays documents, customize this face to
 restore the colors you were used to, or to get colors more to your
 liking.
 
+---
+*** DocView buffers now display a new tool bar.
+This tool bar contains options for searching and navigating within the
+document, replacing the incompatible items for incremental search and
+editing within the default tool bar displayed in the past.
+
 ** Shortdoc
 
 +++
diff --git a/etc/images/last-page.pbm b/etc/images/last-page.pbm
new file mode 100644 (file)
index 0000000..d25ce02
Binary files /dev/null and b/etc/images/last-page.pbm differ
diff --git a/etc/images/last-page.xpm b/etc/images/last-page.xpm
new file mode 100644 (file)
index 0000000..5704143
--- /dev/null
@@ -0,0 +1,122 @@
+/* XPM */
+static char *last_page[] = {
+/* columns rows colors chars-per-pixel */
+"24 24 92 1 ",
+"  c None",
+". c black",
+"X c gray15",
+"o c #2F4050",
+"O c #344353",
+"+ c #3B4F63",
+"@ c #384F66",
+"# c #3A5067",
+"$ c #3C5064",
+"% c #3C5065",
+"& c #3E5166",
+"* c #3F5266",
+"= c #3A5168",
+"- c #3B5269",
+"; c #3D526A",
+": c #3E546A",
+"> c #3F556B",
+", c #3E5975",
+"< c #3F5A76",
+"1 c #464646",
+"2 c #494949",
+"3 c #405367",
+"4 c #405468",
+"5 c #40566C",
+"6 c #41576D",
+"7 c #42586E",
+"8 c #44586F",
+"9 c #45596F",
+"0 c #465B70",
+"q c #415B77",
+"w c #425C78",
+"e c #435E79",
+"r c #445F7A",
+"t c #46607B",
+"y c #47617B",
+"u c #47617C",
+"i c #48627D",
+"p c #49637D",
+"a c #4B647E",
+"s c #4C647F",
+"d c #4C657F",
+"f c gray38",
+"g c #6A6A6A",
+"h c #616A73",
+"j c #68727D",
+"k c #7C7C7C",
+"l c #4E6780",
+"z c #4F6881",
+"x c #506982",
+"c c #526A83",
+"v c #556D85",
+"b c #5B7289",
+"n c #7D8185",
+"m c #77838F",
+"M c #868788",
+"N c #888888",
+"B c #8B8B8B",
+"V c #8F9296",
+"C c #8F9396",
+"Z c #8F9397",
+"A c #909397",
+"S c #959595",
+"D c #91969C",
+"F c #91979C",
+"G c #92979C",
+"H c #92979D",
+"J c #9C9FA1",
+"K c #9D9FA2",
+"L c #A2A3A4",
+"P c #A6A6A6",
+"I c #ACACAC",
+"U c gray68",
+"Y c #B0B0B0",
+"T c #B2B2B2",
+"R c gray71",
+"E c #B6B6B6",
+"W c gray75",
+"Q c #C5C5C5",
+"! c gray79",
+"~ c gray80",
+"^ c LightGray",
+"/ c #D6D6D6",
+"( c #D8D8D8",
+") c #DADADA",
+"_ c #DEDEDE",
+"` c gray89",
+"' c #E5E5E5",
+"] c #E6E6E6",
+"[ c #EEEEEE",
+"{ c #F2F2F2",
+"} c #F6F6F6",
+"| c white",
+/* pixels */
+"                        ",
+"                        ",
+"   ........   ........  ",
+"  .vU/_][`!N2gNT~)]{|b. ",
+"  .@T/_][}||PUTW~)]{|t. ",
+"  .#T/_][}`|PUTW~)]{|t. ",
+"  .-T/_][).|PUTW~)]{|t. ",
+"  .-T/_]^..|PUTW~)]{|t. ",
+"  .;T/_~...|PUTW~)]{|u. ",
+"  .>T/Q.....X1fkSR]{|i. ",
+"  .>T/_~...|PUTW~)]{|i. ",
+"  .5T/_]^..|PUTW~)]{|a. ",
+"  .5T/_][).|PUTW~)]{|d. ",
+"  .7T/_][}`|PUTW~)]{|d. ",
+"  .8T/_][}||PUTW~)]{|l. ",
+"  .8R/_][}||PUTW~)]{|z. ",
+"  .0MAZZZZZKPLHHHHHKmc. ",
+"  .O43&&&&+hnjtrwwq<<c. ",
+"  ..........o.........  ",
+"           ...          ",
+"                        ",
+"                        ",
+"                        ",
+"                        "
+};
index b14655fb2740e5b7c0eb61ca3123546bf8a237c7..c381d5d34a05a0ecfd3da4dd4ce90500dc3383d5 100644 (file)
@@ -643,7 +643,7 @@ Typically \"page-%s.png\".")
       :help                     "Reset the current slice"
       :enabled                  (image-mode-window-get 'slice)])
     "---"
-    ["New Search"               (doc-view-search t)
+    ["New Search"               doc-view-new-search
      :help                      "Initiate a new search"]
     ["Search Forward"           doc-view-search
      :help                      "Jump to the next match or initiate a new search"]
@@ -666,6 +666,45 @@ Typically \"page-%s.png\".")
       :style radio :selected    (eq major-mode 'doc-view-mode)])
     ["Exit DocView Mode" doc-view-minor-mode]))
 
+(defvar doc-view-tool-bar-map
+  (let ((map (make-sparse-keymap)))
+    ;; Most of these items are the same as in the default tool bar
+    ;; map, but with extraneous items removed, and with extra search
+    ;; and navigation items.
+    (tool-bar-local-item-from-menu 'find-file "new" map
+                                   nil :label "New File"
+                                  :vert-only t)
+    (tool-bar-local-item-from-menu 'menu-find-file-existing "open" map
+                                   nil :label "Open" :vert-only t)
+    (tool-bar-local-item-from-menu 'dired "diropen" map nil :vert-only t)
+    (tool-bar-local-item-from-menu 'kill-this-buffer "close" map nil
+                                   :vert-only t)
+    (define-key-after map [separator-1] menu-bar-separator)
+    (tool-bar-local-item-from-menu 'doc-view-new-search "search"
+                                  map doc-view-mode-map :vert-only t
+                                   :help "Start a new search query.")
+    (tool-bar-local-item-from-menu 'doc-view-search-backward "left-arrow"
+                                  map doc-view-mode-map
+                                   :vert-only t
+                                   :enable 'doc-view--current-search-matches
+                                   :help "Move to the last search result.")
+    (tool-bar-local-item-from-menu 'doc-view-search "right-arrow"
+                                  map doc-view-mode-map :vert-only t
+                                   :enable 'doc-view--current-search-matches
+                                   :help "Move to the next search result.")
+    (define-key-after map [separator-2] menu-bar-separator)
+    (tool-bar-local-item-from-menu 'doc-view-previous-page "last-page"
+                                   map doc-view-mode-map :vert-only t
+                                   :enable '(> (doc-view-current-page) 1)
+                                   :help "Move to the next page.")
+    (tool-bar-local-item-from-menu 'doc-view-next-page "next-page"
+                                   map doc-view-mode-map :vert-only t
+                                   :enable '(< (doc-view-current-page)
+                                               (doc-view-last-page-number))
+                                   :help "Move to the next page.")
+    map)
+  "Like the default `tool-bar-map', but with additions for DocView.")
+
 ;;;; Navigation Commands
 
 (defun doc-view-last-page-number ()
@@ -1863,7 +1902,16 @@ If BACKWARD is non-nil, jump to the previous match."
        ;; We must convert to TXT first!
        (if doc-view--current-converter-processes
            (message "DocView: please wait till conversion finished.")
-         (doc-view-doc->txt txt (lambda () (doc-view-search nil))))))))
+         (doc-view-doc->txt txt (lambda () (doc-view-search nil))))))
+    ;; Update the tool bar items.
+    (force-mode-line-update)))
+
+(defun doc-view-new-search ()
+  "Initiate a new search query.
+Prompt for a string, then search for its appearances within
+the document text."
+  (interactive)
+  (doc-view-search t nil))
 
 (defun doc-view-search-next-match (arg)
   "Go to the ARGth next matching page."
@@ -2238,6 +2286,8 @@ toggle between displaying the document or editing it as text.
          major-mode 'doc-view-mode)
     (doc-view-imenu-setup)
     (doc-view-initiate-display)
+    ;; Replace the tool bar map with `doc-view-tool-bar-map'.
+    (setq-local tool-bar-map doc-view-tool-bar-map)
     ;; Switch off view-mode explicitly, because doc-view-mode is the
     ;; canonical view mode for PDF/PS/DVI files.  This could be
     ;; switched on automatically depending on the value of